40 lines
676 B
TypeScript
40 lines
676 B
TypeScript
import { sequelize } from '@/app.ts';
|
|
import { DataTypes, Model } from 'sequelize';
|
|
|
|
// Define the system config model
|
|
|
|
export class Config extends Model {
|
|
declare id: number;
|
|
declare key: string;
|
|
declare value: string;
|
|
}
|
|
|
|
Config.init(
|
|
{
|
|
id: {
|
|
type: DataTypes.INTEGER,
|
|
autoIncrement: true,
|
|
primaryKey: true,
|
|
},
|
|
key: {
|
|
type: DataTypes.STRING,
|
|
allowNull: false,
|
|
},
|
|
value: {
|
|
type: DataTypes.JSON,
|
|
defaultValue: {},
|
|
},
|
|
},
|
|
{
|
|
sequelize,
|
|
tableName: 'system_config',
|
|
},
|
|
);
|
|
|
|
await Config.sync({
|
|
alter: true,
|
|
logging: false,
|
|
}).catch((e) => {
|
|
console.error('Config table sync error', e);
|
|
});
|