style(db): standardize database migration file formatting
This commit is contained in:
@@ -34,12 +34,8 @@
|
||||
"tableFrom": "session",
|
||||
"tableTo": "user",
|
||||
"schemaTo": "public",
|
||||
"columnsFrom": [
|
||||
"userId"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"columnsFrom": ["userId"],
|
||||
"columnsTo": ["id"],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
@@ -121,10 +117,7 @@
|
||||
"compositePrimaryKeys": {
|
||||
"verificationToken_identifier_token_pk": {
|
||||
"name": "verificationToken_identifier_token_pk",
|
||||
"columns": [
|
||||
"identifier",
|
||||
"token"
|
||||
]
|
||||
"columns": ["identifier", "token"]
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {},
|
||||
@@ -192,12 +185,8 @@
|
||||
"tableFrom": "authenticator",
|
||||
"tableTo": "user",
|
||||
"schemaTo": "public",
|
||||
"columnsFrom": [
|
||||
"userId"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"columnsFrom": ["userId"],
|
||||
"columnsTo": ["id"],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
@@ -205,17 +194,12 @@
|
||||
"compositePrimaryKeys": {
|
||||
"authenticator_userId_credentialID_pk": {
|
||||
"name": "authenticator_userId_credentialID_pk",
|
||||
"columns": [
|
||||
"credentialID",
|
||||
"userId"
|
||||
]
|
||||
"columns": ["credentialID", "userId"]
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {
|
||||
"authenticator_credentialID_unique": {
|
||||
"columns": [
|
||||
"credentialID"
|
||||
],
|
||||
"columns": ["credentialID"],
|
||||
"nullsNotDistinct": false,
|
||||
"name": "authenticator_credentialID_unique"
|
||||
}
|
||||
@@ -302,12 +286,8 @@
|
||||
"tableFrom": "account",
|
||||
"tableTo": "user",
|
||||
"schemaTo": "public",
|
||||
"columnsFrom": [
|
||||
"userId"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"columnsFrom": ["userId"],
|
||||
"columnsTo": ["id"],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
@@ -315,10 +295,7 @@
|
||||
"compositePrimaryKeys": {
|
||||
"account_provider_providerAccountId_pk": {
|
||||
"name": "account_provider_providerAccountId_pk",
|
||||
"columns": [
|
||||
"provider",
|
||||
"providerAccountId"
|
||||
]
|
||||
"columns": ["provider", "providerAccountId"]
|
||||
}
|
||||
},
|
||||
"uniqueConstraints": {},
|
||||
|
||||
@@ -95,12 +95,8 @@
|
||||
"name": "account_userId_user_id_fk",
|
||||
"tableFrom": "account",
|
||||
"tableTo": "user",
|
||||
"columnsFrom": [
|
||||
"userId"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"columnsFrom": ["userId"],
|
||||
"columnsTo": ["id"],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
@@ -172,12 +168,8 @@
|
||||
"name": "session_userId_user_id_fk",
|
||||
"tableFrom": "session",
|
||||
"tableTo": "user",
|
||||
"columnsFrom": [
|
||||
"userId"
|
||||
],
|
||||
"columnsTo": [
|
||||
"id"
|
||||
],
|
||||
"columnsFrom": ["userId"],
|
||||
"columnsTo": ["id"],
|
||||
"onDelete": "cascade",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
@@ -187,9 +179,7 @@
|
||||
"session_token_unique": {
|
||||
"name": "session_token_unique",
|
||||
"nullsNotDistinct": false,
|
||||
"columns": [
|
||||
"token"
|
||||
]
|
||||
"columns": ["token"]
|
||||
}
|
||||
},
|
||||
"policies": {},
|
||||
@@ -253,9 +243,7 @@
|
||||
"user_email_unique": {
|
||||
"name": "user_email_unique",
|
||||
"nullsNotDistinct": false,
|
||||
"columns": [
|
||||
"email"
|
||||
]
|
||||
"columns": ["email"]
|
||||
}
|
||||
},
|
||||
"policies": {},
|
||||
|
||||
@@ -4,7 +4,7 @@ import { user, session, account } from "./schema";
|
||||
export const sessionRelations = relations(session, ({ one }) => ({
|
||||
user: one(user, {
|
||||
fields: [session.userId],
|
||||
references: [user.id]
|
||||
references: [user.id],
|
||||
}),
|
||||
}));
|
||||
|
||||
@@ -16,6 +16,6 @@ export const userRelations = relations(user, ({many}) => ({
|
||||
export const accountRelations = relations(account, ({ one }) => ({
|
||||
user: one(user, {
|
||||
fields: [account.userId],
|
||||
references: [user.id]
|
||||
references: [user.id],
|
||||
}),
|
||||
}));
|
||||
@@ -1,37 +1,57 @@
|
||||
import { pgTable, foreignKey, text, timestamp, primaryKey, unique, integer, boolean } from "drizzle-orm/pg-core"
|
||||
import { sql } from "drizzle-orm"
|
||||
import {
|
||||
pgTable,
|
||||
foreignKey,
|
||||
text,
|
||||
timestamp,
|
||||
primaryKey,
|
||||
unique,
|
||||
integer,
|
||||
boolean,
|
||||
} from "drizzle-orm/pg-core";
|
||||
import { sql } from "drizzle-orm";
|
||||
|
||||
|
||||
|
||||
export const session = pgTable("session", {
|
||||
export const session = pgTable(
|
||||
"session",
|
||||
{
|
||||
sessionToken: text().primaryKey().notNull(),
|
||||
userId: text().notNull(),
|
||||
expires: timestamp({ mode: 'string' }).notNull(),
|
||||
}, (table) => [
|
||||
expires: timestamp({ mode: "string" }).notNull(),
|
||||
},
|
||||
(table) => [
|
||||
foreignKey({
|
||||
columns: [table.userId],
|
||||
foreignColumns: [user.id],
|
||||
name: "session_userId_user_id_fk"
|
||||
name: "session_userId_user_id_fk",
|
||||
}).onDelete("cascade"),
|
||||
]);
|
||||
],
|
||||
);
|
||||
|
||||
export const user = pgTable("user", {
|
||||
id: text().primaryKey().notNull(),
|
||||
name: text(),
|
||||
email: text().notNull(),
|
||||
emailVerified: timestamp({ mode: 'string' }),
|
||||
emailVerified: timestamp({ mode: "string" }),
|
||||
image: text(),
|
||||
});
|
||||
|
||||
export const verificationToken = pgTable("verificationToken", {
|
||||
export const verificationToken = pgTable(
|
||||
"verificationToken",
|
||||
{
|
||||
identifier: text().notNull(),
|
||||
token: text().notNull(),
|
||||
expires: timestamp({ mode: 'string' }).notNull(),
|
||||
}, (table) => [
|
||||
primaryKey({ columns: [table.identifier, table.token], name: "verificationToken_identifier_token_pk"}),
|
||||
]);
|
||||
expires: timestamp({ mode: "string" }).notNull(),
|
||||
},
|
||||
(table) => [
|
||||
primaryKey({
|
||||
columns: [table.identifier, table.token],
|
||||
name: "verificationToken_identifier_token_pk",
|
||||
}),
|
||||
],
|
||||
);
|
||||
|
||||
export const authenticator = pgTable("authenticator", {
|
||||
export const authenticator = pgTable(
|
||||
"authenticator",
|
||||
{
|
||||
credentialId: text().notNull(),
|
||||
userId: text().notNull(),
|
||||
providerAccountId: text().notNull(),
|
||||
@@ -40,17 +60,24 @@ export const authenticator = pgTable("authenticator", {
|
||||
credentialDeviceType: text().notNull(),
|
||||
credentialBackedUp: boolean().notNull(),
|
||||
transports: text(),
|
||||
}, (table) => [
|
||||
},
|
||||
(table) => [
|
||||
foreignKey({
|
||||
columns: [table.userId],
|
||||
foreignColumns: [user.id],
|
||||
name: "authenticator_userId_user_id_fk"
|
||||
name: "authenticator_userId_user_id_fk",
|
||||
}).onDelete("cascade"),
|
||||
primaryKey({ columns: [table.credentialId, table.userId], name: "authenticator_userId_credentialID_pk"}),
|
||||
primaryKey({
|
||||
columns: [table.credentialId, table.userId],
|
||||
name: "authenticator_userId_credentialID_pk",
|
||||
}),
|
||||
unique("authenticator_credentialID_unique").on(table.credentialId),
|
||||
]);
|
||||
],
|
||||
);
|
||||
|
||||
export const account = pgTable("account", {
|
||||
export const account = pgTable(
|
||||
"account",
|
||||
{
|
||||
userId: text().notNull(),
|
||||
type: text().notNull(),
|
||||
provider: text().notNull(),
|
||||
@@ -62,11 +89,16 @@ export const account = pgTable("account", {
|
||||
scope: text(),
|
||||
idToken: text("id_token"),
|
||||
sessionState: text("session_state"),
|
||||
}, (table) => [
|
||||
},
|
||||
(table) => [
|
||||
foreignKey({
|
||||
columns: [table.userId],
|
||||
foreignColumns: [user.id],
|
||||
name: "account_userId_user_id_fk"
|
||||
name: "account_userId_user_id_fk",
|
||||
}).onDelete("cascade"),
|
||||
primaryKey({ columns: [table.provider, table.providerAccountId], name: "account_provider_providerAccountId_pk"}),
|
||||
]);
|
||||
primaryKey({
|
||||
columns: [table.provider, table.providerAccountId],
|
||||
name: "account_provider_providerAccountId_pk",
|
||||
}),
|
||||
],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user