Files
outline/server/migrations/20211221031430-create-pins.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

104 lines
2.3 KiB
JavaScript

"use strict";
const { v4 } = require("uuid");
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable("pins", {
id: {
type: Sequelize.UUID,
allowNull: false,
primaryKey: true,
},
documentId: {
type: Sequelize.UUID,
allowNull: false,
onDelete: "cascade",
references: {
model: "documents",
},
},
collectionId: {
type: Sequelize.UUID,
allowNull: true,
onDelete: "cascade",
references: {
model: "collections",
},
},
teamId: {
type: Sequelize.UUID,
allowNull: false,
onDelete: "cascade",
references: {
model: "teams",
},
},
createdById: {
type: Sequelize.UUID,
allowNull: false,
references: {
model: "users",
},
},
index: {
type: Sequelize.STRING,
allowNull: true,
},
createdAt: {
type: Sequelize.DATE,
allowNull: false,
},
updatedAt: {
type: Sequelize.DATE,
allowNull: false,
},
});
await queryInterface.addIndex("pins", ["collectionId"]);
const createdAt = new Date();
const [documents] = await queryInterface.sequelize.query(
`SELECT "id","collectionId","teamId","pinnedById" FROM documents WHERE "pinnedById" IS NOT NULL`
);
for (const document of documents) {
await queryInterface.sequelize.query(
`
INSERT INTO pins (
"id",
"documentId",
"collectionId",
"teamId",
"createdById",
"createdAt",
"updatedAt"
)
VALUES (
:id,
:documentId,
:collectionId,
:teamId,
:createdById,
:createdAt,
:updatedAt
)
`,
{
replacements: {
id: v4(),
documentId: document.id,
collectionId: document.collectionId,
teamId: document.teamId,
createdById: document.pinnedById,
updatedAt: createdAt,
createdAt,
},
}
);
}
},
down: async (queryInterface, Sequelize) => {
return queryInterface.dropTable("pins");
},
};