Files
outline/server/migrations/20220402032204-starred-collections.js
T
codegen-sh[bot] 97f8d0f265 Separate Prettier and ESLint according to best practices (#9565)
* Separate Prettier and ESLint according to best practices

- Create standalone .prettierrc configuration file
- Remove eslint-plugin-prettier integration from ESLint config
- Replace with eslint-config-prettier to disable conflicting rules
- Remove eslint-plugin-prettier dependency
- Add dedicated format and format:check scripts
- Update lint-staged to run Prettier and ESLint separately
- Format entire codebase with new Prettier configuration

This follows the recommended approach from Prettier documentation:
https://prettier.io/docs/integrating-with-linters#notes

* Remove test comment

---------

Co-authored-by: codegen-sh[bot] <131295404+codegen-sh[bot]@users.noreply.github.com>
2025-07-08 18:01:48 -04:00

55 lines
1.5 KiB
JavaScript

"use strict";
module.exports = {
up: async (queryInterface, Sequelize) => {
// Previously there was no onDelete cascade so there may be existing stars
// in the db that reference documents that no longer exist. We must clean
// these up first before applying the new constraint.
await queryInterface.sequelize.query(`
DELETE FROM stars
WHERE NOT EXISTS (
SELECT NULL
FROM documents doc
WHERE doc.id = "documentId"
)
`);
await queryInterface.addColumn("stars", "collectionId", {
type: Sequelize.UUID,
allowNull: true,
references: {
model: "collections",
},
});
await queryInterface.changeColumn("stars", "documentId", {
type: Sequelize.UUID,
allowNull: true,
});
await queryInterface.changeColumn("stars", "documentId", {
type: Sequelize.UUID,
onDelete: "cascade",
references: {
model: "documents",
},
});
await queryInterface.changeColumn("stars", "userId", {
type: Sequelize.UUID,
allowNull: false,
onDelete: "cascade",
references: {
model: "users",
},
});
},
down: async (queryInterface, Sequelize) => {
await queryInterface.removeColumn("stars", "collectionId");
await queryInterface.changeColumn("stars", "documentId", {
type: Sequelize.UUID,
allowNull: false,
});
await queryInterface.removeConstraint("stars", "stars_documentId_fkey");
await queryInterface.removeConstraint("stars", "stars_userId_fkey");
},
};