Skip to content

Commit

Permalink
wip db
Browse files Browse the repository at this point in the history
  • Loading branch information
paulhollmann committed Mar 15, 2024
1 parent 90d44bb commit 62e3b62
Show file tree
Hide file tree
Showing 11 changed files with 893 additions and 479 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const { DataType } = require("sequelize-typescript");
import { DataType } from "sequelize-typescript";
import { QueryInterface } from "sequelize";

const DataModelAttributes = {
export const USER_SESSION_TABLE_NAME = "user_session";
export const USER_SESSION_ATTRIBUTES = {
id: {
type: DataType.INTEGER,
primaryKey: true,
Expand Down Expand Up @@ -40,14 +42,12 @@ const DataModelAttributes = {
updatedAt: DataType.DATE,
};

module.exports = {
async up(queryInterface) {
await queryInterface.createTable("user_session", DataModelAttributes);
export default {
async up(queryInterface: QueryInterface) {
await queryInterface.createTable(USER_SESSION_TABLE_NAME, USER_SESSION_ATTRIBUTES);
},

async down(queryInterface) {
await queryInterface.dropTable("user_session");
async down(queryInterface: QueryInterface) {
await queryInterface.dropTable(USER_SESSION_TABLE_NAME);
},

DataModelAttributes,
};
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
const { DataType } = require("sequelize-typescript");
import { DataType } from "sequelize-typescript";
import { QueryInterface } from "sequelize";

export const USER_SETTINGS_TABLE_NAME = "user_settings";

const LanguageEnum = ["de", "en"];

const DataModelAttributes = {
export const USER_SETTINGS_TABLE_ATTRIBUTES = {
user_id: {
type: DataType.INTEGER,
primaryKey: true,
Expand Down Expand Up @@ -32,14 +35,12 @@ const DataModelAttributes = {
updatedAt: DataType.DATE,
};

module.exports = {
async up(queryInterface) {
await queryInterface.createTable("user_settings", DataModelAttributes);
export default {
async up(queryInterface: QueryInterface) {
await queryInterface.createTable(USER_SETTINGS_TABLE_NAME, USER_SETTINGS_TABLE_ATTRIBUTES);
},

async down(queryInterface) {
await queryInterface.dropTable("user_settings");
async down(queryInterface: QueryInterface) {
await queryInterface.dropTable(USER_SETTINGS_TABLE_NAME);
},

DataModelAttributes,
};
34 changes: 0 additions & 34 deletions db/migrations/20221115171244-create-mentor-groups-table.js

This file was deleted.

34 changes: 34 additions & 0 deletions db/migrations/20221115171244-create-mentor-groups-table.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { QueryInterface } from "sequelize";

import { DataType } from "sequelize-typescript";

const firTypeEnum = ["edww", "edgg", "edmm"];
export const MENTOR_GROUPS_TABLE_NAME = "mentor_groups";
export const MENTOR_GROUPS_TABLE_ATTRIBUTES = {
id: {
type: DataType.INTEGER,
primaryKey: true,
autoIncrement: true,
},
name: {
type: DataType.STRING(70),
comment: "Name of mentor-group. Max length 70 chars",
allowNull: false,
},
fir: {
type: DataType.ENUM(...firTypeEnum),
allowNull: true,
},
createdAt: DataType.DATE,
updatedAt: DataType.DATE,
};

export default {
async up(queryInterface: QueryInterface) {
await queryInterface.createTable(MENTOR_GROUPS_TABLE_NAME, MENTOR_GROUPS_TABLE_ATTRIBUTES);
},

async down(queryInterface: QueryInterface) {
await queryInterface.dropTable(MENTOR_GROUPS_TABLE_NAME);
},
};

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { QueryInterface } from "sequelize";

import { DataType } from "sequelize-typescript";

export const TRAINING_LOG_TEMPLATES_TABLE_NAME = "training_log_templates";

export const TRAINING_LOG_TEMPLATES_ATTRIBUTES = {
id: {
type: DataType.INTEGER,
primaryKey: true,
autoIncrement: true,
},
name: {
type: DataType.STRING,
allowNull: false,
},
content: {
type: DataType.JSON,
allowNull: false,
defaultValue: [],
},
createdAt: DataType.DATE,
updatedAt: DataType.DATE,
};

export default {
async up(queryInterface: QueryInterface) {
await queryInterface.createTable(TRAINING_LOG_TEMPLATES_TABLE_NAME, TRAINING_LOG_TEMPLATES_ATTRIBUTES);
},

async down(queryInterface: QueryInterface) {
await queryInterface.dropTable(TRAINING_LOG_TEMPLATES_TABLE_NAME);
},
};
Loading

0 comments on commit 62e3b62

Please sign in to comment.