db:push not asking if I want to rename or create a new table.

I have been unable to delete my tables. New to Drizzle, TIA.
2 Replies
Andrii Sherman
Andrii Sherman8mo ago
could you please share your ts schema and changes to reproduce it would love to fix it
chocopie
chocopieOP8mo ago
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;
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.
Want results from more Discord servers?
Add your server