chocopie
chocopie
Explore posts from servers
DTDrizzle Team
Created by chocopie on 5/13/2024 in #help
db:push not asking if I want to rename or create a new table.
So when I run db:push with a different table name there will be a new table created. If I added a new field to the same table, then there will be no change to the table at all.
5 replies
DTDrizzle Team
Created by chocopie on 5/13/2024 in #help
db:push not asking if I want to rename or create a new table.
yea this is my schema:
// Example model schema from the Drizzle docs
// https://orm.drizzle.team/docs/sql-schema-declaration

import { sql } from "drizzle-orm";
import {
index,
pgTableCreator,
serial,
timestamp,
varchar,
} from "drizzle-orm/pg-core";
/**
* This is an example of how to use the multi-project schema feature of Drizzle ORM. Use the same
* database instance for multiple projects.
*
* @see https://orm.drizzle.team/docs/goodies#multi-project-schema
*/
export const createTable = pgTableCreator((name) => `project-postgres_${name}`);


export const images = createTable(
"image",
{
id: serial("id").primaryKey(),
name: varchar("name", { length: 256 }).notNull(),
userId: varchar("userId", { length: 256 }).notNull(),
url: varchar("url", { length: 1024 }).notNull(),
createdAt: timestamp("created_at", { withTimezone: true })
.default(sql`CURRENT_TIMESTAMP`)
.notNull(),
updatedAt: timestamp("updatedAt", { withTimezone: true }),
},
(example) => ({
nameIndex: index("name_idx").on(example.name),
})
);
// Example model schema from the Drizzle docs
// https://orm.drizzle.team/docs/sql-schema-declaration

import { sql } from "drizzle-orm";
import {
index,
pgTableCreator,
serial,
timestamp,
varchar,
} from "drizzle-orm/pg-core";
/**
* This is an example of how to use the multi-project schema feature of Drizzle ORM. Use the same
* database instance for multiple projects.
*
* @see https://orm.drizzle.team/docs/goodies#multi-project-schema
*/
export const createTable = pgTableCreator((name) => `project-postgres_${name}`);


export const images = createTable(
"image",
{
id: serial("id").primaryKey(),
name: varchar("name", { length: 256 }).notNull(),
userId: varchar("userId", { length: 256 }).notNull(),
url: varchar("url", { length: 1024 }).notNull(),
createdAt: timestamp("created_at", { withTimezone: true })
.default(sql`CURRENT_TIMESTAMP`)
.notNull(),
updatedAt: timestamp("updatedAt", { withTimezone: true }),
},
(example) => ({
nameIndex: index("name_idx").on(example.name),
})
);
This is my drizzle.config:
import { type Config } from "drizzle-kit";

import { env } from "~/env";

export default {
schema: "./src/server/db/schema.ts",
dialect: "postgresql",
dbCredentials: {
url: env.POSTGRES_URL,
},
tablesFilter: ["alissasmuzeum_*"],
} satisfies Config;
import { type Config } from "drizzle-kit";

import { env } from "~/env";

export default {
schema: "./src/server/db/schema.ts",
dialect: "postgresql",
dbCredentials: {
url: env.POSTGRES_URL,
},
tablesFilter: ["alissasmuzeum_*"],
} satisfies Config;
5 replies