-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #126 from Carifio24/stages
Add endpoints for getting stages and stage states
- Loading branch information
Showing
5 changed files
with
140 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { Sequelize, DataTypes, Model, InferAttributes, InferCreationAttributes, CreationOptional } from "sequelize"; | ||
import { Story } from "./story"; | ||
|
||
|
||
export class Stage extends Model<InferAttributes<Stage>, InferCreationAttributes<Stage>> { | ||
declare story_name: string; | ||
declare stage_name: string; | ||
declare stage_index: CreationOptional<number | null>; | ||
} | ||
|
||
export function initializeStageModel(sequelize: Sequelize) { | ||
Stage.init({ | ||
story_name: { | ||
type: DataTypes.STRING, | ||
allowNull: false, | ||
unique: true, | ||
primaryKey: true, | ||
}, | ||
stage_name: { | ||
type: DataTypes.STRING, | ||
allowNull: false, | ||
unique: true, | ||
primaryKey: true, | ||
references: { | ||
model: Story, | ||
key: "name", | ||
} | ||
}, | ||
stage_index: { | ||
type: DataTypes.INTEGER.UNSIGNED, | ||
allowNull: true, | ||
defaultValue: null, | ||
} | ||
}, { | ||
sequelize, | ||
engine: "InnoDB", | ||
indexes: [ | ||
{ | ||
unique: true, | ||
fields: ["story_name", "stage_name"], | ||
}, | ||
{ | ||
unique: true, | ||
fields: ["story_name"], | ||
}, | ||
{ | ||
unique: true, | ||
fields: ["stage_name"], | ||
}, | ||
] | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
CREATE TABLE Stages ( | ||
story_name varchar(50) NOT NULL, | ||
stage_name varchar(50) NOT NULL, | ||
stage_index int(11) UNSIGNED DEFAULT NULL, | ||
|
||
PRIMARY KEY(story_name, stage_name), | ||
INDEX(story_name), | ||
INDEX(stage_name), | ||
FOREIGN KEY(story_name) | ||
REFERENCES Stories(name) | ||
ON UPDATE CASCADE | ||
ON DELETE CASCADE | ||
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci PACK_KEYS=0; |