From eca4f437387d2de5de13b576cf1c2fc947953e0d Mon Sep 17 00:00:00 2001 From: Roman Kuzovlev Date: Thu, 22 Sep 2022 22:24:49 +0300 Subject: [PATCH 1/5] Actual seeders --- src/seeders/001-data-types.js | 14 ++++ src/seeders/002-properties.js | 127 ++++++++++++++++++++++++++++++++-- 2 files changed, 134 insertions(+), 7 deletions(-) diff --git a/src/seeders/001-data-types.js b/src/seeders/001-data-types.js index 9ae9778..ce5f439 100644 --- a/src/seeders/001-data-types.js +++ b/src/seeders/001-data-types.js @@ -1,7 +1,9 @@ +const { Op } = require("sequelize"); 'use strict'; module.exports = { async up (queryInterface, Sequelize) { + await queryInterface.bulkDelete('DataTypes', {}, {}, true); queryInterface.bulkInsert('DataTypes', [{ id: 1, name: 'JULIAN_DATE', @@ -19,6 +21,18 @@ module.exports = { name: 'GEO_POINT', createdAt: new Date(), updatedAt: new Date() + }, + { + id: 4, + name: 'FILE', + createdAt: new Date(), + updatedAt: new Date() + }, + { + id: 5, + name: 'RICH_TEXT', + createdAt: new Date(), + updatedAt: new Date() }]); }, diff --git a/src/seeders/002-properties.js b/src/seeders/002-properties.js index 2ba6580..7e95cf3 100644 --- a/src/seeders/002-properties.js +++ b/src/seeders/002-properties.js @@ -2,16 +2,17 @@ module.exports = { async up (queryInterface, Sequelize) { + await queryInterface.bulkDelete('Properties', {}, {}, true); queryInterface.bulkInsert('Properties', [{ id: 1, - dataTypeId: 2, + dataTypeId: 1, name: 'julianDate', createdAt: new Date(), updatedAt: new Date(), isLink: false },{ id: 2, - dataTypeId: 2, + dataTypeId: 5, name: 'address', createdAt: new Date(), updatedAt: new Date(), @@ -19,7 +20,7 @@ module.exports = { }, { id: 3, - dataTypeId: 2, + dataTypeId: 5, name: 'artisticText', createdAt: new Date(), updatedAt: new Date(), @@ -35,7 +36,7 @@ module.exports = { }, { id: 5, - dataTypeId: 2, + dataTypeId: 5, name: 'annotation', createdAt: new Date(), updatedAt: new Date(), @@ -43,7 +44,7 @@ module.exports = { }, { id: 6, - dataTypeId: 2, + dataTypeId: 5, name: 'quote', createdAt: new Date(), updatedAt: new Date(), @@ -59,7 +60,7 @@ module.exports = { }, { id: 8, - dataTypeId: 2, + dataTypeId: 5, name: 'sources', createdAt: new Date(), updatedAt: new Date(), @@ -67,11 +68,123 @@ module.exports = { }, { id: 9, - dataTypeId: 2, + dataTypeId: 3, name: 'geoPoint', createdAt: new Date(), updatedAt: new Date(), isLink: false + }, + { + id: 10, + dataTypeId: 4, + name: 'media', + createdAt: new Date(), + updatedAt: new Date(), + isLink: false + }, + { + id: 11, + dataTypeId: 5, + name: 'creator', + createdAt: new Date(), + updatedAt: new Date(), + isLink: false + }, + { + id: 12, + dataTypeId: 5, + name: 'creationPlace', + createdAt: new Date(), + updatedAt: new Date(), + isLink: false + }, + { + id: 13, + dataTypeId: 5, + name: 'copyrightHolder', + createdAt: new Date(), + updatedAt: new Date(), + isLink: false + }, + { + id: 14, + dataTypeId: 5, + name: 'originalText', + createdAt: new Date(), + updatedAt: new Date(), + isLink: false + }, + { + id: 15, + dataTypeId: 5, + name: 'bibliography', + createdAt: new Date(), + updatedAt: new Date(), + isLink: false + }, + { + id: 16, + dataTypeId: 5, + name: 'refutation', + createdAt: new Date(), + updatedAt: new Date(), + isLink: false + }, + { + id: 17, + dataTypeId: 5, + name: 'url', + createdAt: new Date(), + updatedAt: new Date(), + isLink: false + }, + { + id: 18, + dataTypeId: 5, + name: 'participants', + createdAt: new Date(), + updatedAt: new Date(), + isLink: false + }, + { + id: 19, + dataTypeId: 5, + name: 'family', + createdAt: new Date(), + updatedAt: new Date(), + isLink: false + }, + { + id: 20, + dataTypeId: 5, + name: 'profession', + createdAt: new Date(), + updatedAt: new Date(), + isLink: false + }, + { + id: 21, + dataTypeId: 5, + name: 'format', + createdAt: new Date(), + updatedAt: new Date(), + isLink: false + }, + { + id: 22, + dataTypeId: 5, + name: 'storage', + createdAt: new Date(), + updatedAt: new Date(), + isLink: false + }, + { + id: 23, + dataTypeId: 5, + name: 'socialNetworks', + createdAt: new Date(), + updatedAt: new Date(), + isLink: false }]); }, From b818575950a3de2f6ef61b8ea8c16a81d41eb143 Mon Sep 17 00:00:00 2001 From: Roman Kuzovlev Date: Fri, 23 Sep 2022 17:16:53 +0300 Subject: [PATCH 2/5] Split of seed and undo functions --- src/seeders/001-data-types.js | 9 ++------- src/seeders/002-properties.js | 9 ++------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/src/seeders/001-data-types.js b/src/seeders/001-data-types.js index ce5f439..f4bf0b5 100644 --- a/src/seeders/001-data-types.js +++ b/src/seeders/001-data-types.js @@ -3,7 +3,6 @@ const { Op } = require("sequelize"); module.exports = { async up (queryInterface, Sequelize) { - await queryInterface.bulkDelete('DataTypes', {}, {}, true); queryInterface.bulkInsert('DataTypes', [{ id: 1, name: 'JULIAN_DATE', @@ -37,11 +36,7 @@ module.exports = { }, async down (queryInterface, Sequelize) { - /** - * Add commands to revert seed here. - * - * Example: - * await queryInterface.bulkDelete('People', null, {}); - */ + // Осторожно: удаляет все содержимое таблицы. + await queryInterface.bulkDelete('DataTypes', {}, {}, true); } }; diff --git a/src/seeders/002-properties.js b/src/seeders/002-properties.js index 7e95cf3..1fccc6d 100644 --- a/src/seeders/002-properties.js +++ b/src/seeders/002-properties.js @@ -2,7 +2,6 @@ module.exports = { async up (queryInterface, Sequelize) { - await queryInterface.bulkDelete('Properties', {}, {}, true); queryInterface.bulkInsert('Properties', [{ id: 1, dataTypeId: 1, @@ -189,11 +188,7 @@ module.exports = { }, async down (queryInterface, Sequelize) { - /** - * Add commands to revert seed here. - * - * Example: - * await queryInterface.bulkDelete('People', null, {}); - */ + // Осторожно: удаляет все содержимое таблицы. + await queryInterface.bulkDelete('Properties', {}, {}, true); } }; From 10a24ae8b177bac8d9cf444681d240eac79e6d7a Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 5 Oct 2022 11:44:18 +0600 Subject: [PATCH 3/5] now works in docker container + small fix --- .sequelizerc | 2 +- src/seeders/003-user-roles.js | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/.sequelizerc b/.sequelizerc index 38f0cf0..57f1e5c 100644 --- a/.sequelizerc +++ b/.sequelizerc @@ -1,7 +1,7 @@ const path = require('path') module.exports = { - 'config': path.resolve('src', 'configs/db.mjs'), + 'config': path.resolve('dist', 'configs/db.js'), 'models-path': path.resolve('src', 'models'), 'seeders-path': path.resolve('src', 'seeders'), 'migrations-path': path.resolve('src', 'migrations') diff --git a/src/seeders/003-user-roles.js b/src/seeders/003-user-roles.js index f5bb967..6e80986 100644 --- a/src/seeders/003-user-roles.js +++ b/src/seeders/003-user-roles.js @@ -26,11 +26,7 @@ module.exports = { }, async down (queryInterface, Sequelize) { - /** - * Add commands to revert seed here. - * - * Example: - * await queryInterface.bulkDelete('People', null, {}); - */ + // Осторожно: удаляет все содержимое таблицы. + await queryInterface.bulkDelete('Properties', {}, {}, true); } }; From 01c2b2ab902b1587bc6e61bf2fe124097a2f65ae Mon Sep 17 00:00:00 2001 From: Roman Kuzovlev <98535356+RomanKuzovlev@users.noreply.github.com> Date: Wed, 5 Oct 2022 11:45:13 +0600 Subject: [PATCH 4/5] Update 003-user-roles.js --- src/seeders/003-user-roles.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/seeders/003-user-roles.js b/src/seeders/003-user-roles.js index 6e80986..1d1b111 100644 --- a/src/seeders/003-user-roles.js +++ b/src/seeders/003-user-roles.js @@ -27,6 +27,6 @@ module.exports = { async down (queryInterface, Sequelize) { // Осторожно: удаляет все содержимое таблицы. - await queryInterface.bulkDelete('Properties', {}, {}, true); + await queryInterface.bulkDelete('UserRoles', {}, {}, true); } }; From 36ad98cd5086bfbd8334610b3d30cd9b3482a2cd Mon Sep 17 00:00:00 2001 From: Roman Kuzovlev <98535356+RomanKuzovlev@users.noreply.github.com> Date: Wed, 5 Oct 2022 14:11:23 +0600 Subject: [PATCH 5/5] Update 003-user-roles.js --- src/seeders/003-user-roles.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/seeders/003-user-roles.js b/src/seeders/003-user-roles.js index 1d1b111..d311ddd 100644 --- a/src/seeders/003-user-roles.js +++ b/src/seeders/003-user-roles.js @@ -18,6 +18,13 @@ module.exports = { }, { id: 3, + name: 'AUTHOR', + key: 'AUTHOR', + createdAt: new Date(), + updatedAt: new Date() + }, + { + id: 4, name: 'USER', key: 'USER', createdAt: new Date(),