arush
arush
Explore posts from servers
DTDrizzle Team
Created by arush on 3/8/2024 in #help
drizzle-studio doesn't see pgView materialized views
@Rami that thread isn't helping. pls take a look at my code above
7 replies
DTDrizzle Team
Created by arush on 2/29/2024 in #help
push keeps wanting to truncate my existing table data
got it. i have to keep the schema.ts in the drizzle folder. i was deleting it after the introspect. thanks!
7 replies
DTDrizzle Team
Created by arush on 2/29/2024 in #help
push keeps wanting to truncate my existing table data
after the introspect i do a push and it wants to delete the contents of the existing data, it makes no sense
7 replies
DTDrizzle Team
Created by arush on 2/29/2024 in #help
push keeps wanting to truncate my existing table data
ive done the introspect, and that's where the above code comes from
7 replies
DTDrizzle Team
Created by arush on 2/29/2024 in #help
push keeps wanting to truncate my existing table data
above is my code in schema.ts, the comment block explains the issue
7 replies
DTDrizzle Team
Created by arush on 2/29/2024 in #help
push keeps wanting to truncate my existing table data
import { pgTable, pgTableCreator, unique, uuid, varchar, foreignKey, serial, integer, jsonb, boolean, index, timestamp, text } from "drizzle-orm/pg-core"
import { sql } from "drizzle-orm"

/**
* BEGIN remember to comment out before running db:push else it will DELETE ALL DATA IN THESE TABLES
*
* EXISTING TABLES
* These tables were in the db before setting up this project and we need them.
* Drizzle is not responsible for handling their creation but we need to define them as models here
* for type inference in tRPC and the api.
*
* However, defining them here causes drizzle to want to delete all content on db:push
*
* */

export const digitalAssetPrices = pgTable("digital_asset_prices", {
id: uuid("id").default(sql`uuid_generate_v4()`).primaryKey().notNull(),
name: varchar("name", { length: 255 }),
petitionPrice: varchar("petition_price", { length: 255 }),
type: varchar("type", { length: 255 }),
},
(table) => {
return {
digitalAssetPricesNameKey: unique("digital_asset_prices_name_key").on(table.name),
}
});

...

/**
* END remember to comment out before running db:push else it will DELETE ALL DATA IN THESE TABLES
* */


export const users = pgTable("users", {
id: serial("id").primaryKey().notNull(),
uuid: uuid("uuid").default(sql`uuid_generate_v4()`),
fullName: text("full_name"),
phone: varchar("phone", { length: 256 }),
email: varchar("email", { length: 256 }),
createdAt: timestamp("created_at", { mode: 'string' }).defaultNow().notNull(),
updatedAt: timestamp("updated_at", { mode: 'string' }),
});
import { pgTable, pgTableCreator, unique, uuid, varchar, foreignKey, serial, integer, jsonb, boolean, index, timestamp, text } from "drizzle-orm/pg-core"
import { sql } from "drizzle-orm"

/**
* BEGIN remember to comment out before running db:push else it will DELETE ALL DATA IN THESE TABLES
*
* EXISTING TABLES
* These tables were in the db before setting up this project and we need them.
* Drizzle is not responsible for handling their creation but we need to define them as models here
* for type inference in tRPC and the api.
*
* However, defining them here causes drizzle to want to delete all content on db:push
*
* */

export const digitalAssetPrices = pgTable("digital_asset_prices", {
id: uuid("id").default(sql`uuid_generate_v4()`).primaryKey().notNull(),
name: varchar("name", { length: 255 }),
petitionPrice: varchar("petition_price", { length: 255 }),
type: varchar("type", { length: 255 }),
},
(table) => {
return {
digitalAssetPricesNameKey: unique("digital_asset_prices_name_key").on(table.name),
}
});

...

/**
* END remember to comment out before running db:push else it will DELETE ALL DATA IN THESE TABLES
* */


export const users = pgTable("users", {
id: serial("id").primaryKey().notNull(),
uuid: uuid("uuid").default(sql`uuid_generate_v4()`),
fullName: text("full_name"),
phone: varchar("phone", { length: 256 }),
email: varchar("email", { length: 256 }),
createdAt: timestamp("created_at", { mode: 'string' }).defaultNow().notNull(),
updatedAt: timestamp("updated_at", { mode: 'string' }),
});
7 replies