diff --git a/server/src/db/createInitialWorker.ts b/server/src/db/createInitialWorker.ts deleted file mode 100644 index 790c55508f100080f468b8b914723e848ab676f2..0000000000000000000000000000000000000000 --- a/server/src/db/createInitialWorker.ts +++ /dev/null @@ -1,23 +0,0 @@ -import bcrypt from "bcrypt"; -import envVars from "../config"; -import Worker from "./models/Worker"; - -const createInitialWorkerIfNotExists = async () => { - const numberOfWorkers = await Worker.count(); - - if (numberOfWorkers === 0) { - const initialCoordinatorPassword = envVars.INITIAL_COORDINATOR_PASSWORD; - const initialCoordinatorEmail = envVars.INITIAL_COORDINATOR_EMAIL; - - const hashedPassword = await bcrypt.hash(initialCoordinatorPassword, 10); - - await Worker.create({ - email: initialCoordinatorEmail, - password: hashedPassword, - first_name: "coordinator_firstName", - last_name: "coordinator_lastName", - role: "coordinator", - }); - } -}; -export default createInitialWorkerIfNotExists; diff --git a/server/src/db/models/Worker.ts b/server/src/db/models/Worker.ts deleted file mode 100644 index 52012904fbb3e21246521864243cbd57189c1368..0000000000000000000000000000000000000000 --- a/server/src/db/models/Worker.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { DataTypes, Model, Optional, Sequelize } from "sequelize"; - -interface WorkerAttributes { - id: string; - email: string; - first_name: string; - last_name: string; - password: string; - role: string; -} -export interface WorkerInput extends Optional<WorkerAttributes, "id"> {} -class Worker - extends Model<WorkerAttributes, WorkerInput> - implements WorkerAttributes -{ - declare id: string; - declare email: string; - declare first_name: string; - declare last_name: string; - declare password: string; - declare role: string; - declare readonly createdAt: Date; - declare readonly updatedAt: Date; -} -export const initWorker = async (sequelizeConnection: Sequelize) => { - Worker.init( - { - id: { - type: DataTypes.UUID, - defaultValue: DataTypes.UUIDV4, - primaryKey: true, - allowNull: false, - }, - email: { - type: new DataTypes.STRING(), - allowNull: false, - unique: true, - }, - first_name: { - type: new DataTypes.STRING(), - allowNull: false, - }, - last_name: { - type: new DataTypes.STRING(), - allowNull: false, - }, - password: { - type: new DataTypes.STRING(), - allowNull: false, - }, - role: { - type: new DataTypes.STRING(), - allowNull: false, - }, - }, - { - tableName: "worker", - sequelize: sequelizeConnection, - } - ); -}; - -export default Worker;