Fixed sequelize crash, added variables
This commit is contained in:
55
src/database/models/spells/Variable.ts
Normal file
55
src/database/models/spells/Variable.ts
Normal 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,
|
||||
}
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user