-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
71 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,11 @@ | ||
import type { Config } from 'drizzle-kit'; | ||
import { env } from './server/env'; | ||
|
||
const dbCredentials = (() => { | ||
switch (env.DATABASE_CONNECTION_TYPE) { | ||
case 'local': return { url: 'file:local.sqlite' }; | ||
case 'remote': return { url: env.DATABASE_URL, authToken: env.DATABASE_AUTH_TOKEN }; | ||
} | ||
})(); | ||
|
||
export default { | ||
schema: './server/db/schema/index.ts', | ||
out: './drizzle', | ||
driver: 'turso', | ||
dbCredentials, | ||
tablesFilter: ['!libsql_wasm_func_table'], | ||
dialect: 'postgresql', | ||
dbCredentials: { | ||
url: env.DATABASE_URL, | ||
}, | ||
} satisfies Config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { integer, sqliteTable, text } from 'drizzle-orm/sqlite-core'; | ||
import { boolean, json, pgTable, text } from 'drizzle-orm/pg-core'; | ||
|
||
export const arrangements = sqliteTable('arrangements', { | ||
date: text('date', { mode: 'text' }).primaryKey(), | ||
songIds: text('song_ids', { mode: 'json' }).$type<string[]>(), | ||
isPublic: integer('is_public', { mode: 'boolean' }).notNull().default(false), | ||
export const arrangements = pgTable('arrangements', { | ||
date: text('date').primaryKey(), | ||
songIds: json('song_ids').$type<string[]>(), | ||
isPublic: boolean('is_public').notNull().default(false), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
import { integer, sqliteTable, text } from 'drizzle-orm/sqlite-core'; | ||
import { integer, pgTable, text, timestamp, varchar } from 'drizzle-orm/pg-core'; | ||
import { useNanoID } from '../../../composables/useNanoID'; | ||
|
||
export const songs = sqliteTable('songs', { | ||
id: text('id', { mode: 'text' }).primaryKey().$defaultFn(() => useNanoID()), | ||
name: text('name', { mode: 'text' }).notNull(), | ||
creator: text('creator', { mode: 'text' }).notNull(), | ||
submitterName: text('submitter_name', { mode: 'text' }).notNull(), | ||
submitterGrade: integer('submitter_grade', { mode: 'number' }).notNull(), // 1: 高一 | 2: 高二 | 3: 国体高一 | 4: 国体高二 | 5: 国体高三 | ||
submitterClass: integer('submitter_class', { mode: 'number' }).notNull(), | ||
export const songs = pgTable('songs', { | ||
id: varchar('id', { length: 20 }).primaryKey().$defaultFn(() => useNanoID()), | ||
name: text('name').notNull(), | ||
creator: text('creator').notNull(), | ||
submitterName: text('submitter_name').notNull(), | ||
submitterGrade: integer('submitter_grade').notNull(), // 1: 高一 | 2: 高二 | 3: 国体高一 | 4: 国体高二 | 5: 国体高三 | ||
submitterClass: integer('submitter_class').notNull(), | ||
status: text('status', { enum: ['unset', 'approved', 'rejected', 'used'] }).notNull().default('unset'), | ||
type: text('type', { enum: ['normal', 'withMsg'] }).notNull(), | ||
message: text('message', { mode: 'text' }), | ||
createdAt: integer('created_at', { mode: 'timestamp' }).notNull().$defaultFn(() => new Date()), | ||
message: text('message'), | ||
createdAt: timestamp('created_at').notNull().$defaultFn(() => new Date()), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import { integer, sqliteTable, text } from 'drizzle-orm/sqlite-core'; | ||
import { boolean, pgTable, text, timestamp, varchar } from 'drizzle-orm/pg-core'; | ||
import { useNanoID } from '../../../composables/useNanoID'; | ||
|
||
export const times = sqliteTable('times', { | ||
id: text('id', { mode: 'text' }).primaryKey().$defaultFn(() => useNanoID()), | ||
name: text('name', { mode: 'text' }).notNull(), | ||
startAt: integer('start_at', { mode: 'timestamp' }).notNull(), | ||
endAt: integer('end_at', { mode: 'timestamp' }).notNull(), | ||
repeats: integer('repeats', { mode: 'boolean' }).notNull().default(false), | ||
isActive: integer('is_active', { mode: 'boolean' }).notNull().default(true), | ||
export const times = pgTable('times', { | ||
id: varchar('id', { length: 20 }).primaryKey().$defaultFn(() => useNanoID()), | ||
name: text('name').notNull(), | ||
startAt: timestamp('start_at').notNull(), | ||
endAt: timestamp('end_at').notNull(), | ||
repeats: boolean('repeats').notNull().default(false), | ||
isActive: boolean('is_active').notNull().default(true), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import { integer, sqliteTable, text } from 'drizzle-orm/sqlite-core'; | ||
import { pgTable, text, timestamp, varchar } from 'drizzle-orm/pg-core'; | ||
import { useNanoID } from '../../../composables/useNanoID'; | ||
|
||
export const users = sqliteTable('users', { | ||
id: text('id', { mode: 'text' }).primaryKey().$defaultFn(() => useNanoID()), | ||
password: text('password', { mode: 'text' }).notNull(), | ||
createdAt: integer('created_at', { mode: 'timestamp' }).notNull().$defaultFn(() => new Date()), | ||
export const users = pgTable('users', { | ||
id: varchar('id', { length: 20 }).primaryKey().$defaultFn(() => useNanoID()), | ||
password: text('password').notNull(), | ||
createdAt: timestamp('created_at').notNull().$defaultFn(() => new Date()), | ||
}); | ||
|
||
export const refreshTokens = sqliteTable('refresh_tokens', { | ||
id: text('id', { mode: 'text' }).primaryKey().$defaultFn(() => useNanoID()), | ||
token: text('token', { mode: 'text' }).notNull(), | ||
owner: text('owner', { mode: 'text' }).references(() => users.id).notNull(), | ||
export const refreshTokens = pgTable('refresh_tokens', { | ||
id: varchar('id', { length: 20 }).primaryKey().$defaultFn(() => useNanoID()), | ||
token: text('token').notNull(), | ||
owner: text('owner').references(() => users.id).notNull(), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters