Using Table and column naming convention (#68)
* feat(backend): using sqlstyle naming conventions * fix: using sql conventions
This commit is contained in:
26
backend/migrations/20240930124156-rename_table.js
Normal file
26
backend/migrations/20240930124156-rename_table.js
Normal file
@@ -0,0 +1,26 @@
|
||||
'use strict';
|
||||
|
||||
/** @type {import('sequelize-cli').Migration} */
|
||||
module.exports = {
|
||||
async up (queryInterface, Sequelize) {
|
||||
/**
|
||||
* 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');
|
||||
},
|
||||
|
||||
async down (queryInterface, Sequelize) {
|
||||
/**
|
||||
* Add reverting commands here.
|
||||
*
|
||||
* Example:
|
||||
* await queryInterface.dropTable('users');
|
||||
*/
|
||||
}
|
||||
};
|
||||
@@ -1,3 +1,9 @@
|
||||
/**
|
||||
*
|
||||
* @param {import('sequelize').Sequelize} sequelize
|
||||
* @param {*} DataTypes
|
||||
* @returns
|
||||
*/
|
||||
function defineUser(sequelize, DataTypes) {
|
||||
const User = sequelize.define('User', {
|
||||
email: {
|
||||
@@ -20,7 +26,7 @@ function defineUser(sequelize, DataTypes) {
|
||||
avatarPath: {
|
||||
type: DataTypes.STRING,
|
||||
},
|
||||
});
|
||||
}, { underscored: true });
|
||||
|
||||
User.associate = (models) => {
|
||||
User.hasMany(models.Project, { foreignKey: 'userId' });
|
||||
|
||||
Reference in New Issue
Block a user