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
|
||||
},
|
||||
name: {
|
||||
type: DataTypes.STRING,
|
||||
type: Sequelize.STRING,
|
||||
allowNull: false,
|
||||
unique: true
|
||||
},
|
||||
abbreviation: {
|
||||
type: DataTypes.STRING,
|
||||
type: Sequelize.STRING,
|
||||
allowNull: false
|
||||
},
|
||||
description: {
|
||||
type: DataTypes.STRING,
|
||||
type: Sequelize.STRING,
|
||||
allowNull: false
|
||||
},
|
||||
createdAt: {
|
||||
|
|
|
|||
|
|
@ -48,22 +48,6 @@ module.exports = {
|
|||
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*/) {
|
||||
await queryInterface.dropTable('Players');
|
||||
|
|
@ -9,12 +9,12 @@ module.exports = {
|
|||
type: Sequelize.INTEGER
|
||||
},
|
||||
name: {
|
||||
type: DataTypes.STRING,
|
||||
type: Sequelize.STRING,
|
||||
allowNull: false,
|
||||
unique: true
|
||||
},
|
||||
description: {
|
||||
type: DataTypes.STRING,
|
||||
type: Sequelize.STRING,
|
||||
allowNull: false
|
||||
},
|
||||
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