feat(deploy): update deployment workflow and migration paths
Some checks failed
Deploy to production / deploy (push) Has been cancelled
Some checks failed
Deploy to production / deploy (push) Has been cancelled
- Modified the deployment workflow to include new migration paths for the backend, ensuring that migrations are correctly referenced in the deployment process. - Updated the `db:migrate` script in package.json to point to the `migrations-active` directory, enhancing clarity and organization of migration files. - Adjusted the deployment conditions to account for changes in migration file locations, improving the accuracy of change detection during deployments. - Removed obsolete migration files to streamline the migration process and prevent confusion.
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
up: async (queryInterface, Sequelize) => {
|
||||
await queryInterface.sequelize.query(`
|
||||
ALTER TABLE falukant_data.falukant_user
|
||||
ADD COLUMN IF NOT EXISTS last_political_daily_salary_on date NULL;
|
||||
`);
|
||||
|
||||
await queryInterface.sequelize.query(`
|
||||
DO $$
|
||||
BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'falukant_predefine'
|
||||
AND table_name = 'political_office_benefit'
|
||||
AND column_name = 'political_office_id'
|
||||
) AND NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'falukant_predefine'
|
||||
AND table_name = 'political_office_benefit'
|
||||
AND column_name = 'office_type_id'
|
||||
) THEN
|
||||
ALTER TABLE falukant_predefine.political_office_benefit
|
||||
RENAME COLUMN political_office_id TO office_type_id;
|
||||
ELSIF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'falukant_predefine'
|
||||
AND table_name = 'political_office_benefit'
|
||||
AND column_name = 'political_office_id'
|
||||
) AND EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'falukant_predefine'
|
||||
AND table_name = 'political_office_benefit'
|
||||
AND column_name = 'office_type_id'
|
||||
) THEN
|
||||
UPDATE falukant_predefine.political_office_benefit
|
||||
SET office_type_id = COALESCE(office_type_id, political_office_id);
|
||||
ALTER TABLE falukant_predefine.political_office_benefit
|
||||
DROP COLUMN political_office_id;
|
||||
END IF;
|
||||
END $$;
|
||||
`);
|
||||
},
|
||||
|
||||
down: async (queryInterface, Sequelize) => {
|
||||
await queryInterface.sequelize.query(`
|
||||
ALTER TABLE falukant_data.falukant_user
|
||||
DROP COLUMN IF EXISTS last_political_daily_salary_on;
|
||||
`);
|
||||
|
||||
await queryInterface.sequelize.query(`
|
||||
DO $$
|
||||
BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'falukant_predefine'
|
||||
AND table_name = 'political_office_benefit'
|
||||
AND column_name = 'office_type_id'
|
||||
) AND NOT EXISTS (
|
||||
SELECT 1 FROM information_schema.columns
|
||||
WHERE table_schema = 'falukant_predefine'
|
||||
AND table_name = 'political_office_benefit'
|
||||
AND column_name = 'political_office_id'
|
||||
) THEN
|
||||
ALTER TABLE falukant_predefine.political_office_benefit
|
||||
RENAME COLUMN office_type_id TO political_office_id;
|
||||
END IF;
|
||||
END $$;
|
||||
`);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user