Updated db models

This commit is contained in:
Alexis
2021-07-24 22:20:48 +02:00
parent ca9dbbd7db
commit f3bbe696ed
7 changed files with 64 additions and 15 deletions

View File

@@ -4,6 +4,7 @@ import { AuracleDatabaseDriver } from "../../AuracleDatabaseDriver";
interface IngredientAttributes {
id: number
uuid: string
name: string
description: string
@@ -12,8 +13,9 @@ interface IngredientAttributes {
interface IngredientCreationAttributes extends Optional<IngredientAttributes, 'id'> { }
class Ingredient extends Model<IngredientAttributes, IngredientCreationAttributes> implements IngredientAttributes {
public id!: number
export class Ingredient extends Model<IngredientAttributes, IngredientCreationAttributes> implements IngredientAttributes {
public readonly id!: number
public readonly uuid!: string
public name!: string
public description!: string
@@ -31,6 +33,11 @@ export default () => {
autoIncrement: true,
primaryKey: true
},
uuid: {
type: DataTypes.UUIDV4,
allowNull: false,
unique: true
},
name: {
type: DataTypes.STRING,
allowNull: false,

View File

@@ -4,6 +4,7 @@ import { AuracleDatabaseDriver } from "../../AuracleDatabaseDriver";
interface MetaSchoolAttributes {
id: number
uuid: string
name: string
description: string
@@ -12,8 +13,9 @@ interface MetaSchoolAttributes {
interface MetaSchoolCreationAttributes extends Optional<MetaSchoolAttributes, 'id'> { }
class MetaSchool extends Model<MetaSchoolAttributes, MetaSchoolCreationAttributes> implements MetaSchoolAttributes {
public id!: number
export class MetaSchool extends Model<MetaSchoolAttributes, MetaSchoolCreationAttributes> implements MetaSchoolAttributes {
public readonly id!: number
public readonly uuid!: string
public name!: string
public description!: string
@@ -31,6 +33,11 @@ export default () => {
autoIncrement: true,
primaryKey: true
},
uuid: {
type: DataTypes.UUIDV4,
allowNull: false,
unique: true
},
name: {
type: DataTypes.STRING,
allowNull: false,

View File

@@ -4,6 +4,7 @@ import { AuracleDatabaseDriver } from "../../AuracleDatabaseDriver";
interface SchoolAttributes {
id: number
uuid: string
name: string
description: string
@@ -12,8 +13,9 @@ interface SchoolAttributes {
interface SchoolCreationAttributes extends Optional<SchoolAttributes, 'id'> { }
class School extends Model<SchoolAttributes, SchoolCreationAttributes> implements SchoolAttributes {
public id!: number
export class School extends Model<SchoolAttributes, SchoolCreationAttributes> implements SchoolAttributes {
public readonly id!: number
public readonly uuid!: string
public name!: string
public description!: string
@@ -31,6 +33,11 @@ export default () => {
autoIncrement: true,
primaryKey: true
},
uuid: {
type: DataTypes.UUIDV4,
allowNull: false,
unique: true
},
name: {
type: DataTypes.STRING,
allowNull: false,

View File

@@ -4,6 +4,7 @@ import { AuracleDatabaseDriver } from "../../AuracleDatabaseDriver";
interface SpellAttributes {
id: number
uuid: string
name: string
description: string
@@ -18,8 +19,9 @@ interface SpellAttributes {
interface SpellCreationAttributes extends Optional<SpellAttributes, 'id'> { }
class Spell extends Model<SpellAttributes, SpellCreationAttributes> implements SpellAttributes {
public id!: number
export class SpellModel extends Model<SpellAttributes, SpellCreationAttributes> implements SpellAttributes {
public readonly id!: number
public readonly uuid!: string
public name!: string
public description!: string
@@ -36,13 +38,18 @@ class Spell extends Model<SpellAttributes, SpellCreationAttributes> implements S
}
export default () => {
Spell.init(
SpellModel.init(
{
id: {
type: DataTypes.INTEGER.UNSIGNED,
autoIncrement: true,
primaryKey: true
},
uuid: {
type: DataTypes.UUIDV4,
allowNull: false,
unique: true
},
name: {
type: DataTypes.STRING,
allowNull: false,