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.
62 lines
2.1 KiB
JavaScript
62 lines
2.1 KiB
JavaScript
/* eslint-disable */
|
|
'use strict';
|
|
|
|
module.exports = {
|
|
async up(queryInterface) {
|
|
// Sprache / Set, das geteilt werden kann
|
|
await queryInterface.sequelize.query(`
|
|
CREATE TABLE IF NOT EXISTS community.vocab_language (
|
|
id SERIAL PRIMARY KEY,
|
|
owner_user_id INTEGER NOT NULL,
|
|
name TEXT NOT NULL,
|
|
share_code TEXT NOT NULL,
|
|
created_at TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT NOW(),
|
|
CONSTRAINT vocab_language_owner_fk
|
|
FOREIGN KEY (owner_user_id)
|
|
REFERENCES community."user"(id)
|
|
ON DELETE CASCADE,
|
|
CONSTRAINT vocab_language_share_code_uniq UNIQUE (share_code)
|
|
);
|
|
`);
|
|
|
|
// Abos (Freunde)
|
|
await queryInterface.sequelize.query(`
|
|
CREATE TABLE IF NOT EXISTS community.vocab_language_subscription (
|
|
id SERIAL PRIMARY KEY,
|
|
user_id INTEGER NOT NULL,
|
|
language_id INTEGER NOT NULL,
|
|
created_at TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT NOW(),
|
|
CONSTRAINT vocab_language_subscription_user_fk
|
|
FOREIGN KEY (user_id)
|
|
REFERENCES community."user"(id)
|
|
ON DELETE CASCADE,
|
|
CONSTRAINT vocab_language_subscription_language_fk
|
|
FOREIGN KEY (language_id)
|
|
REFERENCES community.vocab_language(id)
|
|
ON DELETE CASCADE,
|
|
CONSTRAINT vocab_language_subscription_uniq UNIQUE (user_id, language_id)
|
|
);
|
|
`);
|
|
|
|
await queryInterface.sequelize.query(`
|
|
CREATE INDEX IF NOT EXISTS vocab_language_owner_idx
|
|
ON community.vocab_language(owner_user_id);
|
|
`);
|
|
await queryInterface.sequelize.query(`
|
|
CREATE INDEX IF NOT EXISTS vocab_language_subscription_user_idx
|
|
ON community.vocab_language_subscription(user_id);
|
|
`);
|
|
await queryInterface.sequelize.query(`
|
|
CREATE INDEX IF NOT EXISTS vocab_language_subscription_language_idx
|
|
ON community.vocab_language_subscription(language_id);
|
|
`);
|
|
},
|
|
|
|
async down(queryInterface) {
|
|
await queryInterface.sequelize.query(`DROP TABLE IF EXISTS community.vocab_language_subscription;`);
|
|
await queryInterface.sequelize.query(`DROP TABLE IF EXISTS community.vocab_language;`);
|
|
}
|
|
};
|
|
|
|
|