changelogs/drizzle-orm-pg/0.15.1.md
Add support for schemas -> PostgreSQL schemas
Drizzle won't append any schema before table definition by default. So if your tables are in public schema drizzle generate -> select * from "users"
But if you will specify any custom schema you want, then drizzle will generate -> select * from "custom_schema"."users"
Warning If you will have tables with same names in different schemas then drizzle will respond with
never[]error in result types and error from databaseIn this case you may use alias syntax
Usage example
// Table in default schema
const publicUsersTable = pgTable('users', {
id: serial('id').primaryKey(),
name: text('name').notNull(),
verified: boolean('verified').notNull().default(false),
jsonb: jsonb<string[]>('jsonb'),
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
});
// Table in custom schema
const mySchema = pgSchema('mySchema');
const usersTable = mySchema('users', {
id: serial('id').primaryKey(),
name: text('name').notNull(),
verified: boolean('verified').notNull().default(false),
jsonb: jsonb<string[]>('jsonb'),
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
});