fix: writer/reader correctness and determinism issues
- merge: cloneTable keeps relationships; skip-tables applies to new schemas - diff: detect schema description/owner changes - prisma: reader no longer turns relation fields into columns, enum detection via declared names; writer type mapping is ordered - typeorm writer: keep explicit SQL types that cannot be inferred - drizzle: enum columns call the enum constant; reader resolves them - mysql/mssql/sqlite writers: honour OutputPath, deterministic column and constraint order; mssql live execute covers full schema - template: ToYAML recovers from panics; Merge nil-pointer loop - regenerate drizzle fixtures
This commit is contained in:
@@ -17,7 +17,7 @@ export const users = pgTable('users', {
|
||||
lastLoginAt: timestamp('last_login_at'),
|
||||
passwordHash: varchar('password_hash').notNull(),
|
||||
profile: jsonb('profile'),
|
||||
role: pgEnum('UserRole')('role').notNull(),
|
||||
role: userRole('role').notNull(),
|
||||
updatedAt: timestamp('updated_at').notNull().default(sql`now()`),
|
||||
username: varchar('username').notNull().unique(),
|
||||
});
|
||||
@@ -131,7 +131,7 @@ export const orders = pgTable('orders', {
|
||||
notes: text('notes'),
|
||||
orderNumber: varchar('order_number').notNull().unique(),
|
||||
shippingAddress: jsonb('shipping_address').notNull(),
|
||||
status: pgEnum('OrderStatus')('status').notNull().default('pending'),
|
||||
status: orderStatus('status').notNull().default('pending'),
|
||||
totalAmount: numeric('total_amount').notNull(),
|
||||
updatedAt: timestamp('updated_at').notNull().default(sql`now()`),
|
||||
userId: integer('user_id').notNull().references(() => users.id),
|
||||
|
||||
@@ -13,7 +13,6 @@ export interface User {
|
||||
id: number;
|
||||
email: string;
|
||||
name: string | null;
|
||||
profile: string | null;
|
||||
role: Role;
|
||||
}
|
||||
|
||||
@@ -21,8 +20,7 @@ export const user = pgTable('User', {
|
||||
id: integer('id').primaryKey().generatedAlwaysAsIdentity(),
|
||||
email: text('email').notNull().unique(),
|
||||
name: text('name'),
|
||||
profile: text('profile'),
|
||||
role: pgEnum('Role')('role').notNull().default('USER'),
|
||||
role: role('role').notNull().default('USER'),
|
||||
});
|
||||
|
||||
export type NewUser = typeof user.$inferInsert;
|
||||
@@ -30,14 +28,12 @@ export type NewUser = typeof user.$inferInsert;
|
||||
export interface Profile {
|
||||
id: number;
|
||||
bio: string;
|
||||
user: string;
|
||||
userId: number;
|
||||
}
|
||||
|
||||
export const profile = pgTable('Profile', {
|
||||
id: integer('id').primaryKey().generatedAlwaysAsIdentity(),
|
||||
bio: text('bio').notNull(),
|
||||
user: text('user').notNull(),
|
||||
userId: integer('userId').notNull().unique().references(() => user.id),
|
||||
});
|
||||
|
||||
@@ -45,7 +41,6 @@ export type NewProfile = typeof profile.$inferInsert;
|
||||
// Table: Post
|
||||
export interface Post {
|
||||
id: number;
|
||||
author: string;
|
||||
authorId: number;
|
||||
createdAt: Date;
|
||||
published: boolean;
|
||||
@@ -55,7 +50,6 @@ export interface Post {
|
||||
|
||||
export const post = pgTable('Post', {
|
||||
id: integer('id').primaryKey().generatedAlwaysAsIdentity(),
|
||||
author: text('author').notNull(),
|
||||
authorId: integer('authorId').notNull().references(() => user.id),
|
||||
createdAt: timestamp('createdAt').notNull().default(sql`now()`),
|
||||
published: boolean('published').notNull().default(false),
|
||||
|
||||
Reference in New Issue
Block a user