refactor: make casing for column names consistent (#1517)
* refactor: make casing for column names consistent * fix: format issues
This commit is contained in:
@@ -7,6 +7,7 @@ dotenv.config({ path: "../../.env" });
|
|||||||
export default {
|
export default {
|
||||||
dialect: "mysql",
|
dialect: "mysql",
|
||||||
schema: "./schema",
|
schema: "./schema",
|
||||||
|
casing: "snake_case",
|
||||||
dbCredentials: {
|
dbCredentials: {
|
||||||
host: process.env.DB_HOST!,
|
host: process.env.DB_HOST!,
|
||||||
user: process.env.DB_USER!,
|
user: process.env.DB_USER!,
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ dotenv.config({ path: "../../.env" });
|
|||||||
export default {
|
export default {
|
||||||
dialect: "sqlite",
|
dialect: "sqlite",
|
||||||
schema: "./schema",
|
schema: "./schema",
|
||||||
|
casing: "snake_case",
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
dbCredentials: { url: process.env.DB_URL! },
|
dbCredentials: { url: process.env.DB_URL! },
|
||||||
out: "./migrations/sqlite",
|
out: "./migrations/sqlite",
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ const initBetterSqlite = () => {
|
|||||||
database = drizzleSqlite(connection, {
|
database = drizzleSqlite(connection, {
|
||||||
schema: sqliteSchema,
|
schema: sqliteSchema,
|
||||||
logger: new WinstonDrizzleLogger(),
|
logger: new WinstonDrizzleLogger(),
|
||||||
|
casing: "snake_case",
|
||||||
}) as unknown as never;
|
}) as unknown as never;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -61,6 +62,7 @@ const initMySQL2 = () => {
|
|||||||
schema: mysqlSchema,
|
schema: mysqlSchema,
|
||||||
mode: "default",
|
mode: "default",
|
||||||
logger: new WinstonDrizzleLogger(),
|
logger: new WinstonDrizzleLogger(),
|
||||||
|
casing: "snake_case",
|
||||||
}) as unknown as HomarrDatabase;
|
}) as unknown as HomarrDatabase;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
ALTER TABLE `account` RENAME COLUMN `userId` TO `user_id`;--> statement-breakpoint
|
||||||
|
ALTER TABLE `account` RENAME COLUMN `providerAccountId` TO `provider_account_id`;--> statement-breakpoint
|
||||||
|
ALTER TABLE `apiKey` RENAME COLUMN `apiKey` TO `api_key`;--> statement-breakpoint
|
||||||
|
ALTER TABLE `apiKey` RENAME COLUMN `userId` TO `user_id`;--> statement-breakpoint
|
||||||
|
ALTER TABLE `groupMember` RENAME COLUMN `groupId` TO `group_id`;--> statement-breakpoint
|
||||||
|
ALTER TABLE `groupMember` RENAME COLUMN `userId` TO `user_id`;--> statement-breakpoint
|
||||||
|
ALTER TABLE `groupPermission` RENAME COLUMN `groupId` TO `group_id`;--> statement-breakpoint
|
||||||
|
ALTER TABLE `iconRepository` RENAME COLUMN `iconRepository_id` TO `id`;--> statement-breakpoint
|
||||||
|
ALTER TABLE `iconRepository` RENAME COLUMN `iconRepository_slug` TO `slug`;--> statement-breakpoint
|
||||||
|
ALTER TABLE `icon` RENAME COLUMN `icon_id` TO `id`;--> statement-breakpoint
|
||||||
|
ALTER TABLE `icon` RENAME COLUMN `icon_name` TO `name`;--> statement-breakpoint
|
||||||
|
ALTER TABLE `icon` RENAME COLUMN `icon_url` TO `url`;--> statement-breakpoint
|
||||||
|
ALTER TABLE `icon` RENAME COLUMN `icon_checksum` TO `checksum`;--> statement-breakpoint
|
||||||
|
ALTER TABLE `icon` RENAME COLUMN `iconRepository_id` TO `icon_repository_id`;--> statement-breakpoint
|
||||||
|
ALTER TABLE `serverSetting` RENAME COLUMN `key` TO `setting_key`;--> statement-breakpoint
|
||||||
|
ALTER TABLE `session` RENAME COLUMN `sessionToken` TO `session_token`;--> statement-breakpoint
|
||||||
|
ALTER TABLE `session` RENAME COLUMN `userId` TO `user_id`;--> statement-breakpoint
|
||||||
|
ALTER TABLE `user` RENAME COLUMN `emailVerified` TO `email_verified`;--> statement-breakpoint
|
||||||
|
ALTER TABLE `user` RENAME COLUMN `homeBoardId` TO `home_board_id`;--> statement-breakpoint
|
||||||
|
ALTER TABLE `user` RENAME COLUMN `colorScheme` TO `color_scheme`;--> statement-breakpoint
|
||||||
|
ALTER TABLE `user` RENAME COLUMN `firstDayOfWeek` TO `first_day_of_week`;--> statement-breakpoint
|
||||||
|
ALTER TABLE `user` RENAME COLUMN `pingIconsEnabled` TO `ping_icons_enabled`;--> statement-breakpoint
|
||||||
|
ALTER TABLE `serverSetting` DROP INDEX `serverSetting_key_unique`;--> statement-breakpoint
|
||||||
|
ALTER TABLE `account` DROP FOREIGN KEY `account_userId_user_id_fk`;
|
||||||
|
--> statement-breakpoint
|
||||||
|
ALTER TABLE `apiKey` DROP FOREIGN KEY `apiKey_userId_user_id_fk`;
|
||||||
|
--> statement-breakpoint
|
||||||
|
ALTER TABLE `groupMember` DROP FOREIGN KEY `groupMember_groupId_group_id_fk`;
|
||||||
|
--> statement-breakpoint
|
||||||
|
ALTER TABLE `groupMember` DROP FOREIGN KEY `groupMember_userId_user_id_fk`;
|
||||||
|
--> statement-breakpoint
|
||||||
|
ALTER TABLE `groupPermission` DROP FOREIGN KEY `groupPermission_groupId_group_id_fk`;
|
||||||
|
--> statement-breakpoint
|
||||||
|
ALTER TABLE `icon` DROP FOREIGN KEY `icon_iconRepository_id_iconRepository_iconRepository_id_fk`;
|
||||||
|
--> statement-breakpoint
|
||||||
|
ALTER TABLE `session` DROP FOREIGN KEY `session_userId_user_id_fk`;
|
||||||
|
--> statement-breakpoint
|
||||||
|
ALTER TABLE `user` DROP FOREIGN KEY `user_homeBoardId_board_id_fk`;
|
||||||
|
--> statement-breakpoint
|
||||||
|
DROP INDEX `userId_idx` ON `account`;--> statement-breakpoint
|
||||||
|
DROP INDEX `user_id_idx` ON `session`;--> statement-breakpoint
|
||||||
|
ALTER TABLE `account` DROP PRIMARY KEY;--> statement-breakpoint
|
||||||
|
ALTER TABLE `groupMember` DROP PRIMARY KEY;--> statement-breakpoint
|
||||||
|
ALTER TABLE `iconRepository` DROP PRIMARY KEY;--> statement-breakpoint
|
||||||
|
ALTER TABLE `icon` DROP PRIMARY KEY;--> statement-breakpoint
|
||||||
|
ALTER TABLE `serverSetting` DROP PRIMARY KEY;--> statement-breakpoint
|
||||||
|
ALTER TABLE `session` DROP PRIMARY KEY;--> statement-breakpoint
|
||||||
|
ALTER TABLE `account` ADD PRIMARY KEY(`provider`,`provider_account_id`);--> statement-breakpoint
|
||||||
|
ALTER TABLE `groupMember` ADD PRIMARY KEY(`group_id`,`user_id`);--> statement-breakpoint
|
||||||
|
ALTER TABLE `iconRepository` ADD PRIMARY KEY(`id`);--> statement-breakpoint
|
||||||
|
ALTER TABLE `icon` ADD PRIMARY KEY(`id`);--> statement-breakpoint
|
||||||
|
ALTER TABLE `serverSetting` ADD PRIMARY KEY(`setting_key`);--> statement-breakpoint
|
||||||
|
ALTER TABLE `session` ADD PRIMARY KEY(`session_token`);--> statement-breakpoint
|
||||||
|
ALTER TABLE `serverSetting` ADD CONSTRAINT `serverSetting_settingKey_unique` UNIQUE(`setting_key`);--> statement-breakpoint
|
||||||
|
ALTER TABLE `account` ADD CONSTRAINT `account_user_id_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||||
|
ALTER TABLE `apiKey` ADD CONSTRAINT `apiKey_user_id_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||||
|
ALTER TABLE `groupMember` ADD CONSTRAINT `groupMember_group_id_group_id_fk` FOREIGN KEY (`group_id`) REFERENCES `group`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||||
|
ALTER TABLE `groupMember` ADD CONSTRAINT `groupMember_user_id_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||||
|
ALTER TABLE `groupPermission` ADD CONSTRAINT `groupPermission_group_id_group_id_fk` FOREIGN KEY (`group_id`) REFERENCES `group`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||||
|
ALTER TABLE `icon` ADD CONSTRAINT `icon_icon_repository_id_iconRepository_id_fk` FOREIGN KEY (`icon_repository_id`) REFERENCES `iconRepository`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||||
|
ALTER TABLE `session` ADD CONSTRAINT `session_user_id_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||||
|
ALTER TABLE `user` ADD CONSTRAINT `user_home_board_id_board_id_fk` FOREIGN KEY (`home_board_id`) REFERENCES `board`(`id`) ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
||||||
|
CREATE INDEX `userId_idx` ON `account` (`user_id`);--> statement-breakpoint
|
||||||
|
CREATE INDEX `user_id_idx` ON `session` (`user_id`);
|
||||||
1650
packages/db/migrations/mysql/meta/0016_snapshot.json
Normal file
1650
packages/db/migrations/mysql/meta/0016_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -113,6 +113,13 @@
|
|||||||
"when": 1730653393442,
|
"when": 1730653393442,
|
||||||
"tag": "0015_unknown_firedrake",
|
"tag": "0015_unknown_firedrake",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 16,
|
||||||
|
"version": "5",
|
||||||
|
"when": 1732212709518,
|
||||||
|
"tag": "0016_change_all_to_snake_case",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ const migrateAsync = async () => {
|
|||||||
const db = drizzle(mysql2, {
|
const db = drizzle(mysql2, {
|
||||||
mode: "default",
|
mode: "default",
|
||||||
schema: mysqlSchema,
|
schema: mysqlSchema,
|
||||||
|
casing: "snake_case",
|
||||||
});
|
});
|
||||||
|
|
||||||
await migrate(db, { migrationsFolder });
|
await migrate(db, { migrationsFolder });
|
||||||
|
|||||||
102
packages/db/migrations/sqlite/0016_change_all_to_snake_case.sql
Normal file
102
packages/db/migrations/sqlite/0016_change_all_to_snake_case.sql
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
ALTER TABLE `iconRepository` RENAME COLUMN "iconRepository_id" TO "id";--> statement-breakpoint
|
||||||
|
ALTER TABLE `iconRepository` RENAME COLUMN "iconRepository_slug" TO "slug";--> statement-breakpoint
|
||||||
|
ALTER TABLE `serverSetting` RENAME COLUMN "key" TO "setting_key";--> statement-breakpoint
|
||||||
|
PRAGMA foreign_keys=OFF;--> statement-breakpoint
|
||||||
|
CREATE TABLE `__new_account` (
|
||||||
|
`user_id` text NOT NULL,
|
||||||
|
`type` text NOT NULL,
|
||||||
|
`provider` text NOT NULL,
|
||||||
|
`provider_account_id` text NOT NULL,
|
||||||
|
`refresh_token` text,
|
||||||
|
`access_token` text,
|
||||||
|
`expires_at` integer,
|
||||||
|
`token_type` text,
|
||||||
|
`scope` text,
|
||||||
|
`id_token` text,
|
||||||
|
`session_state` text,
|
||||||
|
PRIMARY KEY(`provider`, `provider_account_id`),
|
||||||
|
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
INSERT INTO `__new_account`("user_id", "type", "provider", "provider_account_id", "refresh_token", "access_token", "expires_at", "token_type", "scope", "id_token", "session_state") SELECT "userId", "type", "provider", "providerAccountId", "refresh_token", "access_token", "expires_at", "token_type", "scope", "id_token", "session_state" FROM `account`;--> statement-breakpoint
|
||||||
|
DROP TABLE `account`;--> statement-breakpoint
|
||||||
|
ALTER TABLE `__new_account` RENAME TO `account`;--> statement-breakpoint
|
||||||
|
PRAGMA foreign_keys=ON;--> statement-breakpoint
|
||||||
|
CREATE INDEX `userId_idx` ON `account` (`user_id`);--> statement-breakpoint
|
||||||
|
PRAGMA foreign_keys=OFF;--> statement-breakpoint
|
||||||
|
CREATE TABLE `__new_apiKey` (
|
||||||
|
`id` text PRIMARY KEY NOT NULL,
|
||||||
|
`api_key` text NOT NULL,
|
||||||
|
`salt` text NOT NULL,
|
||||||
|
`user_id` text NOT NULL,
|
||||||
|
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
INSERT INTO `__new_apiKey`("id", "api_key", "salt", "user_id") SELECT "id", "apiKey", "salt", "userId" FROM `apiKey`;--> statement-breakpoint
|
||||||
|
DROP TABLE `apiKey`;--> statement-breakpoint
|
||||||
|
ALTER TABLE `__new_apiKey` RENAME TO `apiKey`;--> statement-breakpoint
|
||||||
|
CREATE TABLE `__new_groupMember` (
|
||||||
|
`group_id` text NOT NULL,
|
||||||
|
`user_id` text NOT NULL,
|
||||||
|
PRIMARY KEY(`group_id`, `user_id`),
|
||||||
|
FOREIGN KEY (`group_id`) REFERENCES `group`(`id`) ON UPDATE no action ON DELETE cascade,
|
||||||
|
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
INSERT INTO `__new_groupMember`("group_id", "user_id") SELECT "groupId", "userId" FROM `groupMember`;--> statement-breakpoint
|
||||||
|
DROP TABLE `groupMember`;--> statement-breakpoint
|
||||||
|
ALTER TABLE `__new_groupMember` RENAME TO `groupMember`;--> statement-breakpoint
|
||||||
|
CREATE TABLE `__new_groupPermission` (
|
||||||
|
`group_id` text NOT NULL,
|
||||||
|
`permission` text NOT NULL,
|
||||||
|
FOREIGN KEY (`group_id`) REFERENCES `group`(`id`) ON UPDATE no action ON DELETE cascade
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
INSERT INTO `__new_groupPermission`("group_id", "permission") SELECT "groupId", "permission" FROM `groupPermission`;--> statement-breakpoint
|
||||||
|
DROP TABLE `groupPermission`;--> statement-breakpoint
|
||||||
|
ALTER TABLE `__new_groupPermission` RENAME TO `groupPermission`;--> statement-breakpoint
|
||||||
|
CREATE TABLE `__new_icon` (
|
||||||
|
`id` text PRIMARY KEY NOT NULL,
|
||||||
|
`name` text NOT NULL,
|
||||||
|
`url` text NOT NULL,
|
||||||
|
`checksum` text NOT NULL,
|
||||||
|
`icon_repository_id` text NOT NULL,
|
||||||
|
FOREIGN KEY (`icon_repository_id`) REFERENCES `iconRepository`(`id`) ON UPDATE no action ON DELETE cascade
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
INSERT INTO `__new_icon`("id", "name", "url", "checksum", "icon_repository_id") SELECT "icon_id", "icon_name", "icon_url", "icon_checksum", "iconRepository_id" FROM `icon`;--> statement-breakpoint
|
||||||
|
DROP TABLE `icon`;--> statement-breakpoint
|
||||||
|
ALTER TABLE `__new_icon` RENAME TO `icon`;--> statement-breakpoint
|
||||||
|
DROP INDEX IF EXISTS `serverSetting_key_unique`;--> statement-breakpoint
|
||||||
|
CREATE UNIQUE INDEX `serverSetting_settingKey_unique` ON `serverSetting` (`setting_key`);--> statement-breakpoint
|
||||||
|
CREATE TABLE `__new_session` (
|
||||||
|
`session_token` text PRIMARY KEY NOT NULL,
|
||||||
|
`user_id` text NOT NULL,
|
||||||
|
`expires` integer NOT NULL,
|
||||||
|
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
INSERT INTO `__new_session`("session_token", "user_id", "expires") SELECT "sessionToken", "userId", "expires" FROM `session`;--> statement-breakpoint
|
||||||
|
DROP TABLE `session`;--> statement-breakpoint
|
||||||
|
ALTER TABLE `__new_session` RENAME TO `session`;--> statement-breakpoint
|
||||||
|
CREATE INDEX `user_id_idx` ON `session` (`user_id`);--> statement-breakpoint
|
||||||
|
CREATE TABLE `__new_user` (
|
||||||
|
`id` text PRIMARY KEY NOT NULL,
|
||||||
|
`name` text,
|
||||||
|
`email` text,
|
||||||
|
`email_verified` integer,
|
||||||
|
`image` text,
|
||||||
|
`password` text,
|
||||||
|
`salt` text,
|
||||||
|
`provider` text DEFAULT 'credentials' NOT NULL,
|
||||||
|
`home_board_id` text,
|
||||||
|
`color_scheme` text DEFAULT 'dark' NOT NULL,
|
||||||
|
`first_day_of_week` integer DEFAULT 1 NOT NULL,
|
||||||
|
`ping_icons_enabled` integer DEFAULT false NOT NULL,
|
||||||
|
FOREIGN KEY (`home_board_id`) REFERENCES `board`(`id`) ON UPDATE no action ON DELETE set null
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
INSERT INTO `__new_user`("id", "name", "email", "email_verified", "image", "password", "salt", "provider", "home_board_id", "color_scheme", "first_day_of_week", "ping_icons_enabled") SELECT "id", "name", "email", "emailVerified", "image", "password", "salt", "provider", "homeBoardId", "colorScheme", "firstDayOfWeek", "pingIconsEnabled" FROM `user`;--> statement-breakpoint
|
||||||
|
DROP TABLE `user`;--> statement-breakpoint
|
||||||
|
ALTER TABLE `__new_user` RENAME TO `user`;--> statement-breakpoint
|
||||||
|
PRAGMA foreign_keys=ON;
|
||||||
1579
packages/db/migrations/sqlite/meta/0016_snapshot.json
Normal file
1579
packages/db/migrations/sqlite/meta/0016_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -113,6 +113,13 @@
|
|||||||
"when": 1730653336134,
|
"when": 1730653336134,
|
||||||
"tag": "0015_superb_psylocke",
|
"tag": "0015_superb_psylocke",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 16,
|
||||||
|
"version": "6",
|
||||||
|
"when": 1732210918783,
|
||||||
|
"tag": "0016_change_all_to_snake_case",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ const migrationsFolder = process.argv[2] ?? ".";
|
|||||||
const migrateAsync = async () => {
|
const migrateAsync = async () => {
|
||||||
const sqlite = new Database(process.env.DB_URL?.replace("file:", ""));
|
const sqlite = new Database(process.env.DB_URL?.replace("file:", ""));
|
||||||
|
|
||||||
const db = drizzle(sqlite, { schema });
|
const db = drizzle(sqlite, { schema, casing: "snake_case" });
|
||||||
|
|
||||||
migrate(db, { migrationsFolder });
|
migrate(db, { migrationsFolder });
|
||||||
|
|
||||||
|
|||||||
@@ -39,10 +39,10 @@ const customBlob = customType<{ data: Buffer }>({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const apiKeys = mysqlTable("apiKey", {
|
export const apiKeys = mysqlTable("apiKey", {
|
||||||
id: varchar("id", { length: 64 }).notNull().primaryKey(),
|
id: varchar({ length: 64 }).notNull().primaryKey(),
|
||||||
apiKey: text("apiKey").notNull(),
|
apiKey: text().notNull(),
|
||||||
salt: text("salt").notNull(),
|
salt: text().notNull(),
|
||||||
userId: varchar("userId", { length: 64 })
|
userId: varchar({ length: 64 })
|
||||||
.notNull()
|
.notNull()
|
||||||
.references((): AnyMySqlColumn => users.id, {
|
.references((): AnyMySqlColumn => users.id, {
|
||||||
onDelete: "cascade",
|
onDelete: "cascade",
|
||||||
@@ -50,38 +50,38 @@ export const apiKeys = mysqlTable("apiKey", {
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const users = mysqlTable("user", {
|
export const users = mysqlTable("user", {
|
||||||
id: varchar("id", { length: 64 }).notNull().primaryKey(),
|
id: varchar({ length: 64 }).notNull().primaryKey(),
|
||||||
name: text("name"),
|
name: text(),
|
||||||
email: text("email"),
|
email: text(),
|
||||||
emailVerified: timestamp("emailVerified"),
|
emailVerified: timestamp(),
|
||||||
image: text("image"),
|
image: text(),
|
||||||
password: text("password"),
|
password: text(),
|
||||||
salt: text("salt"),
|
salt: text(),
|
||||||
provider: varchar("provider", { length: 64 }).$type<SupportedAuthProvider>().default("credentials").notNull(),
|
provider: varchar({ length: 64 }).$type<SupportedAuthProvider>().default("credentials").notNull(),
|
||||||
homeBoardId: varchar("homeBoardId", { length: 64 }).references((): AnyMySqlColumn => boards.id, {
|
homeBoardId: varchar({ length: 64 }).references((): AnyMySqlColumn => boards.id, {
|
||||||
onDelete: "set null",
|
onDelete: "set null",
|
||||||
}),
|
}),
|
||||||
colorScheme: varchar("colorScheme", { length: 5 }).$type<ColorScheme>().default("dark").notNull(),
|
colorScheme: varchar({ length: 5 }).$type<ColorScheme>().default("dark").notNull(),
|
||||||
firstDayOfWeek: tinyint("firstDayOfWeek").$type<DayOfWeek>().default(1).notNull(), // Defaults to Monday
|
firstDayOfWeek: tinyint().$type<DayOfWeek>().default(1).notNull(), // Defaults to Monday
|
||||||
pingIconsEnabled: boolean("pingIconsEnabled").default(false).notNull(),
|
pingIconsEnabled: boolean().default(false).notNull(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const accounts = mysqlTable(
|
export const accounts = mysqlTable(
|
||||||
"account",
|
"account",
|
||||||
{
|
{
|
||||||
userId: varchar("userId", { length: 64 })
|
userId: varchar({ length: 64 })
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => users.id, { onDelete: "cascade" }),
|
.references(() => users.id, { onDelete: "cascade" }),
|
||||||
type: text("type").$type<AdapterAccount["type"]>().notNull(),
|
type: text().$type<AdapterAccount["type"]>().notNull(),
|
||||||
provider: varchar("provider", { length: 64 }).notNull(),
|
provider: varchar({ length: 64 }).notNull(),
|
||||||
providerAccountId: varchar("providerAccountId", { length: 64 }).notNull(),
|
providerAccountId: varchar({ length: 64 }).notNull(),
|
||||||
refresh_token: text("refresh_token"),
|
refresh_token: text(),
|
||||||
access_token: text("access_token"),
|
access_token: text(),
|
||||||
expires_at: int("expires_at"),
|
expires_at: int(),
|
||||||
token_type: text("token_type"),
|
token_type: text(),
|
||||||
scope: text("scope"),
|
scope: text(),
|
||||||
id_token: text("id_token"),
|
id_token: text(),
|
||||||
session_state: text("session_state"),
|
session_state: text(),
|
||||||
},
|
},
|
||||||
(account) => ({
|
(account) => ({
|
||||||
compoundKey: primaryKey({
|
compoundKey: primaryKey({
|
||||||
@@ -94,11 +94,11 @@ export const accounts = mysqlTable(
|
|||||||
export const sessions = mysqlTable(
|
export const sessions = mysqlTable(
|
||||||
"session",
|
"session",
|
||||||
{
|
{
|
||||||
sessionToken: varchar("sessionToken", { length: 512 }).notNull().primaryKey(),
|
sessionToken: varchar({ length: 512 }).notNull().primaryKey(),
|
||||||
userId: varchar("userId", { length: 64 })
|
userId: varchar({ length: 64 })
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => users.id, { onDelete: "cascade" }),
|
.references(() => users.id, { onDelete: "cascade" }),
|
||||||
expires: timestamp("expires").notNull(),
|
expires: timestamp().notNull(),
|
||||||
},
|
},
|
||||||
(session) => ({
|
(session) => ({
|
||||||
userIdIdx: index("user_id_idx").on(session.userId),
|
userIdIdx: index("user_id_idx").on(session.userId),
|
||||||
@@ -108,9 +108,9 @@ export const sessions = mysqlTable(
|
|||||||
export const verificationTokens = mysqlTable(
|
export const verificationTokens = mysqlTable(
|
||||||
"verificationToken",
|
"verificationToken",
|
||||||
{
|
{
|
||||||
identifier: varchar("identifier", { length: 64 }).notNull(),
|
identifier: varchar({ length: 64 }).notNull(),
|
||||||
token: varchar("token", { length: 512 }).notNull(),
|
token: varchar({ length: 512 }).notNull(),
|
||||||
expires: timestamp("expires").notNull(),
|
expires: timestamp().notNull(),
|
||||||
},
|
},
|
||||||
(verificationToken) => ({
|
(verificationToken) => ({
|
||||||
compoundKey: primaryKey({
|
compoundKey: primaryKey({
|
||||||
@@ -122,10 +122,10 @@ export const verificationTokens = mysqlTable(
|
|||||||
export const groupMembers = mysqlTable(
|
export const groupMembers = mysqlTable(
|
||||||
"groupMember",
|
"groupMember",
|
||||||
{
|
{
|
||||||
groupId: varchar("groupId", { length: 64 })
|
groupId: varchar({ length: 64 })
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => groups.id, { onDelete: "cascade" }),
|
.references(() => groups.id, { onDelete: "cascade" }),
|
||||||
userId: varchar("userId", { length: 64 })
|
userId: varchar({ length: 64 })
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => users.id, { onDelete: "cascade" }),
|
.references(() => users.id, { onDelete: "cascade" }),
|
||||||
},
|
},
|
||||||
@@ -137,46 +137,46 @@ export const groupMembers = mysqlTable(
|
|||||||
);
|
);
|
||||||
|
|
||||||
export const groups = mysqlTable("group", {
|
export const groups = mysqlTable("group", {
|
||||||
id: varchar("id", { length: 64 }).notNull().primaryKey(),
|
id: varchar({ length: 64 }).notNull().primaryKey(),
|
||||||
name: varchar("name", { length: 64 }).unique().notNull(),
|
name: varchar({ length: 64 }).unique().notNull(),
|
||||||
ownerId: varchar("owner_id", { length: 64 }).references(() => users.id, {
|
ownerId: varchar({ length: 64 }).references(() => users.id, {
|
||||||
onDelete: "set null",
|
onDelete: "set null",
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const groupPermissions = mysqlTable("groupPermission", {
|
export const groupPermissions = mysqlTable("groupPermission", {
|
||||||
groupId: varchar("groupId", { length: 64 })
|
groupId: varchar({ length: 64 })
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => groups.id, { onDelete: "cascade" }),
|
.references(() => groups.id, { onDelete: "cascade" }),
|
||||||
permission: text("permission").$type<GroupPermissionKey>().notNull(),
|
permission: text().$type<GroupPermissionKey>().notNull(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const invites = mysqlTable("invite", {
|
export const invites = mysqlTable("invite", {
|
||||||
id: varchar("id", { length: 64 }).notNull().primaryKey(),
|
id: varchar({ length: 64 }).notNull().primaryKey(),
|
||||||
token: varchar("token", { length: 512 }).notNull().unique(),
|
token: varchar({ length: 512 }).notNull().unique(),
|
||||||
expirationDate: timestamp("expiration_date").notNull(),
|
expirationDate: timestamp().notNull(),
|
||||||
creatorId: varchar("creator_id", { length: 64 })
|
creatorId: varchar({ length: 64 })
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => users.id, { onDelete: "cascade" }),
|
.references(() => users.id, { onDelete: "cascade" }),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const medias = mysqlTable("media", {
|
export const medias = mysqlTable("media", {
|
||||||
id: varchar("id", { length: 64 }).notNull().primaryKey(),
|
id: varchar({ length: 64 }).notNull().primaryKey(),
|
||||||
name: varchar("name", { length: 512 }).notNull(),
|
name: varchar({ length: 512 }).notNull(),
|
||||||
content: customBlob("content").notNull(),
|
content: customBlob().notNull(),
|
||||||
contentType: text("content_type").notNull(),
|
contentType: text().notNull(),
|
||||||
size: int("size").notNull(),
|
size: int().notNull(),
|
||||||
createdAt: timestamp("created_at", { mode: "date" }).notNull().defaultNow(),
|
createdAt: timestamp({ mode: "date" }).notNull().defaultNow(),
|
||||||
creatorId: varchar("creator_id", { length: 64 }).references(() => users.id, { onDelete: "set null" }),
|
creatorId: varchar({ length: 64 }).references(() => users.id, { onDelete: "set null" }),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const integrations = mysqlTable(
|
export const integrations = mysqlTable(
|
||||||
"integration",
|
"integration",
|
||||||
{
|
{
|
||||||
id: varchar("id", { length: 64 }).notNull().primaryKey(),
|
id: varchar({ length: 64 }).notNull().primaryKey(),
|
||||||
name: text("name").notNull(),
|
name: text().notNull(),
|
||||||
url: text("url").notNull(),
|
url: text().notNull(),
|
||||||
kind: varchar("kind", { length: 128 }).$type<IntegrationKind>().notNull(),
|
kind: varchar({ length: 128 }).$type<IntegrationKind>().notNull(),
|
||||||
},
|
},
|
||||||
(integrations) => ({
|
(integrations) => ({
|
||||||
kindIdx: index("integration__kind_idx").on(integrations.kind),
|
kindIdx: index("integration__kind_idx").on(integrations.kind),
|
||||||
@@ -186,12 +186,12 @@ export const integrations = mysqlTable(
|
|||||||
export const integrationSecrets = mysqlTable(
|
export const integrationSecrets = mysqlTable(
|
||||||
"integrationSecret",
|
"integrationSecret",
|
||||||
{
|
{
|
||||||
kind: varchar("kind", { length: 16 }).$type<IntegrationSecretKind>().notNull(),
|
kind: varchar({ length: 16 }).$type<IntegrationSecretKind>().notNull(),
|
||||||
value: text("value").$type<`${string}.${string}`>().notNull(),
|
value: text().$type<`${string}.${string}`>().notNull(),
|
||||||
updatedAt: timestamp("updated_at")
|
updatedAt: timestamp()
|
||||||
.$onUpdateFn(() => new Date())
|
.$onUpdateFn(() => new Date())
|
||||||
.notNull(),
|
.notNull(),
|
||||||
integrationId: varchar("integration_id", { length: 64 })
|
integrationId: varchar({ length: 64 })
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => integrations.id, { onDelete: "cascade" }),
|
.references(() => integrations.id, { onDelete: "cascade" }),
|
||||||
},
|
},
|
||||||
@@ -207,13 +207,13 @@ export const integrationSecrets = mysqlTable(
|
|||||||
export const integrationUserPermissions = mysqlTable(
|
export const integrationUserPermissions = mysqlTable(
|
||||||
"integrationUserPermission",
|
"integrationUserPermission",
|
||||||
{
|
{
|
||||||
integrationId: varchar("integration_id", { length: 64 })
|
integrationId: varchar({ length: 64 })
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => integrations.id, { onDelete: "cascade" }),
|
.references(() => integrations.id, { onDelete: "cascade" }),
|
||||||
userId: varchar("user_id", { length: 64 })
|
userId: varchar({ length: 64 })
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => users.id, { onDelete: "cascade" }),
|
.references(() => users.id, { onDelete: "cascade" }),
|
||||||
permission: varchar("permission", { length: 128 }).$type<IntegrationPermission>().notNull(),
|
permission: varchar({ length: 128 }).$type<IntegrationPermission>().notNull(),
|
||||||
},
|
},
|
||||||
(table) => ({
|
(table) => ({
|
||||||
compoundKey: primaryKey({
|
compoundKey: primaryKey({
|
||||||
@@ -225,13 +225,13 @@ export const integrationUserPermissions = mysqlTable(
|
|||||||
export const integrationGroupPermissions = mysqlTable(
|
export const integrationGroupPermissions = mysqlTable(
|
||||||
"integrationGroupPermissions",
|
"integrationGroupPermissions",
|
||||||
{
|
{
|
||||||
integrationId: varchar("integration_id", { length: 64 })
|
integrationId: varchar({ length: 64 })
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => integrations.id, { onDelete: "cascade" }),
|
.references(() => integrations.id, { onDelete: "cascade" }),
|
||||||
groupId: varchar("group_id", { length: 64 })
|
groupId: varchar({ length: 64 })
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => groups.id, { onDelete: "cascade" }),
|
.references(() => groups.id, { onDelete: "cascade" }),
|
||||||
permission: varchar("permission", { length: 128 }).$type<IntegrationPermission>().notNull(),
|
permission: varchar({ length: 128 }).$type<IntegrationPermission>().notNull(),
|
||||||
},
|
},
|
||||||
(table) => ({
|
(table) => ({
|
||||||
compoundKey: primaryKey({
|
compoundKey: primaryKey({
|
||||||
@@ -242,46 +242,40 @@ export const integrationGroupPermissions = mysqlTable(
|
|||||||
);
|
);
|
||||||
|
|
||||||
export const boards = mysqlTable("board", {
|
export const boards = mysqlTable("board", {
|
||||||
id: varchar("id", { length: 64 }).notNull().primaryKey(),
|
id: varchar({ length: 64 }).notNull().primaryKey(),
|
||||||
name: varchar("name", { length: 256 }).unique().notNull(),
|
name: varchar({ length: 256 }).unique().notNull(),
|
||||||
isPublic: boolean("is_public").default(false).notNull(),
|
isPublic: boolean().default(false).notNull(),
|
||||||
creatorId: varchar("creator_id", { length: 64 }).references(() => users.id, {
|
creatorId: varchar({ length: 64 }).references(() => users.id, {
|
||||||
onDelete: "set null",
|
onDelete: "set null",
|
||||||
}),
|
}),
|
||||||
pageTitle: text("page_title"),
|
pageTitle: text(),
|
||||||
metaTitle: text("meta_title"),
|
metaTitle: text(),
|
||||||
logoImageUrl: text("logo_image_url"),
|
logoImageUrl: text(),
|
||||||
faviconImageUrl: text("favicon_image_url"),
|
faviconImageUrl: text(),
|
||||||
backgroundImageUrl: text("background_image_url"),
|
backgroundImageUrl: text(),
|
||||||
backgroundImageAttachment: text("background_image_attachment")
|
backgroundImageAttachment: text()
|
||||||
.$type<BackgroundImageAttachment>()
|
.$type<BackgroundImageAttachment>()
|
||||||
.default(backgroundImageAttachments.defaultValue)
|
.default(backgroundImageAttachments.defaultValue)
|
||||||
.notNull(),
|
.notNull(),
|
||||||
backgroundImageRepeat: text("background_image_repeat")
|
backgroundImageRepeat: text().$type<BackgroundImageRepeat>().default(backgroundImageRepeats.defaultValue).notNull(),
|
||||||
.$type<BackgroundImageRepeat>()
|
backgroundImageSize: text().$type<BackgroundImageSize>().default(backgroundImageSizes.defaultValue).notNull(),
|
||||||
.default(backgroundImageRepeats.defaultValue)
|
primaryColor: text().default("#fa5252").notNull(),
|
||||||
.notNull(),
|
secondaryColor: text().default("#fd7e14").notNull(),
|
||||||
backgroundImageSize: text("background_image_size")
|
opacity: int().default(100).notNull(),
|
||||||
.$type<BackgroundImageSize>()
|
customCss: text(),
|
||||||
.default(backgroundImageSizes.defaultValue)
|
columnCount: int().default(10).notNull(),
|
||||||
.notNull(),
|
|
||||||
primaryColor: text("primary_color").default("#fa5252").notNull(),
|
|
||||||
secondaryColor: text("secondary_color").default("#fd7e14").notNull(),
|
|
||||||
opacity: int("opacity").default(100).notNull(),
|
|
||||||
customCss: text("custom_css"),
|
|
||||||
columnCount: int("column_count").default(10).notNull(),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const boardUserPermissions = mysqlTable(
|
export const boardUserPermissions = mysqlTable(
|
||||||
"boardUserPermission",
|
"boardUserPermission",
|
||||||
{
|
{
|
||||||
boardId: varchar("board_id", { length: 64 })
|
boardId: varchar({ length: 64 })
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => boards.id, { onDelete: "cascade" }),
|
.references(() => boards.id, { onDelete: "cascade" }),
|
||||||
userId: varchar("user_id", { length: 64 })
|
userId: varchar({ length: 64 })
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => users.id, { onDelete: "cascade" }),
|
.references(() => users.id, { onDelete: "cascade" }),
|
||||||
permission: varchar("permission", { length: 128 }).$type<BoardPermission>().notNull(),
|
permission: varchar({ length: 128 }).$type<BoardPermission>().notNull(),
|
||||||
},
|
},
|
||||||
(table) => ({
|
(table) => ({
|
||||||
compoundKey: primaryKey({
|
compoundKey: primaryKey({
|
||||||
@@ -293,13 +287,13 @@ export const boardUserPermissions = mysqlTable(
|
|||||||
export const boardGroupPermissions = mysqlTable(
|
export const boardGroupPermissions = mysqlTable(
|
||||||
"boardGroupPermission",
|
"boardGroupPermission",
|
||||||
{
|
{
|
||||||
boardId: varchar("board_id", { length: 64 })
|
boardId: varchar({ length: 64 })
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => boards.id, { onDelete: "cascade" }),
|
.references(() => boards.id, { onDelete: "cascade" }),
|
||||||
groupId: varchar("group_id", { length: 64 })
|
groupId: varchar({ length: 64 })
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => groups.id, { onDelete: "cascade" }),
|
.references(() => groups.id, { onDelete: "cascade" }),
|
||||||
permission: varchar("permission", { length: 128 }).$type<BoardPermission>().notNull(),
|
permission: varchar({ length: 128 }).$type<BoardPermission>().notNull(),
|
||||||
},
|
},
|
||||||
(table) => ({
|
(table) => ({
|
||||||
compoundKey: primaryKey({
|
compoundKey: primaryKey({
|
||||||
@@ -309,50 +303,50 @@ export const boardGroupPermissions = mysqlTable(
|
|||||||
);
|
);
|
||||||
|
|
||||||
export const sections = mysqlTable("section", {
|
export const sections = mysqlTable("section", {
|
||||||
id: varchar("id", { length: 64 }).notNull().primaryKey(),
|
id: varchar({ length: 64 }).notNull().primaryKey(),
|
||||||
boardId: varchar("board_id", { length: 64 })
|
boardId: varchar({ length: 64 })
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => boards.id, { onDelete: "cascade" }),
|
.references(() => boards.id, { onDelete: "cascade" }),
|
||||||
kind: text("kind").$type<SectionKind>().notNull(),
|
kind: text().$type<SectionKind>().notNull(),
|
||||||
xOffset: int("x_offset").notNull(),
|
xOffset: int().notNull(),
|
||||||
yOffset: int("y_offset").notNull(),
|
yOffset: int().notNull(),
|
||||||
width: int("width"),
|
width: int(),
|
||||||
height: int("height"),
|
height: int(),
|
||||||
name: text("name"),
|
name: text(),
|
||||||
parentSectionId: varchar("parent_section_id", { length: 64 }).references((): AnyMySqlColumn => sections.id, {
|
parentSectionId: varchar({ length: 64 }).references((): AnyMySqlColumn => sections.id, {
|
||||||
onDelete: "cascade",
|
onDelete: "cascade",
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const items = mysqlTable("item", {
|
export const items = mysqlTable("item", {
|
||||||
id: varchar("id", { length: 64 }).notNull().primaryKey(),
|
id: varchar({ length: 64 }).notNull().primaryKey(),
|
||||||
sectionId: varchar("section_id", { length: 64 })
|
sectionId: varchar({ length: 64 })
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => sections.id, { onDelete: "cascade" }),
|
.references(() => sections.id, { onDelete: "cascade" }),
|
||||||
kind: text("kind").$type<WidgetKind>().notNull(),
|
kind: text().$type<WidgetKind>().notNull(),
|
||||||
xOffset: int("x_offset").notNull(),
|
xOffset: int().notNull(),
|
||||||
yOffset: int("y_offset").notNull(),
|
yOffset: int().notNull(),
|
||||||
width: int("width").notNull(),
|
width: int().notNull(),
|
||||||
height: int("height").notNull(),
|
height: int().notNull(),
|
||||||
options: text("options").default('{"json": {}}').notNull(), // empty superjson object
|
options: text().default('{"json": {}}').notNull(), // empty superjson object
|
||||||
advancedOptions: text("advanced_options").default('{"json": {}}').notNull(), // empty superjson object
|
advancedOptions: text().default('{"json": {}}').notNull(), // empty superjson object
|
||||||
});
|
});
|
||||||
|
|
||||||
export const apps = mysqlTable("app", {
|
export const apps = mysqlTable("app", {
|
||||||
id: varchar("id", { length: 64 }).notNull().primaryKey(),
|
id: varchar({ length: 64 }).notNull().primaryKey(),
|
||||||
name: text("name").notNull(),
|
name: text().notNull(),
|
||||||
description: text("description"),
|
description: text(),
|
||||||
iconUrl: text("icon_url").notNull(),
|
iconUrl: text().notNull(),
|
||||||
href: text("href"),
|
href: text(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const integrationItems = mysqlTable(
|
export const integrationItems = mysqlTable(
|
||||||
"integration_item",
|
"integration_item",
|
||||||
{
|
{
|
||||||
itemId: varchar("item_id", { length: 64 })
|
itemId: varchar({ length: 64 })
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => items.id, { onDelete: "cascade" }),
|
.references(() => items.id, { onDelete: "cascade" }),
|
||||||
integrationId: varchar("integration_id", { length: 64 })
|
integrationId: varchar({ length: 64 })
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => integrations.id, { onDelete: "cascade" }),
|
.references(() => integrations.id, { onDelete: "cascade" }),
|
||||||
},
|
},
|
||||||
@@ -364,23 +358,23 @@ export const integrationItems = mysqlTable(
|
|||||||
);
|
);
|
||||||
|
|
||||||
export const icons = mysqlTable("icon", {
|
export const icons = mysqlTable("icon", {
|
||||||
id: varchar("icon_id", { length: 64 }).notNull().primaryKey(),
|
id: varchar({ length: 64 }).notNull().primaryKey(),
|
||||||
name: varchar("icon_name", { length: 250 }).notNull(),
|
name: varchar({ length: 250 }).notNull(),
|
||||||
url: text("icon_url").notNull(),
|
url: text().notNull(),
|
||||||
checksum: text("icon_checksum").notNull(),
|
checksum: text().notNull(),
|
||||||
iconRepositoryId: varchar("iconRepository_id", { length: 64 })
|
iconRepositoryId: varchar({ length: 64 })
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => iconRepositories.id, { onDelete: "cascade" }),
|
.references(() => iconRepositories.id, { onDelete: "cascade" }),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const iconRepositories = mysqlTable("iconRepository", {
|
export const iconRepositories = mysqlTable("iconRepository", {
|
||||||
id: varchar("iconRepository_id", { length: 64 }).notNull().primaryKey(),
|
id: varchar({ length: 64 }).notNull().primaryKey(),
|
||||||
slug: varchar("iconRepository_slug", { length: 150 }).notNull(),
|
slug: varchar({ length: 150 }).notNull(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const serverSettings = mysqlTable("serverSetting", {
|
export const serverSettings = mysqlTable("serverSetting", {
|
||||||
settingKey: varchar("key", { length: 64 }).notNull().unique().primaryKey(),
|
settingKey: varchar({ length: 64 }).notNull().unique().primaryKey(),
|
||||||
value: text("value").default('{"json": {}}').notNull(), // empty superjson object
|
value: text().default('{"json": {}}').notNull(), // empty superjson object
|
||||||
});
|
});
|
||||||
|
|
||||||
export const apiKeyRelations = relations(apiKeys, ({ one }) => ({
|
export const apiKeyRelations = relations(apiKeys, ({ one }) => ({
|
||||||
@@ -391,14 +385,14 @@ export const apiKeyRelations = relations(apiKeys, ({ one }) => ({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
export const searchEngines = mysqlTable("search_engine", {
|
export const searchEngines = mysqlTable("search_engine", {
|
||||||
id: varchar("id", { length: 64 }).notNull().primaryKey(),
|
id: varchar({ length: 64 }).notNull().primaryKey(),
|
||||||
iconUrl: text("icon_url").notNull(),
|
iconUrl: text().notNull(),
|
||||||
name: varchar("name", { length: 64 }).notNull(),
|
name: varchar({ length: 64 }).notNull(),
|
||||||
short: varchar("short", { length: 8 }).notNull(),
|
short: varchar({ length: 8 }).notNull(),
|
||||||
description: text("description"),
|
description: text(),
|
||||||
urlTemplate: text("url_template"),
|
urlTemplate: text(),
|
||||||
type: varchar("type", { length: 64 }).$type<SearchEngineType>().notNull().default("generic"),
|
type: varchar({ length: 64 }).$type<SearchEngineType>().notNull().default("generic"),
|
||||||
integrationId: varchar("integration_id", { length: 64 }).references(() => integrations.id, { onDelete: "cascade" }),
|
integrationId: varchar({ length: 64 }).references(() => integrations.id, { onDelete: "cascade" }),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const accountRelations = relations(accounts, ({ one }) => ({
|
export const accountRelations = relations(accounts, ({ one }) => ({
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import type { DayOfWeek } from "@mantine/dates";
|
|||||||
import type { InferSelectModel } from "drizzle-orm";
|
import type { InferSelectModel } from "drizzle-orm";
|
||||||
import { relations, sql } from "drizzle-orm";
|
import { relations, sql } from "drizzle-orm";
|
||||||
import type { AnySQLiteColumn } from "drizzle-orm/sqlite-core";
|
import type { AnySQLiteColumn } from "drizzle-orm/sqlite-core";
|
||||||
import { blob, index, int, integer, primaryKey, sqliteTable, text } from "drizzle-orm/sqlite-core";
|
import { blob, index, int, primaryKey, sqliteTable, text } from "drizzle-orm/sqlite-core";
|
||||||
|
|
||||||
import { backgroundImageAttachments, backgroundImageRepeats, backgroundImageSizes } from "@homarr/definitions";
|
import { backgroundImageAttachments, backgroundImageRepeats, backgroundImageSizes } from "@homarr/definitions";
|
||||||
import type {
|
import type {
|
||||||
@@ -23,10 +23,10 @@ import type {
|
|||||||
} from "@homarr/definitions";
|
} from "@homarr/definitions";
|
||||||
|
|
||||||
export const apiKeys = sqliteTable("apiKey", {
|
export const apiKeys = sqliteTable("apiKey", {
|
||||||
id: text("id").notNull().primaryKey(),
|
id: text().notNull().primaryKey(),
|
||||||
apiKey: text("apiKey").notNull(),
|
apiKey: text().notNull(),
|
||||||
salt: text("salt").notNull(),
|
salt: text().notNull(),
|
||||||
userId: text("userId")
|
userId: text()
|
||||||
.notNull()
|
.notNull()
|
||||||
.references((): AnySQLiteColumn => users.id, {
|
.references((): AnySQLiteColumn => users.id, {
|
||||||
onDelete: "cascade",
|
onDelete: "cascade",
|
||||||
@@ -34,38 +34,38 @@ export const apiKeys = sqliteTable("apiKey", {
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const users = sqliteTable("user", {
|
export const users = sqliteTable("user", {
|
||||||
id: text("id").notNull().primaryKey(),
|
id: text().notNull().primaryKey(),
|
||||||
name: text("name"),
|
name: text(),
|
||||||
email: text("email"),
|
email: text(),
|
||||||
emailVerified: integer("emailVerified", { mode: "timestamp_ms" }),
|
emailVerified: int({ mode: "timestamp_ms" }),
|
||||||
image: text("image"),
|
image: text(),
|
||||||
password: text("password"),
|
password: text(),
|
||||||
salt: text("salt"),
|
salt: text(),
|
||||||
provider: text("provider").$type<SupportedAuthProvider>().default("credentials").notNull(),
|
provider: text().$type<SupportedAuthProvider>().default("credentials").notNull(),
|
||||||
homeBoardId: text("homeBoardId").references((): AnySQLiteColumn => boards.id, {
|
homeBoardId: text().references((): AnySQLiteColumn => boards.id, {
|
||||||
onDelete: "set null",
|
onDelete: "set null",
|
||||||
}),
|
}),
|
||||||
colorScheme: text("colorScheme").$type<ColorScheme>().default("dark").notNull(),
|
colorScheme: text().$type<ColorScheme>().default("dark").notNull(),
|
||||||
firstDayOfWeek: int("firstDayOfWeek").$type<DayOfWeek>().default(1).notNull(), // Defaults to Monday
|
firstDayOfWeek: int().$type<DayOfWeek>().default(1).notNull(), // Defaults to Monday
|
||||||
pingIconsEnabled: int("pingIconsEnabled", { mode: "boolean" }).default(false).notNull(),
|
pingIconsEnabled: int({ mode: "boolean" }).default(false).notNull(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const accounts = sqliteTable(
|
export const accounts = sqliteTable(
|
||||||
"account",
|
"account",
|
||||||
{
|
{
|
||||||
userId: text("userId")
|
userId: text()
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => users.id, { onDelete: "cascade" }),
|
.references(() => users.id, { onDelete: "cascade" }),
|
||||||
type: text("type").$type<AdapterAccount["type"]>().notNull(),
|
type: text().$type<AdapterAccount["type"]>().notNull(),
|
||||||
provider: text("provider").notNull(),
|
provider: text().notNull(),
|
||||||
providerAccountId: text("providerAccountId").notNull(),
|
providerAccountId: text().notNull(),
|
||||||
refresh_token: text("refresh_token"),
|
refresh_token: text(),
|
||||||
access_token: text("access_token"),
|
access_token: text(),
|
||||||
expires_at: integer("expires_at"),
|
expires_at: int(),
|
||||||
token_type: text("token_type"),
|
token_type: text(),
|
||||||
scope: text("scope"),
|
scope: text(),
|
||||||
id_token: text("id_token"),
|
id_token: text(),
|
||||||
session_state: text("session_state"),
|
session_state: text(),
|
||||||
},
|
},
|
||||||
(account) => ({
|
(account) => ({
|
||||||
compoundKey: primaryKey({
|
compoundKey: primaryKey({
|
||||||
@@ -78,11 +78,11 @@ export const accounts = sqliteTable(
|
|||||||
export const sessions = sqliteTable(
|
export const sessions = sqliteTable(
|
||||||
"session",
|
"session",
|
||||||
{
|
{
|
||||||
sessionToken: text("sessionToken").notNull().primaryKey(),
|
sessionToken: text().notNull().primaryKey(),
|
||||||
userId: text("userId")
|
userId: text()
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => users.id, { onDelete: "cascade" }),
|
.references(() => users.id, { onDelete: "cascade" }),
|
||||||
expires: integer("expires", { mode: "timestamp_ms" }).notNull(),
|
expires: int({ mode: "timestamp_ms" }).notNull(),
|
||||||
},
|
},
|
||||||
(session) => ({
|
(session) => ({
|
||||||
userIdIdx: index("user_id_idx").on(session.userId),
|
userIdIdx: index("user_id_idx").on(session.userId),
|
||||||
@@ -92,9 +92,9 @@ export const sessions = sqliteTable(
|
|||||||
export const verificationTokens = sqliteTable(
|
export const verificationTokens = sqliteTable(
|
||||||
"verificationToken",
|
"verificationToken",
|
||||||
{
|
{
|
||||||
identifier: text("identifier").notNull(),
|
identifier: text().notNull(),
|
||||||
token: text("token").notNull(),
|
token: text().notNull(),
|
||||||
expires: integer("expires", { mode: "timestamp_ms" }).notNull(),
|
expires: int({ mode: "timestamp_ms" }).notNull(),
|
||||||
},
|
},
|
||||||
(verificationToken) => ({
|
(verificationToken) => ({
|
||||||
compoundKey: primaryKey({
|
compoundKey: primaryKey({
|
||||||
@@ -106,10 +106,10 @@ export const verificationTokens = sqliteTable(
|
|||||||
export const groupMembers = sqliteTable(
|
export const groupMembers = sqliteTable(
|
||||||
"groupMember",
|
"groupMember",
|
||||||
{
|
{
|
||||||
groupId: text("groupId")
|
groupId: text()
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => groups.id, { onDelete: "cascade" }),
|
.references(() => groups.id, { onDelete: "cascade" }),
|
||||||
userId: text("userId")
|
userId: text()
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => users.id, { onDelete: "cascade" }),
|
.references(() => users.id, { onDelete: "cascade" }),
|
||||||
},
|
},
|
||||||
@@ -121,50 +121,50 @@ export const groupMembers = sqliteTable(
|
|||||||
);
|
);
|
||||||
|
|
||||||
export const groups = sqliteTable("group", {
|
export const groups = sqliteTable("group", {
|
||||||
id: text("id").notNull().primaryKey(),
|
id: text().notNull().primaryKey(),
|
||||||
name: text("name").unique().notNull(),
|
name: text().unique().notNull(),
|
||||||
ownerId: text("owner_id").references(() => users.id, {
|
ownerId: text().references(() => users.id, {
|
||||||
onDelete: "set null",
|
onDelete: "set null",
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const groupPermissions = sqliteTable("groupPermission", {
|
export const groupPermissions = sqliteTable("groupPermission", {
|
||||||
groupId: text("groupId")
|
groupId: text()
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => groups.id, { onDelete: "cascade" }),
|
.references(() => groups.id, { onDelete: "cascade" }),
|
||||||
permission: text("permission").$type<GroupPermissionKey>().notNull(),
|
permission: text().$type<GroupPermissionKey>().notNull(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const invites = sqliteTable("invite", {
|
export const invites = sqliteTable("invite", {
|
||||||
id: text("id").notNull().primaryKey(),
|
id: text().notNull().primaryKey(),
|
||||||
token: text("token").notNull().unique(),
|
token: text().notNull().unique(),
|
||||||
expirationDate: int("expiration_date", {
|
expirationDate: int({
|
||||||
mode: "timestamp",
|
mode: "timestamp",
|
||||||
}).notNull(),
|
}).notNull(),
|
||||||
creatorId: text("creator_id")
|
creatorId: text()
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => users.id, { onDelete: "cascade" }),
|
.references(() => users.id, { onDelete: "cascade" }),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const medias = sqliteTable("media", {
|
export const medias = sqliteTable("media", {
|
||||||
id: text("id").notNull().primaryKey(),
|
id: text().notNull().primaryKey(),
|
||||||
name: text("name").notNull(),
|
name: text().notNull(),
|
||||||
content: blob("content", { mode: "buffer" }).$type<Buffer>().notNull(),
|
content: blob({ mode: "buffer" }).$type<Buffer>().notNull(),
|
||||||
contentType: text("content_type").notNull(),
|
contentType: text().notNull(),
|
||||||
size: int("size").notNull(),
|
size: int().notNull(),
|
||||||
createdAt: integer("created_at", { mode: "timestamp" })
|
createdAt: int({ mode: "timestamp" })
|
||||||
.notNull()
|
.notNull()
|
||||||
.default(sql`(unixepoch())`),
|
.default(sql`(unixepoch())`),
|
||||||
creatorId: text("creator_id").references(() => users.id, { onDelete: "set null" }),
|
creatorId: text().references(() => users.id, { onDelete: "set null" }),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const integrations = sqliteTable(
|
export const integrations = sqliteTable(
|
||||||
"integration",
|
"integration",
|
||||||
{
|
{
|
||||||
id: text("id").notNull().primaryKey(),
|
id: text().notNull().primaryKey(),
|
||||||
name: text("name").notNull(),
|
name: text().notNull(),
|
||||||
url: text("url").notNull(),
|
url: text().notNull(),
|
||||||
kind: text("kind").$type<IntegrationKind>().notNull(),
|
kind: text().$type<IntegrationKind>().notNull(),
|
||||||
},
|
},
|
||||||
(integrations) => ({
|
(integrations) => ({
|
||||||
kindIdx: index("integration__kind_idx").on(integrations.kind),
|
kindIdx: index("integration__kind_idx").on(integrations.kind),
|
||||||
@@ -174,12 +174,12 @@ export const integrations = sqliteTable(
|
|||||||
export const integrationSecrets = sqliteTable(
|
export const integrationSecrets = sqliteTable(
|
||||||
"integrationSecret",
|
"integrationSecret",
|
||||||
{
|
{
|
||||||
kind: text("kind").$type<IntegrationSecretKind>().notNull(),
|
kind: text().$type<IntegrationSecretKind>().notNull(),
|
||||||
value: text("value").$type<`${string}.${string}`>().notNull(),
|
value: text().$type<`${string}.${string}`>().notNull(),
|
||||||
updatedAt: integer("updated_at", { mode: "timestamp" })
|
updatedAt: int({ mode: "timestamp" })
|
||||||
.$onUpdateFn(() => new Date())
|
.$onUpdateFn(() => new Date())
|
||||||
.notNull(),
|
.notNull(),
|
||||||
integrationId: text("integration_id")
|
integrationId: text()
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => integrations.id, { onDelete: "cascade" }),
|
.references(() => integrations.id, { onDelete: "cascade" }),
|
||||||
},
|
},
|
||||||
@@ -195,13 +195,13 @@ export const integrationSecrets = sqliteTable(
|
|||||||
export const integrationUserPermissions = sqliteTable(
|
export const integrationUserPermissions = sqliteTable(
|
||||||
"integrationUserPermission",
|
"integrationUserPermission",
|
||||||
{
|
{
|
||||||
integrationId: text("integration_id")
|
integrationId: text()
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => integrations.id, { onDelete: "cascade" }),
|
.references(() => integrations.id, { onDelete: "cascade" }),
|
||||||
userId: text("user_id")
|
userId: text()
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => users.id, { onDelete: "cascade" }),
|
.references(() => users.id, { onDelete: "cascade" }),
|
||||||
permission: text("permission").$type<IntegrationPermission>().notNull(),
|
permission: text().$type<IntegrationPermission>().notNull(),
|
||||||
},
|
},
|
||||||
(table) => ({
|
(table) => ({
|
||||||
compoundKey: primaryKey({
|
compoundKey: primaryKey({
|
||||||
@@ -213,13 +213,13 @@ export const integrationUserPermissions = sqliteTable(
|
|||||||
export const integrationGroupPermissions = sqliteTable(
|
export const integrationGroupPermissions = sqliteTable(
|
||||||
"integrationGroupPermissions",
|
"integrationGroupPermissions",
|
||||||
{
|
{
|
||||||
integrationId: text("integration_id")
|
integrationId: text()
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => integrations.id, { onDelete: "cascade" }),
|
.references(() => integrations.id, { onDelete: "cascade" }),
|
||||||
groupId: text("group_id")
|
groupId: text()
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => groups.id, { onDelete: "cascade" }),
|
.references(() => groups.id, { onDelete: "cascade" }),
|
||||||
permission: text("permission").$type<IntegrationPermission>().notNull(),
|
permission: text().$type<IntegrationPermission>().notNull(),
|
||||||
},
|
},
|
||||||
(table) => ({
|
(table) => ({
|
||||||
compoundKey: primaryKey({
|
compoundKey: primaryKey({
|
||||||
@@ -229,46 +229,40 @@ export const integrationGroupPermissions = sqliteTable(
|
|||||||
);
|
);
|
||||||
|
|
||||||
export const boards = sqliteTable("board", {
|
export const boards = sqliteTable("board", {
|
||||||
id: text("id").notNull().primaryKey(),
|
id: text().notNull().primaryKey(),
|
||||||
name: text("name").unique().notNull(),
|
name: text().unique().notNull(),
|
||||||
isPublic: int("is_public", { mode: "boolean" }).default(false).notNull(),
|
isPublic: int({ mode: "boolean" }).default(false).notNull(),
|
||||||
creatorId: text("creator_id").references(() => users.id, {
|
creatorId: text().references(() => users.id, {
|
||||||
onDelete: "set null",
|
onDelete: "set null",
|
||||||
}),
|
}),
|
||||||
pageTitle: text("page_title"),
|
pageTitle: text(),
|
||||||
metaTitle: text("meta_title"),
|
metaTitle: text(),
|
||||||
logoImageUrl: text("logo_image_url"),
|
logoImageUrl: text(),
|
||||||
faviconImageUrl: text("favicon_image_url"),
|
faviconImageUrl: text(),
|
||||||
backgroundImageUrl: text("background_image_url"),
|
backgroundImageUrl: text(),
|
||||||
backgroundImageAttachment: text("background_image_attachment")
|
backgroundImageAttachment: text()
|
||||||
.$type<BackgroundImageAttachment>()
|
.$type<BackgroundImageAttachment>()
|
||||||
.default(backgroundImageAttachments.defaultValue)
|
.default(backgroundImageAttachments.defaultValue)
|
||||||
.notNull(),
|
.notNull(),
|
||||||
backgroundImageRepeat: text("background_image_repeat")
|
backgroundImageRepeat: text().$type<BackgroundImageRepeat>().default(backgroundImageRepeats.defaultValue).notNull(),
|
||||||
.$type<BackgroundImageRepeat>()
|
backgroundImageSize: text().$type<BackgroundImageSize>().default(backgroundImageSizes.defaultValue).notNull(),
|
||||||
.default(backgroundImageRepeats.defaultValue)
|
primaryColor: text().default("#fa5252").notNull(),
|
||||||
.notNull(),
|
secondaryColor: text().default("#fd7e14").notNull(),
|
||||||
backgroundImageSize: text("background_image_size")
|
opacity: int().default(100).notNull(),
|
||||||
.$type<BackgroundImageSize>()
|
customCss: text(),
|
||||||
.default(backgroundImageSizes.defaultValue)
|
columnCount: int().default(10).notNull(),
|
||||||
.notNull(),
|
|
||||||
primaryColor: text("primary_color").default("#fa5252").notNull(),
|
|
||||||
secondaryColor: text("secondary_color").default("#fd7e14").notNull(),
|
|
||||||
opacity: int("opacity").default(100).notNull(),
|
|
||||||
customCss: text("custom_css"),
|
|
||||||
columnCount: int("column_count").default(10).notNull(),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const boardUserPermissions = sqliteTable(
|
export const boardUserPermissions = sqliteTable(
|
||||||
"boardUserPermission",
|
"boardUserPermission",
|
||||||
{
|
{
|
||||||
boardId: text("board_id")
|
boardId: text()
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => boards.id, { onDelete: "cascade" }),
|
.references(() => boards.id, { onDelete: "cascade" }),
|
||||||
userId: text("user_id")
|
userId: text()
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => users.id, { onDelete: "cascade" }),
|
.references(() => users.id, { onDelete: "cascade" }),
|
||||||
permission: text("permission").$type<BoardPermission>().notNull(),
|
permission: text().$type<BoardPermission>().notNull(),
|
||||||
},
|
},
|
||||||
(table) => ({
|
(table) => ({
|
||||||
compoundKey: primaryKey({
|
compoundKey: primaryKey({
|
||||||
@@ -280,13 +274,13 @@ export const boardUserPermissions = sqliteTable(
|
|||||||
export const boardGroupPermissions = sqliteTable(
|
export const boardGroupPermissions = sqliteTable(
|
||||||
"boardGroupPermission",
|
"boardGroupPermission",
|
||||||
{
|
{
|
||||||
boardId: text("board_id")
|
boardId: text()
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => boards.id, { onDelete: "cascade" }),
|
.references(() => boards.id, { onDelete: "cascade" }),
|
||||||
groupId: text("group_id")
|
groupId: text()
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => groups.id, { onDelete: "cascade" }),
|
.references(() => groups.id, { onDelete: "cascade" }),
|
||||||
permission: text("permission").$type<BoardPermission>().notNull(),
|
permission: text().$type<BoardPermission>().notNull(),
|
||||||
},
|
},
|
||||||
(table) => ({
|
(table) => ({
|
||||||
compoundKey: primaryKey({
|
compoundKey: primaryKey({
|
||||||
@@ -296,50 +290,50 @@ export const boardGroupPermissions = sqliteTable(
|
|||||||
);
|
);
|
||||||
|
|
||||||
export const sections = sqliteTable("section", {
|
export const sections = sqliteTable("section", {
|
||||||
id: text("id").notNull().primaryKey(),
|
id: text().notNull().primaryKey(),
|
||||||
boardId: text("board_id")
|
boardId: text()
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => boards.id, { onDelete: "cascade" }),
|
.references(() => boards.id, { onDelete: "cascade" }),
|
||||||
kind: text("kind").$type<SectionKind>().notNull(),
|
kind: text().$type<SectionKind>().notNull(),
|
||||||
xOffset: int("x_offset").notNull(),
|
xOffset: int().notNull(),
|
||||||
yOffset: int("y_offset").notNull(),
|
yOffset: int().notNull(),
|
||||||
width: int("width"),
|
width: int(),
|
||||||
height: int("height"),
|
height: int(),
|
||||||
name: text("name"),
|
name: text(),
|
||||||
parentSectionId: text("parent_section_id").references((): AnySQLiteColumn => sections.id, {
|
parentSectionId: text().references((): AnySQLiteColumn => sections.id, {
|
||||||
onDelete: "cascade",
|
onDelete: "cascade",
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const items = sqliteTable("item", {
|
export const items = sqliteTable("item", {
|
||||||
id: text("id").notNull().primaryKey(),
|
id: text().notNull().primaryKey(),
|
||||||
sectionId: text("section_id")
|
sectionId: text()
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => sections.id, { onDelete: "cascade" }),
|
.references(() => sections.id, { onDelete: "cascade" }),
|
||||||
kind: text("kind").$type<WidgetKind>().notNull(),
|
kind: text().$type<WidgetKind>().notNull(),
|
||||||
xOffset: int("x_offset").notNull(),
|
xOffset: int().notNull(),
|
||||||
yOffset: int("y_offset").notNull(),
|
yOffset: int().notNull(),
|
||||||
width: int("width").notNull(),
|
width: int().notNull(),
|
||||||
height: int("height").notNull(),
|
height: int().notNull(),
|
||||||
options: text("options").default('{"json": {}}').notNull(), // empty superjson object
|
options: text().default('{"json": {}}').notNull(), // empty superjson object
|
||||||
advancedOptions: text("advanced_options").default('{"json": {}}').notNull(), // empty superjson object
|
advancedOptions: text().default('{"json": {}}').notNull(), // empty superjson object
|
||||||
});
|
});
|
||||||
|
|
||||||
export const apps = sqliteTable("app", {
|
export const apps = sqliteTable("app", {
|
||||||
id: text("id").notNull().primaryKey(),
|
id: text().notNull().primaryKey(),
|
||||||
name: text("name").notNull(),
|
name: text().notNull(),
|
||||||
description: text("description"),
|
description: text(),
|
||||||
iconUrl: text("icon_url").notNull(),
|
iconUrl: text().notNull(),
|
||||||
href: text("href"),
|
href: text(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const integrationItems = sqliteTable(
|
export const integrationItems = sqliteTable(
|
||||||
"integration_item",
|
"integration_item",
|
||||||
{
|
{
|
||||||
itemId: text("item_id")
|
itemId: text()
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => items.id, { onDelete: "cascade" }),
|
.references(() => items.id, { onDelete: "cascade" }),
|
||||||
integrationId: text("integration_id")
|
integrationId: text()
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => integrations.id, { onDelete: "cascade" }),
|
.references(() => integrations.id, { onDelete: "cascade" }),
|
||||||
},
|
},
|
||||||
@@ -351,23 +345,23 @@ export const integrationItems = sqliteTable(
|
|||||||
);
|
);
|
||||||
|
|
||||||
export const icons = sqliteTable("icon", {
|
export const icons = sqliteTable("icon", {
|
||||||
id: text("icon_id").notNull().primaryKey(),
|
id: text().notNull().primaryKey(),
|
||||||
name: text("icon_name").notNull(),
|
name: text().notNull(),
|
||||||
url: text("icon_url").notNull(),
|
url: text().notNull(),
|
||||||
checksum: text("icon_checksum").notNull(),
|
checksum: text().notNull(),
|
||||||
iconRepositoryId: text("iconRepository_id")
|
iconRepositoryId: text()
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => iconRepositories.id, { onDelete: "cascade" }),
|
.references(() => iconRepositories.id, { onDelete: "cascade" }),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const iconRepositories = sqliteTable("iconRepository", {
|
export const iconRepositories = sqliteTable("iconRepository", {
|
||||||
id: text("iconRepository_id").notNull().primaryKey(),
|
id: text().notNull().primaryKey(),
|
||||||
slug: text("iconRepository_slug").notNull(),
|
slug: text().notNull(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const serverSettings = sqliteTable("serverSetting", {
|
export const serverSettings = sqliteTable("serverSetting", {
|
||||||
settingKey: text("key").notNull().unique().primaryKey(),
|
settingKey: text().notNull().unique().primaryKey(),
|
||||||
value: text("value").default('{"json": {}}').notNull(), // empty superjson object
|
value: text().default('{"json": {}}').notNull(), // empty superjson object
|
||||||
});
|
});
|
||||||
|
|
||||||
export const apiKeyRelations = relations(apiKeys, ({ one }) => ({
|
export const apiKeyRelations = relations(apiKeys, ({ one }) => ({
|
||||||
@@ -378,14 +372,14 @@ export const apiKeyRelations = relations(apiKeys, ({ one }) => ({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
export const searchEngines = sqliteTable("search_engine", {
|
export const searchEngines = sqliteTable("search_engine", {
|
||||||
id: text("id").notNull().primaryKey(),
|
id: text().notNull().primaryKey(),
|
||||||
iconUrl: text("icon_url").notNull(),
|
iconUrl: text().notNull(),
|
||||||
name: text("name").notNull(),
|
name: text().notNull(),
|
||||||
short: text("short").notNull(),
|
short: text().notNull(),
|
||||||
description: text("description"),
|
description: text(),
|
||||||
urlTemplate: text("url_template"),
|
urlTemplate: text(),
|
||||||
type: text("type").$type<SearchEngineType>().notNull().default("generic"),
|
type: text().$type<SearchEngineType>().notNull().default("generic"),
|
||||||
integrationId: text("integration_id").references(() => integrations.id, { onDelete: "cascade" }),
|
integrationId: text().references(() => integrations.id, { onDelete: "cascade" }),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const accountRelations = relations(accounts, ({ one }) => ({
|
export const accountRelations = relations(accounts, ({ one }) => ({
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { schema } from "..";
|
|||||||
|
|
||||||
export const createDb = (debug?: boolean) => {
|
export const createDb = (debug?: boolean) => {
|
||||||
const sqlite = new Database(":memory:");
|
const sqlite = new Database(":memory:");
|
||||||
const db = drizzle(sqlite, { schema, logger: debug });
|
const db = drizzle(sqlite, { schema, logger: debug, casing: "snake_case" });
|
||||||
migrate(db, {
|
migrate(db, {
|
||||||
migrationsFolder: "./packages/db/migrations/sqlite",
|
migrationsFolder: "./packages/db/migrations/sqlite",
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ describe("Mysql Migration", () => {
|
|||||||
const database = drizzle(connection, {
|
const database = drizzle(connection, {
|
||||||
schema: mysqlSchema,
|
schema: mysqlSchema,
|
||||||
mode: "default",
|
mode: "default",
|
||||||
|
casing: "snake_case",
|
||||||
});
|
});
|
||||||
|
|
||||||
// Run migrations and check if it works
|
// Run migrations and check if it works
|
||||||
|
|||||||
Reference in New Issue
Block a user