chore: Unify backend express project into ESM (#281)

This commit is contained in:
kimatata
2025-09-15 22:46:46 +09:00
committed by GitHub
parent 72fd3af24f
commit 761869736e
83 changed files with 2129 additions and 2328 deletions

View File

@@ -1,46 +1,41 @@
'use strict';
export async function up(queryInterface, Sequelize) {
await queryInterface.createTable('users', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true,
},
email: {
type: Sequelize.STRING,
allowNull: false,
unique: true,
},
password: {
type: Sequelize.STRING,
allowNull: false,
},
username: {
type: Sequelize.STRING,
allowNull: false,
},
role: {
type: Sequelize.INTEGER,
allowNull: false,
},
avatarPath: {
type: Sequelize.STRING,
},
createdAt: {
type: Sequelize.DATE,
allowNull: false,
},
updatedAt: {
type: Sequelize.DATE,
allowNull: false,
},
});
}
/** @type {import('sequelize-cli').Migration} */
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('users', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true,
},
email: {
type: Sequelize.STRING,
allowNull: false,
unique: true,
},
password: {
type: Sequelize.STRING,
allowNull: false,
},
username: {
type: Sequelize.STRING,
allowNull: false,
},
role: {
type: Sequelize.INTEGER,
allowNull: false,
},
avatarPath: {
type: Sequelize.STRING,
},
createdAt: {
type: Sequelize.DATE,
allowNull: false,
},
updatedAt: {
type: Sequelize.DATE,
allowNull: false,
},
});
},
down: async (queryInterface) => {
await queryInterface.dropTable('users');
},
};
export async function down(queryInterface) {
await queryInterface.dropTable('users');
}

View File

@@ -1,48 +1,43 @@
'use strict';
export async function up(queryInterface, Sequelize) {
await queryInterface.createTable('projects', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true,
},
name: {
type: Sequelize.STRING,
allowNull: false,
},
detail: {
type: Sequelize.STRING,
allowNull: true,
},
isPublic: {
type: Sequelize.BOOLEAN,
allowNull: false,
},
userId: {
type: Sequelize.INTEGER,
allowNull: false,
references: {
model: 'users',
key: 'id',
onDelete: 'CASCADE',
onUpdate: 'CASCADE',
},
},
createdAt: {
type: Sequelize.DATE,
allowNull: false,
},
updatedAt: {
type: Sequelize.DATE,
allowNull: false,
},
});
}
/** @type {import('sequelize-cli').Migration} */
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('projects', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true,
},
name: {
type: Sequelize.STRING,
allowNull: false,
},
detail: {
type: Sequelize.STRING,
allowNull: true,
},
isPublic: {
type: Sequelize.BOOLEAN,
allowNull: false,
},
userId: {
type: Sequelize.INTEGER,
allowNull: false,
references: {
model: 'users',
key: 'id',
onDelete: 'CASCADE',
onUpdate: 'CASCADE',
},
},
createdAt: {
type: Sequelize.DATE,
allowNull: false,
},
updatedAt: {
type: Sequelize.DATE,
allowNull: false,
},
});
},
down: async (queryInterface) => {
await queryInterface.dropTable('projects');
},
};
export async function down(queryInterface) {
await queryInterface.dropTable('projects');
}

View File

@@ -1,48 +1,43 @@
'use strict';
export async function up(queryInterface, Sequelize) {
await queryInterface.createTable('folders', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true,
},
name: {
type: Sequelize.STRING,
allowNull: false,
},
detail: {
type: Sequelize.STRING,
allowNull: true,
},
parentFolderId: {
type: Sequelize.INTEGER,
allowNull: true,
},
projectId: {
type: Sequelize.INTEGER,
allowNull: false,
references: {
model: 'projects',
key: 'id',
onDelete: 'CASCADE',
onUpdate: 'CASCADE',
},
},
createdAt: {
type: Sequelize.DATE,
allowNull: false,
},
updatedAt: {
type: Sequelize.DATE,
allowNull: false,
},
});
}
/** @type {import('sequelize-cli').Migration} */
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('folders', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true,
},
name: {
type: Sequelize.STRING,
allowNull: false,
},
detail: {
type: Sequelize.STRING,
allowNull: true,
},
parentFolderId: {
type: Sequelize.INTEGER,
allowNull: true,
},
projectId: {
type: Sequelize.INTEGER,
allowNull: false,
references: {
model: 'projects',
key: 'id',
onDelete: 'CASCADE',
onUpdate: 'CASCADE',
},
},
createdAt: {
type: Sequelize.DATE,
allowNull: false,
},
updatedAt: {
type: Sequelize.DATE,
allowNull: false,
},
});
},
async down(queryInterface) {
await queryInterface.dropTable('folders');
},
};
export async function down(queryInterface) {
await queryInterface.dropTable('folders');
}

View File

@@ -1,52 +1,47 @@
'use strict';
export async function up(queryInterface, Sequelize) {
await queryInterface.createTable('runs', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true,
},
name: {
type: Sequelize.STRING,
allowNull: false,
},
configurations: {
type: Sequelize.STRING,
allowNull: true,
},
description: {
type: Sequelize.STRING,
allowNull: true,
},
state: {
type: Sequelize.INTEGER,
allowNull: true,
},
projectId: {
type: Sequelize.INTEGER,
allowNull: false,
references: {
model: 'projects',
key: 'id',
},
onUpdate: 'CASCADE',
onDelete: 'CASCADE',
},
createdAt: {
allowNull: false,
type: Sequelize.DATE,
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE,
},
});
}
/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.createTable('runs', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true,
},
name: {
type: Sequelize.STRING,
allowNull: false,
},
configurations: {
type: Sequelize.STRING,
allowNull: true,
},
description: {
type: Sequelize.STRING,
allowNull: true,
},
state: {
type: Sequelize.INTEGER,
allowNull: true,
},
projectId: {
type: Sequelize.INTEGER,
allowNull: false,
references: {
model: 'projects',
key: 'id',
},
onUpdate: 'CASCADE',
onDelete: 'CASCADE',
},
createdAt: {
allowNull: false,
type: Sequelize.DATE,
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE,
},
});
},
async down(queryInterface) {
await queryInterface.dropTable('runs');
},
};
export async function down(queryInterface) {
await queryInterface.dropTable('runs');
}

View File

@@ -1,72 +1,67 @@
'use strict';
export async function up(queryInterface, Sequelize) {
await queryInterface.createTable('cases', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true,
},
folderId: {
type: Sequelize.INTEGER,
allowNull: false,
references: {
model: 'folders',
key: 'id',
},
onUpdate: 'CASCADE',
onDelete: 'CASCADE',
},
title: {
type: Sequelize.STRING,
allowNull: false,
},
state: {
type: Sequelize.INTEGER,
allowNull: false,
},
priority: {
type: Sequelize.INTEGER,
allowNull: false,
},
type: {
type: Sequelize.INTEGER,
allowNull: false,
},
automationStatus: {
type: Sequelize.INTEGER,
allowNull: false,
},
description: {
type: Sequelize.STRING,
allowNull: true,
},
template: {
type: Sequelize.INTEGER,
allowNull: false,
},
preConditions: {
type: Sequelize.STRING,
allowNull: true,
},
expectedResults: {
type: Sequelize.STRING,
allowNull: true,
},
createdAt: {
allowNull: false,
type: Sequelize.DATE,
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE,
},
});
}
/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.createTable('cases', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true,
},
folderId: {
type: Sequelize.INTEGER,
allowNull: false,
references: {
model: 'folders',
key: 'id',
},
onUpdate: 'CASCADE',
onDelete: 'CASCADE',
},
title: {
type: Sequelize.STRING,
allowNull: false,
},
state: {
type: Sequelize.INTEGER,
allowNull: false,
},
priority: {
type: Sequelize.INTEGER,
allowNull: false,
},
type: {
type: Sequelize.INTEGER,
allowNull: false,
},
automationStatus: {
type: Sequelize.INTEGER,
allowNull: false,
},
description: {
type: Sequelize.STRING,
allowNull: true,
},
template: {
type: Sequelize.INTEGER,
allowNull: false,
},
preConditions: {
type: Sequelize.STRING,
allowNull: true,
},
expectedResults: {
type: Sequelize.STRING,
allowNull: true,
},
createdAt: {
allowNull: false,
type: Sequelize.DATE,
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE,
},
});
},
async down(queryInterface) {
await queryInterface.dropTable('cases');
},
};
export async function down(queryInterface) {
await queryInterface.dropTable('cases');
}

View File

@@ -1,34 +1,29 @@
'use strict';
export async function up(queryInterface, Sequelize) {
await queryInterface.createTable('steps', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true,
},
step: {
type: Sequelize.STRING,
allowNull: false,
},
result: {
type: Sequelize.STRING,
allowNull: false,
},
createdAt: {
type: Sequelize.DATE,
allowNull: false,
},
updatedAt: {
type: Sequelize.DATE,
allowNull: false,
},
});
}
/** @type {import('sequelize-cli').Migration} */
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('steps', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true,
},
step: {
type: Sequelize.STRING,
allowNull: false,
},
result: {
type: Sequelize.STRING,
allowNull: false,
},
createdAt: {
type: Sequelize.DATE,
allowNull: false,
},
updatedAt: {
type: Sequelize.DATE,
allowNull: false,
},
});
},
down: async (queryInterface) => {
await queryInterface.dropTable('steps');
},
};
export async function down(queryInterface) {
await queryInterface.dropTable('steps');
}

View File

@@ -1,52 +1,47 @@
'use strict';
export async function up(queryInterface, Sequelize) {
await queryInterface.createTable('caseSteps', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true,
},
caseId: {
type: Sequelize.INTEGER,
references: {
model: 'cases',
key: 'id',
},
onUpdate: 'CASCADE',
onDelete: 'CASCADE',
},
stepId: {
type: Sequelize.INTEGER,
references: {
model: 'steps',
key: 'id',
},
onUpdate: 'CASCADE',
onDelete: 'CASCADE',
},
stepNo: {
type: Sequelize.INTEGER,
allowNull: false,
},
createdAt: {
type: Sequelize.DATE,
allowNull: false,
},
updatedAt: {
type: Sequelize.DATE,
allowNull: false,
},
});
/** @type {import('sequelize-cli').Migration} */
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('caseSteps', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true,
},
caseId: {
type: Sequelize.INTEGER,
references: {
model: 'cases',
key: 'id',
},
onUpdate: 'CASCADE',
onDelete: 'CASCADE',
},
stepId: {
type: Sequelize.INTEGER,
references: {
model: 'steps',
key: 'id',
},
onUpdate: 'CASCADE',
onDelete: 'CASCADE',
},
stepNo: {
type: Sequelize.INTEGER,
allowNull: false,
},
createdAt: {
type: Sequelize.DATE,
allowNull: false,
},
updatedAt: {
type: Sequelize.DATE,
allowNull: false,
},
});
await queryInterface.addIndex('caseSteps', ['caseId', 'stepId'], {
unique: true,
});
}
await queryInterface.addIndex('caseSteps', ['caseId', 'stepId'], {
unique: true,
});
},
down: async (queryInterface) => {
await queryInterface.dropTable('caseSteps');
},
};
export async function down(queryInterface) {
await queryInterface.dropTable('caseSteps');
}

View File

@@ -1,38 +1,33 @@
'use strict';
export async function up(queryInterface, Sequelize) {
await queryInterface.createTable('attachments', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true,
},
title: {
type: Sequelize.STRING,
allowNull: false,
},
detail: {
type: Sequelize.STRING,
allowNull: true,
},
path: {
type: Sequelize.STRING,
allowNull: false,
},
createdAt: {
allowNull: false,
type: Sequelize.DATE,
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE,
},
});
}
/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.createTable('attachments', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true,
},
title: {
type: Sequelize.STRING,
allowNull: false,
},
detail: {
type: Sequelize.STRING,
allowNull: true,
},
path: {
type: Sequelize.STRING,
allowNull: false,
},
createdAt: {
allowNull: false,
type: Sequelize.DATE,
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE,
},
});
},
async down(queryInterface) {
await queryInterface.dropTable('attachments');
},
};
export async function down(queryInterface) {
await queryInterface.dropTable('attachments');
}

View File

@@ -1,48 +1,43 @@
'use strict';
export async function up(queryInterface, Sequelize) {
await queryInterface.createTable('caseAttachments', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true,
},
caseId: {
type: Sequelize.INTEGER,
references: {
model: 'cases',
key: 'id',
},
onUpdate: 'CASCADE',
onDelete: 'CASCADE',
},
attachmentId: {
type: Sequelize.INTEGER,
references: {
model: 'attachments',
key: 'id',
},
onUpdate: 'CASCADE',
onDelete: 'CASCADE',
},
createdAt: {
type: Sequelize.DATE,
allowNull: false,
},
updatedAt: {
type: Sequelize.DATE,
allowNull: false,
},
});
/** @type {import('sequelize-cli').Migration} */
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('caseAttachments', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true,
},
caseId: {
type: Sequelize.INTEGER,
references: {
model: 'cases',
key: 'id',
},
onUpdate: 'CASCADE',
onDelete: 'CASCADE',
},
attachmentId: {
type: Sequelize.INTEGER,
references: {
model: 'attachments',
key: 'id',
},
onUpdate: 'CASCADE',
onDelete: 'CASCADE',
},
createdAt: {
type: Sequelize.DATE,
allowNull: false,
},
updatedAt: {
type: Sequelize.DATE,
allowNull: false,
},
});
await queryInterface.addIndex('caseAttachments', ['caseId', 'attachmentId'], {
unique: true,
});
}
await queryInterface.addIndex('caseAttachments', ['caseId', 'attachmentId'], {
unique: true,
});
},
down: async (queryInterface) => {
await queryInterface.dropTable('caseAttachments');
},
};
export async function down(queryInterface) {
await queryInterface.dropTable('caseAttachments');
}

View File

@@ -1,52 +1,47 @@
'use strict';
export async function up(queryInterface, Sequelize) {
await queryInterface.createTable('runCases', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true,
},
runId: {
type: Sequelize.INTEGER,
references: {
model: 'runs',
key: 'id',
},
onUpdate: 'CASCADE',
onDelete: 'CASCADE',
},
caseId: {
type: Sequelize.INTEGER,
references: {
model: 'cases',
key: 'id',
},
onUpdate: 'CASCADE',
onDelete: 'CASCADE',
},
status: {
type: Sequelize.INTEGER,
allowNull: false,
},
createdAt: {
type: Sequelize.DATE,
allowNull: false,
},
updatedAt: {
type: Sequelize.DATE,
allowNull: false,
},
});
/** @type {import('sequelize-cli').Migration} */
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('runCases', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true,
},
runId: {
type: Sequelize.INTEGER,
references: {
model: 'runs',
key: 'id',
},
onUpdate: 'CASCADE',
onDelete: 'CASCADE',
},
caseId: {
type: Sequelize.INTEGER,
references: {
model: 'cases',
key: 'id',
},
onUpdate: 'CASCADE',
onDelete: 'CASCADE',
},
status: {
type: Sequelize.INTEGER,
allowNull: false,
},
createdAt: {
type: Sequelize.DATE,
allowNull: false,
},
updatedAt: {
type: Sequelize.DATE,
allowNull: false,
},
});
await queryInterface.addIndex('runCases', ['runId', 'caseId'], {
unique: true,
});
}
await queryInterface.addIndex('runCases', ['runId', 'caseId'], {
unique: true,
});
},
down: async (queryInterface) => {
await queryInterface.dropTable('runCases');
},
};
export async function down(queryInterface) {
await queryInterface.dropTable('runCases');
}

View File

@@ -1,52 +1,47 @@
'use strict';
export async function up(queryInterface, Sequelize) {
await queryInterface.createTable('members', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true,
},
userId: {
type: Sequelize.INTEGER,
references: {
model: 'users',
key: 'id',
},
onUpdate: 'CASCADE',
onDelete: 'CASCADE',
},
projectId: {
type: Sequelize.INTEGER,
references: {
model: 'projects',
key: 'id',
},
onUpdate: 'CASCADE',
onDelete: 'CASCADE',
},
role: {
type: Sequelize.INTEGER,
allowNull: false,
},
createdAt: {
type: Sequelize.DATE,
allowNull: false,
},
updatedAt: {
type: Sequelize.DATE,
allowNull: false,
},
});
/** @type {import('sequelize-cli').Migration} */
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('members', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true,
},
userId: {
type: Sequelize.INTEGER,
references: {
model: 'users',
key: 'id',
},
onUpdate: 'CASCADE',
onDelete: 'CASCADE',
},
projectId: {
type: Sequelize.INTEGER,
references: {
model: 'projects',
key: 'id',
},
onUpdate: 'CASCADE',
onDelete: 'CASCADE',
},
role: {
type: Sequelize.INTEGER,
allowNull: false,
},
createdAt: {
type: Sequelize.DATE,
allowNull: false,
},
updatedAt: {
type: Sequelize.DATE,
allowNull: false,
},
});
await queryInterface.addIndex('members', ['userId', 'projectId'], {
unique: true,
});
}
await queryInterface.addIndex('members', ['userId', 'projectId'], {
unique: true,
});
},
down: async (queryInterface) => {
await queryInterface.dropTable('members');
},
};
export async function down(queryInterface) {
await queryInterface.dropTable('members');
}

View File

@@ -1,26 +1,21 @@
'use strict';
export async function up(queryInterface) {
/**
* Add altering commands here.
*
* Example:
* await queryInterface.createTable('users', { id: Sequelize.INTEGER });
*/
/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up(queryInterface) {
/**
* Add altering commands here.
*
* Example:
* await queryInterface.createTable('users', { id: Sequelize.INTEGER });
*/
await queryInterface.renameColumn('users', 'createdAt', 'created_at');
await queryInterface.renameColumn('users', 'updatedAt', 'updated_at');
await queryInterface.renameColumn('users', 'avatarPath', 'avatar_path');
}
await queryInterface.renameColumn('users', 'createdAt', 'created_at');
await queryInterface.renameColumn('users', 'updatedAt', 'updated_at');
await queryInterface.renameColumn('users', 'avatarPath', 'avatar_path');
},
async down() {
/**
* Add reverting commands here.
*
* Example:
* await queryInterface.dropTable('users');
*/
},
};
export async function down() {
/**
* Add reverting commands here.
*
* Example:
* await queryInterface.dropTable('users');
*/
}

View File

@@ -1,13 +1,9 @@
'use strict';
export async function up(queryInterface) {
// Rename column 'path' to 'filename' in 'Attachments' table
await queryInterface.renameColumn('Attachments', 'path', 'filename');
}
module.exports = {
up: async (queryInterface) => {
// Rename column 'path' to 'filename' in 'Attachments' table
await queryInterface.renameColumn('Attachments', 'path', 'filename');
},
down: async (queryInterface) => {
// Revert column name from 'filename' back to 'path'
await queryInterface.renameColumn('Attachments', 'filename', 'path');
},
};
export async function down(queryInterface) {
// Revert column name from 'filename' back to 'path'
await queryInterface.renameColumn('Attachments', 'filename', 'path');
}

View File

@@ -1,22 +1,17 @@
'use strict';
export async function up(queryInterface) {
await queryInterface.addConstraint('folders', {
fields: ['parentFolderId'],
type: 'foreign key',
name: 'fk_folders_parentFolderId',
references: {
table: 'folders',
field: 'id',
},
onDelete: 'CASCADE',
onUpdate: 'CASCADE',
});
}
/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up(queryInterface) {
await queryInterface.addConstraint('folders', {
fields: ['parentFolderId'],
type: 'foreign key',
name: 'fk_folders_parentFolderId',
references: {
table: 'folders',
field: 'id',
},
onDelete: 'CASCADE',
onUpdate: 'CASCADE',
});
},
async down(queryInterface) {
await queryInterface.removeConstraint('folders', 'fk_folders_parentFolderId');
},
};
export async function down(queryInterface) {
await queryInterface.removeConstraint('folders', 'fk_folders_parentFolderId');
}