extract creating of player table into a separate migration file
This commit is contained in:
parent
b40824c3e5
commit
3d8bb3f40e
|
|
@ -9,16 +9,16 @@ module.exports = {
|
||||||
type: Sequelize.INTEGER
|
type: Sequelize.INTEGER
|
||||||
},
|
},
|
||||||
name: {
|
name: {
|
||||||
type: DataTypes.STRING,
|
type: Sequelize.STRING,
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
unique: true
|
unique: true
|
||||||
},
|
},
|
||||||
abbreviation: {
|
abbreviation: {
|
||||||
type: DataTypes.STRING,
|
type: Sequelize.STRING,
|
||||||
allowNull: false
|
allowNull: false
|
||||||
},
|
},
|
||||||
description: {
|
description: {
|
||||||
type: DataTypes.STRING,
|
type: Sequelize.STRING,
|
||||||
allowNull: false
|
allowNull: false
|
||||||
},
|
},
|
||||||
createdAt: {
|
createdAt: {
|
||||||
|
|
|
||||||
|
|
@ -48,22 +48,6 @@ module.exports = {
|
||||||
type: Sequelize.DATE
|
type: Sequelize.DATE
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 2. Kopiere Daten von Users nach Players
|
|
||||||
await queryInterface.sequelize.query(`
|
|
||||||
INSERT INTO "Players" ("userId", "height", "weight", "gender", "bats", "throws", "createdAt", "updatedAt")
|
|
||||||
SELECT
|
|
||||||
"id" as "userId",
|
|
||||||
"height",
|
|
||||||
"weight",
|
|
||||||
"gender"::text::"enum_Players_gender",
|
|
||||||
"handedness"::text::"enum_Players_bats",
|
|
||||||
"handedness"::text::"enum_Players_throws",
|
|
||||||
"createdAt",
|
|
||||||
"updatedAt"
|
|
||||||
FROM "Users"
|
|
||||||
`);
|
|
||||||
|
|
||||||
},
|
},
|
||||||
async down(queryInterface, /*Sequelize*/) {
|
async down(queryInterface, /*Sequelize*/) {
|
||||||
await queryInterface.dropTable('Players');
|
await queryInterface.dropTable('Players');
|
||||||
|
|
@ -9,12 +9,12 @@ module.exports = {
|
||||||
type: Sequelize.INTEGER
|
type: Sequelize.INTEGER
|
||||||
},
|
},
|
||||||
name: {
|
name: {
|
||||||
type: DataTypes.STRING,
|
type: Sequelize.STRING,
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
unique: true
|
unique: true
|
||||||
},
|
},
|
||||||
description: {
|
description: {
|
||||||
type: DataTypes.STRING,
|
type: Sequelize.STRING,
|
||||||
allowNull: false
|
allowNull: false
|
||||||
},
|
},
|
||||||
createdAt: {
|
createdAt: {
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
/** @type {import('sequelize-cli').Migration} */
|
||||||
|
module.exports = {
|
||||||
|
async up(queryInterface, Sequelize) {
|
||||||
|
await queryInterface.sequelize.query(`
|
||||||
|
INSERT INTO "Players" ("userId", "height", "weight", "gender", "bats", "throws", "createdAt", "updatedAt")
|
||||||
|
SELECT
|
||||||
|
"id" as "userId",
|
||||||
|
"height",
|
||||||
|
"weight",
|
||||||
|
"gender"::text::"enum_Players_gender",
|
||||||
|
"handedness"::text::"enum_Players_bats",
|
||||||
|
"handedness"::text::"enum_Players_throws",
|
||||||
|
"createdAt",
|
||||||
|
"updatedAt"
|
||||||
|
FROM "Users"
|
||||||
|
`);
|
||||||
|
|
||||||
|
},
|
||||||
|
async down(queryInterface, /*Sequelize*/) {
|
||||||
|
await queryInterface.dropTable('Players');
|
||||||
|
}
|
||||||
|
};
|
||||||
Loading…
Reference in New Issue