mirror of
https://github.com/chrisbenincasa/tunarr.git
synced 2026-04-18 09:03:35 -04:00
Giving kysely a go
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -10,4 +10,5 @@ package-lock.json
|
||||
config/
|
||||
.vscode/
|
||||
build/
|
||||
log.txt
|
||||
log.txt
|
||||
*.db
|
||||
3
pnpm-lock.yaml
generated
3
pnpm-lock.yaml
generated
@@ -59,6 +59,9 @@ importers:
|
||||
cors:
|
||||
specifier: ^2.8.5
|
||||
version: 2.8.5
|
||||
dayjs:
|
||||
specifier: ^1.11.10
|
||||
version: 1.11.10
|
||||
dizquetv-types:
|
||||
specifier: workspace:*
|
||||
version: link:../types
|
||||
|
||||
@@ -1,7 +1,15 @@
|
||||
import { Generated, Selectable } from 'kysely';
|
||||
import { ColumnType, Selectable } from 'kysely';
|
||||
|
||||
export interface PlexServerSettingsTable {
|
||||
id: Generated<number>;
|
||||
id: string;
|
||||
name: string;
|
||||
uri: string;
|
||||
access_token: string;
|
||||
send_guide_updates: boolean;
|
||||
send_channel_updates: boolean;
|
||||
index: number;
|
||||
created_at: ColumnType<Date, string | undefined, never>;
|
||||
// updated_at: ColumnType<Date,
|
||||
}
|
||||
|
||||
export type PlexServerSettings = Selectable<PlexServerSettingsTable>;
|
||||
|
||||
@@ -1,10 +1,24 @@
|
||||
import { Kysely } from 'kysely';
|
||||
import { Kysely, sql } from 'kysely';
|
||||
|
||||
export async function up(db: Kysely<unknown>): Promise<void> {
|
||||
await db.schema
|
||||
const query = db.schema
|
||||
.createTable('plexServerSettings')
|
||||
.addColumn('id', 'integer', (col) => col.primaryKey())
|
||||
.execute();
|
||||
.addColumn('name', 'text', (col) => col.notNull())
|
||||
.addColumn('uri', 'text', (col) => col.notNull())
|
||||
.addColumn('access_token', 'text', (col) => col.notNull())
|
||||
.addColumn('send_guide_updates', 'integer', (col) =>
|
||||
col.notNull().defaultTo(sql`TRUE`),
|
||||
)
|
||||
.addColumn('send_channel_updates', 'integer', (col) =>
|
||||
col.notNull().defaultTo(sql`TRUE`),
|
||||
)
|
||||
.addColumn('index', 'integer', (col) => col.notNull())
|
||||
.addColumn('created_at', 'timestamp', (col) =>
|
||||
col.notNull().defaultTo(sql`(unixepoch())`),
|
||||
);
|
||||
console.log(query.compile());
|
||||
return query.execute();
|
||||
}
|
||||
|
||||
export async function down(db: Kysely<unknown>): Promise<void> {
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
"body-parser": "^1.19.0",
|
||||
"chalk": "^5.3.0",
|
||||
"cors": "^2.8.5",
|
||||
"dayjs": "^1.11.10",
|
||||
"dizquetv-types": "workspace:*",
|
||||
"express-fileupload": "^1.2.1",
|
||||
"fast-json-stringify": "^5.9.1",
|
||||
|
||||
Reference in New Issue
Block a user