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