Fixed sequelize crash, added variables

This commit is contained in:
Alexis
2021-07-24 22:47:45 +02:00
parent f3bbe696ed
commit f1d620dacd
8 changed files with 83 additions and 21 deletions

View File

@@ -0,0 +1,55 @@
import { DataTypes, Model, Optional } from "sequelize";
import { AuracleDatabaseDriver } from "../../AuracleDatabaseDriver";
interface VariableAttributes {
id: number
uuid: string
description: string
published: boolean
}
interface VariableCreationAttributes extends Optional<VariableAttributes, 'id'> { }
export class Variable extends Model<VariableAttributes, VariableCreationAttributes> implements VariableAttributes {
public readonly id!: number
public readonly uuid!: string
public description!: string
public published: boolean
public readonly createdAt!: Date;
public readonly updatedAt!: Date;
}
export default () => {
Variable.init(
{
id: {
type: DataTypes.INTEGER.UNSIGNED,
autoIncrement: true,
primaryKey: true
},
uuid: {
type: DataTypes.UUID,
allowNull: false,
unique: true,
defaultValue: DataTypes.UUIDV4
},
description: {
type: DataTypes.STRING,
allowNull: false,
},
published: {
type: DataTypes.BOOLEAN,
defaultValue: false
}
},
{
tableName: 'variables',
sequelize: AuracleDatabaseDriver,
}
)
}