84 lines
2.2 KiB
TypeScript
84 lines
2.2 KiB
TypeScript
import {
|
|
boolean,
|
|
char,
|
|
int,
|
|
longtext,
|
|
mysqlTable,
|
|
serial,
|
|
text,
|
|
timestamp,
|
|
tinyint,
|
|
varchar
|
|
} from 'drizzle-orm/mysql-core';
|
|
import { longblob, mediumblob } from './custom-types';
|
|
|
|
export const task = mysqlTable('task', {
|
|
id: serial('id').primaryKey(),
|
|
title: text('title').notNull(),
|
|
priority: int('priority').notNull().default(1)
|
|
});
|
|
|
|
export const config = mysqlTable('config', {
|
|
key: varchar('key', { length: 64 }).primaryKey(),
|
|
value: longtext('value').notNull()
|
|
});
|
|
|
|
export const projects = mysqlTable('projects', {
|
|
id: tinyint('id').notNull().primaryKey().autoincrement(),
|
|
name: text('name').notNull(),
|
|
data: longtext('data', {}).notNull(),
|
|
enabled: tinyint('enabled').notNull()
|
|
});
|
|
|
|
export const locales = mysqlTable('locales', {
|
|
code: char('code').notNull().unique(),
|
|
name: char('name').notNull(),
|
|
dictionary: longtext().notNull(),
|
|
flag: longtext('').notNull(),
|
|
enabled: tinyint('enabled').notNull()
|
|
});
|
|
|
|
export const groups = mysqlTable('groups', {
|
|
gid: int('gid').primaryKey().autoincrement(),
|
|
name: varchar('name', { length: 32 }).notNull().unique()
|
|
});
|
|
|
|
export const users = mysqlTable('users', {
|
|
uid: int('uid').primaryKey().autoincrement(),
|
|
username: varchar('username', { length: 32 }).notNull().unique(),
|
|
password: varchar('password', { length: 128 }).notNull(),
|
|
home: int('home').notNull(),
|
|
gid: int('gid')
|
|
.notNull()
|
|
.references(() => groups.gid),
|
|
accessible: boolean('accessible').notNull(),
|
|
face: mediumblob('face')
|
|
});
|
|
|
|
export const filesystem = mysqlTable(
|
|
'filesystem',
|
|
{
|
|
id: int('id').primaryKey().default(1),
|
|
data: longtext('data').notNull(),
|
|
checksum: varchar('checksum', { length: 32 }).notNull(),
|
|
updatedAt: timestamp('updated_at').defaultNow().onUpdateNow()
|
|
} /* ,
|
|
{
|
|
// Ensures only one row can exist
|
|
singleRow: check('single_row_check', `id = 1`)
|
|
} */
|
|
);
|
|
|
|
export const fileContents = mysqlTable('file_contents', {
|
|
guid: varchar('guid', { length: 36 }).primaryKey(),
|
|
data: longblob('data').notNull(),
|
|
mimeType: varchar('mime_type', { length: 127 }).default('text/plain'),
|
|
checksum: varchar('checksum', { length: 32 }).notNull()
|
|
});
|
|
|
|
export const allowList = mysqlTable('allow_list', {
|
|
ip: int('ip').notNull()
|
|
});
|
|
|
|
export type Config = typeof config.$inferSelect;
|