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>
This commit is contained in:
codegen-sh[bot]
2025-07-08 18:01:48 -04:00
committed by GitHub
parent 68f87f7254
commit 97f8d0f265
123 changed files with 1291 additions and 1081 deletions
+3 -12
View File
@@ -21,10 +21,7 @@
[ [
"transform-inline-environment-variables", "transform-inline-environment-variables",
{ {
"include": [ "include": ["SOURCE_COMMIT", "SOURCE_VERSION"]
"SOURCE_COMMIT",
"SOURCE_VERSION"
]
} }
], ],
"tsconfig-paths-module-resolver" "tsconfig-paths-module-resolver"
@@ -39,16 +36,10 @@
} }
] ]
], ],
"ignore": [ "ignore": ["**/__mocks__", "**/*.test.ts"]
"**/__mocks__",
"**/*.test.ts"
]
}, },
"development": { "development": {
"ignore": [ "ignore": ["**/__mocks__", "**/*.test.ts"]
"**/__mocks__",
"**/*.test.ts"
]
}, },
"test": { "test": {
"presets": [ "presets": [
+1 -8
View File
@@ -15,7 +15,7 @@
"plugin:@typescript-eslint/recommended", "plugin:@typescript-eslint/recommended",
"plugin:import/recommended", "plugin:import/recommended",
"plugin:import/typescript", "plugin:import/typescript",
"plugin:prettier/recommended" "prettier"
], ],
"plugins": [ "plugins": [
"es", "es",
@@ -162,13 +162,6 @@
} }
] ]
} }
],
"prettier/prettier": [
"error",
{
"printWidth": 80,
"trailingComma": "es5"
}
] ]
}, },
"settings": { "settings": {
+1 -1
View File
@@ -2,7 +2,7 @@ name: Auto Close Unsigned PRs
on: on:
schedule: schedule:
- cron: '0 0 * * *' # Run daily at midnight UTC - cron: "0 0 * * *" # Run daily at midnight UTC
jobs: jobs:
close-unsigned-prs: close-unsigned-prs:
+6 -6
View File
@@ -30,7 +30,7 @@ jobs:
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: ${{ matrix.node-version }} node-version: ${{ matrix.node-version }}
cache: 'yarn' cache: "yarn"
- name: Install dependencies - name: Install dependencies
run: yarn install --frozen-lockfile run: yarn install --frozen-lockfile
@@ -43,7 +43,7 @@ jobs:
- uses: actions/setup-node@v4 - uses: actions/setup-node@v4
with: with:
node-version: 22.x node-version: 22.x
cache: 'yarn' cache: "yarn"
- run: yarn install --frozen-lockfile - run: yarn install --frozen-lockfile
- run: yarn lint - run: yarn lint
@@ -55,7 +55,7 @@ jobs:
- uses: actions/setup-node@v4 - uses: actions/setup-node@v4
with: with:
node-version: 22.x node-version: 22.x
cache: 'yarn' cache: "yarn"
- run: yarn install --frozen-lockfile - run: yarn install --frozen-lockfile
- run: yarn tsc - run: yarn tsc
@@ -93,7 +93,7 @@ jobs:
- uses: actions/setup-node@v4 - uses: actions/setup-node@v4
with: with:
node-version: 22.x node-version: 22.x
cache: 'yarn' cache: "yarn"
- run: yarn install --frozen-lockfile - run: yarn install --frozen-lockfile
- run: yarn test:${{ matrix.test-group }} - run: yarn test:${{ matrix.test-group }}
@@ -135,7 +135,7 @@ jobs:
- uses: actions/setup-node@v4 - uses: actions/setup-node@v4
with: with:
node-version: 22.x node-version: 22.x
cache: 'yarn' cache: "yarn"
- run: yarn install --frozen-lockfile - run: yarn install --frozen-lockfile
- run: yarn sequelize db:migrate - run: yarn sequelize db:migrate
- name: Run server tests - name: Run server tests
@@ -152,7 +152,7 @@ jobs:
- uses: actions/setup-node@v4 - uses: actions/setup-node@v4
with: with:
node-version: 22.x node-version: 22.x
cache: 'yarn' cache: "yarn"
- run: yarn install --frozen-lockfile - run: yarn install --frozen-lockfile
- name: Set environment to production - name: Set environment to production
run: echo "NODE_ENV=production" >> $GITHUB_ENV run: echo "NODE_ENV=production" >> $GITHUB_ENV
+2 -2
View File
@@ -18,7 +18,7 @@ on:
# The branches below must be a subset of the branches above # The branches below must be a subset of the branches above
branches: [main] branches: [main]
schedule: schedule:
- cron: '28 15 * * 2' - cron: "28 15 * * 2"
jobs: jobs:
analyze: analyze:
@@ -32,7 +32,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
language: [ 'javascript' ] language: ["javascript"]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://git.io/codeql-language-support # Learn more about CodeQL language support at https://git.io/codeql-language-support
+2 -2
View File
@@ -20,11 +20,11 @@ jobs:
- uses: actions/setup-node@v4 - uses: actions/setup-node@v4
with: with:
node-version: 20.x node-version: 20.x
cache: 'yarn' cache: "yarn"
- run: yarn install --frozen-lockfile - run: yarn install --frozen-lockfile
- run: yarn lint --fix - run: yarn lint --fix
- name: Commit changes - name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5 uses: stefanzweifel/git-auto-commit-action@v5
with: with:
commit_message: 'Applied automatic fixes' commit_message: "Applied automatic fixes"
+4
View File
@@ -0,0 +1,4 @@
{
"printWidth": 80,
"trailingComma": "es5"
}
+1 -1
View File
@@ -1 +1 @@
export default ''; export default "";
+1 -1
View File
@@ -2,7 +2,7 @@ const storage = {};
export default { export default {
setItem: function (key, value) { setItem: function (key, value) {
storage[key] = value || ''; storage[key] = value || "";
}, },
getItem: function (key) { getItem: function (key) {
return key in storage ? storage[key] : null; return key in storage ? storage[key] : null;
+1 -7
View File
@@ -3,13 +3,7 @@
"description": "Open source wiki and knowledge base for growing teams", "description": "Open source wiki and knowledge base for growing teams",
"website": "https://www.getoutline.com/", "website": "https://www.getoutline.com/",
"repository": "https://github.com/outline/outline", "repository": "https://github.com/outline/outline",
"keywords": [ "keywords": ["wiki", "team", "node", "markdown", "slack"],
"wiki",
"team",
"node",
"markdown",
"slack"
],
"success_url": "/", "success_url": "/",
"formation": { "formation": {
"web": { "web": {
+4 -4
View File
@@ -1,12 +1,12 @@
/* eslint-disable */ /* eslint-disable */
import stores from "~/stores"; import stores from "~/stores";
describe('Collection model', () => { describe("Collection model", () => {
test('should initialize with data', () => { test("should initialize with data", () => {
const collection = stores.collections.add({ const collection = stores.collections.add({
id: "123", id: "123",
name: 'Engineering' name: "Engineering",
}); });
expect(collection.name).toBe('Engineering'); expect(collection.name).toBe("Engineering");
}); });
}); });
+5 -3
View File
@@ -1,11 +1,13 @@
/* eslint-disable */ /* eslint-disable */
export const client = { export const client = {
post: jest.fn(() => Promise.resolve({ post: jest.fn(() =>
Promise.resolve({
data: { data: {
user: {}, user: {},
team: {}, team: {},
groups: [], groups: [],
groupUsers: [], groupUsers: [],
} },
})) })
),
}; };
+1 -1
View File
@@ -1,4 +1,4 @@
commit_message: 'fix: New %language% translations from Crowdin [ci skip]' commit_message: "fix: New %language% translations from Crowdin [ci skip]"
append_commit_message: append_commit_message:
files: files:
- source: /shared/i18n/locales/en_US/translation.json - source: /shared/i18n/locales/en_US/translation.json
+10 -10
View File
@@ -8,19 +8,19 @@ In the interest of fostering an open and welcoming environment, we as contributo
Examples of behavior that contributes to creating a positive environment include: Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language - Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences - Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism - Gracefully accepting constructive criticism
* Focusing on what is best for the community - Focusing on what is best for the community
* Showing empathy towards other community members - Showing empathy towards other community members
Examples of unacceptable behavior by participants include: Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances - The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks - Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment - Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission - Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting - Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities ## Our Responsibilities
+2 -1
View File
@@ -1,7 +1,8 @@
export default { export default {
// Efficiently run prettier and translation updates on changes to JS and // Run prettier first for formatting, then eslint for linting, and translation updates on changes to JS and
// TypeScript files // TypeScript files
"**/*.[tj]s?(x)": [ "**/*.[tj]s?(x)": [
(f) => `prettier --write ${f.join(" ")}`,
(f) => (f.length > 20 ? `yarn lint --fix` : `eslint ${f.join(" ")} --fix`), (f) => (f.length > 20 ? `yarn lint --fix` : `eslint ${f.join(" ")} --fix`),
() => `yarn build:i18n`, () => `yarn build:i18n`,
() => "git add shared/i18n/locales/en_US/translation.json", () => "git add shared/i18n/locales/en_US/translation.json",
+2 -1
View File
@@ -15,6 +15,8 @@
"dev:watch": "NODE_ENV=development yarn concurrently -n backend,frontend \"yarn dev:backend\" \"yarn vite:dev\"", "dev:watch": "NODE_ENV=development yarn concurrently -n backend,frontend \"yarn dev:backend\" \"yarn vite:dev\"",
"lint": "eslint app server shared plugins", "lint": "eslint app server shared plugins",
"lint:changed": "git diff --name-only --diff-filter=ACMRTUXB | grep -E '\\.(js|jsx|ts|tsx)$' | xargs -r yarn eslint --fix", "lint:changed": "git diff --name-only --diff-filter=ACMRTUXB | grep -E '\\.(js|jsx|ts|tsx)$' | xargs -r yarn eslint --fix",
"format": "prettier --write .",
"format:check": "prettier --check .",
"prepare": "husky install", "prepare": "husky install",
"postinstall": "yarn patch-package", "postinstall": "yarn patch-package",
"install-local-ssl": "node ./server/scripts/install-local-ssl.js", "install-local-ssl": "node ./server/scripts/install-local-ssl.js",
@@ -356,7 +358,6 @@
"eslint-plugin-jsx-a11y": "^6.10.2", "eslint-plugin-jsx-a11y": "^6.10.2",
"eslint-plugin-lodash": "^7.4.0", "eslint-plugin-lodash": "^7.4.0",
"eslint-plugin-node": "^11.1.0", "eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^5.5.1",
"eslint-plugin-react": "^7.37.5", "eslint-plugin-react": "^7.37.5",
"eslint-plugin-react-hooks": "^4.6.2", "eslint-plugin-react-hooks": "^4.6.2",
"husky": "^8.0.3", "husky": "^8.0.3",
+1 -4
View File
@@ -3,8 +3,5 @@
"name": "Umami", "name": "Umami",
"priority": 50, "priority": 50,
"description": "Adds support for reporting analytics to a Umami server.", "description": "Adds support for reporting analytics to a Umami server.",
"deployments": [ "deployments": ["community", "enterprise"]
"community",
"enterprise"
]
} }
@@ -1,8 +1,7 @@
module.exports = { module.exports = {
up: async (queryInterface, Sequelize) => { up: async (queryInterface, Sequelize) => {
const [teams, metaData] = await queryInterface.sequelize.query( const [teams, metaData] =
`SELECT * FROM teams` await queryInterface.sequelize.query(`SELECT * FROM teams`);
);
const teamIds = teams.map((team) => team.id); const teamIds = teams.map((team) => team.id);
await Promise.all( await Promise.all(
@@ -2,12 +2,15 @@
module.exports = { module.exports = {
up: async (queryInterface, Sequelize) => { up: async (queryInterface, Sequelize) => {
await queryInterface.removeIndex("documents", "documents_id_atlas_id_deleted_at"); await queryInterface.removeIndex(
"documents",
"documents_id_atlas_id_deleted_at"
);
await queryInterface.removeIndex("apiKeys", "api_keys_secret_deleted_at"); await queryInterface.removeIndex("apiKeys", "api_keys_secret_deleted_at");
await queryInterface.removeIndex("groups", "groups_deleted_at"); await queryInterface.removeIndex("groups", "groups_deleted_at");
}, },
down: async (queryInterface, Sequelize) => { down: async (queryInterface, Sequelize) => {
// noop // noop
} },
}; };
@@ -57,10 +57,13 @@ module.exports = {
await queryInterface.addIndex("pins", ["collectionId"]); await queryInterface.addIndex("pins", ["collectionId"]);
const createdAt = new Date(); const createdAt = new Date();
const [documents] = await queryInterface.sequelize.query(`SELECT "id","collectionId","teamId","pinnedById" FROM documents WHERE "pinnedById" IS NOT NULL`); const [documents] = await queryInterface.sequelize.query(
`SELECT "id","collectionId","teamId","pinnedById" FROM documents WHERE "pinnedById" IS NOT NULL`
);
for (const document of documents) { for (const document of documents) {
await queryInterface.sequelize.query(` await queryInterface.sequelize.query(
`
INSERT INTO pins ( INSERT INTO pins (
"id", "id",
"documentId", "documentId",
@@ -79,7 +82,8 @@ module.exports = {
:createdAt, :createdAt,
:updatedAt :updatedAt
) )
`, { `,
{
replacements: { replacements: {
id: v4(), id: v4(),
documentId: document.id, documentId: document.id,
@@ -89,7 +93,8 @@ module.exports = {
updatedAt: createdAt, updatedAt: createdAt,
createdAt, createdAt,
}, },
}); }
);
} }
}, },
down: async (queryInterface, Sequelize) => { down: async (queryInterface, Sequelize) => {
@@ -26,16 +26,28 @@ module.exports = {
// somehow these indexes were being used sometimes, but i'll never know how. // somehow these indexes were being used sometimes, but i'll never know how.
// Note: These are not recreated in the down method // Note: These are not recreated in the down method
await queryInterface.removeIndex("documents", "documents_id_atlas_id_published_at"); await queryInterface.removeIndex(
await queryInterface.removeIndex("documents", "documents_id_team_id_deleted_at"); "documents",
"documents_id_atlas_id_published_at"
);
await queryInterface.removeIndex(
"documents",
"documents_id_team_id_deleted_at"
);
await queryInterface.removeIndex("documents", "documents_id_deleted_at"); await queryInterface.removeIndex("documents", "documents_id_deleted_at");
await queryInterface.removeIndex("collections", "atlases_id_deleted_at"); await queryInterface.removeIndex("collections", "atlases_id_deleted_at");
await queryInterface.removeIndex("collections", "atlases_id_team_id_deleted_at"); await queryInterface.removeIndex(
"collections",
"atlases_id_team_id_deleted_at"
);
}, },
down: async (queryInterface) => { down: async (queryInterface) => {
await queryInterface.removeIndex("views", "views_last_editing_at"); await queryInterface.removeIndex("views", "views_last_editing_at");
await queryInterface.removeIndex("pins", "pins_team_id"); await queryInterface.removeIndex("pins", "pins_team_id");
await queryInterface.removeIndex("collections", "collections_team_id_deleted_at"); await queryInterface.removeIndex(
"collections",
"collections_team_id_deleted_at"
);
await queryInterface.removeIndex("stars", "stars_user_id_document_id"); await queryInterface.removeIndex("stars", "stars_user_id_document_id");
await queryInterface.removeIndex("documents", "documents_collection_id"); await queryInterface.removeIndex("documents", "documents_collection_id");
await queryInterface.removeIndex("documents", "documents_published_at"); await queryInterface.removeIndex("documents", "documents_published_at");
@@ -1,4 +1,4 @@
'use strict'; "use strict";
module.exports = { module.exports = {
up: async (queryInterface, Sequelize) => { up: async (queryInterface, Sequelize) => {
@@ -11,5 +11,5 @@ module.exports = {
down: async (queryInterface, Sequelize) => { down: async (queryInterface, Sequelize) => {
await queryInterface.removeColumn("teams", "defaultCollectionId"); await queryInterface.removeColumn("teams", "defaultCollectionId");
} },
}; };
@@ -6,58 +6,58 @@ module.exports = {
id: { id: {
type: Sequelize.UUID, type: Sequelize.UUID,
allowNull: false, allowNull: false,
primaryKey: true primaryKey: true,
}, },
data: { data: {
type: Sequelize.JSONB, type: Sequelize.JSONB,
allowNull: false allowNull: false,
}, },
documentId: { documentId: {
type: Sequelize.UUID, type: Sequelize.UUID,
allowNull: false, allowNull: false,
onDelete: "cascade", onDelete: "cascade",
references: { references: {
model: "documents" model: "documents",
} },
}, },
parentCommentId: { parentCommentId: {
type: Sequelize.UUID, type: Sequelize.UUID,
allowNull: true, allowNull: true,
onDelete: "cascade", onDelete: "cascade",
references: { references: {
model: "comments" model: "comments",
} },
}, },
createdById: { createdById: {
type: Sequelize.UUID, type: Sequelize.UUID,
allowNull: false, allowNull: false,
references: { references: {
model: "users" model: "users",
} },
}, },
resolvedAt: { resolvedAt: {
type: Sequelize.DATE, type: Sequelize.DATE,
allowNull: true allowNull: true,
}, },
resolvedById: { resolvedById: {
type: Sequelize.UUID, type: Sequelize.UUID,
allowNull: true, allowNull: true,
references: { references: {
model: "users" model: "users",
} },
}, },
createdAt: { createdAt: {
type: Sequelize.DATE, type: Sequelize.DATE,
allowNull: false allowNull: false,
}, },
updatedAt: { updatedAt: {
type: Sequelize.DATE, type: Sequelize.DATE,
allowNull: false allowNull: false,
}, },
deletedAt: { deletedAt: {
type: Sequelize.DATE, type: Sequelize.DATE,
allowNull: true allowNull: true,
} },
}); });
await queryInterface.addIndex("comments", ["documentId"]); await queryInterface.addIndex("comments", ["documentId"]);
@@ -66,5 +66,5 @@ module.exports = {
down: async (queryInterface, Sequelize) => { down: async (queryInterface, Sequelize) => {
queryInterface.dropTable("comments"); queryInterface.dropTable("comments");
} },
}; };
@@ -1,4 +1,4 @@
'use strict'; "use strict";
module.exports = { module.exports = {
up: async (queryInterface, Sequelize) => { up: async (queryInterface, Sequelize) => {
@@ -16,6 +16,9 @@ module.exports = {
down: async (queryInterface, Sequelize) => { down: async (queryInterface, Sequelize) => {
await queryInterface.removeIndex("views", "views_updated_at"); await queryInterface.removeIndex("views", "views_updated_at");
await queryInterface.removeIndex("views", "views_user_id"); await queryInterface.removeIndex("views", "views_user_id");
await queryInterface.removeIndex("collection_users", "collection_users_user_id"); await queryInterface.removeIndex(
} "collection_users",
"collection_users_user_id"
);
},
}; };
@@ -1,4 +1,4 @@
'use strict'; "use strict";
module.exports = { module.exports = {
up: async (queryInterface, Sequelize) => { up: async (queryInterface, Sequelize) => {
@@ -9,5 +9,5 @@ module.exports = {
down: async (queryInterface, Sequelize) => { down: async (queryInterface, Sequelize) => {
await queryInterface.removeIndex("events", "events_created_at"); await queryInterface.removeIndex("events", "events_created_at");
} },
}; };
@@ -1,4 +1,4 @@
'use strict'; "use strict";
module.exports = { module.exports = {
up: async (queryInterface, Sequelize) => { up: async (queryInterface, Sequelize) => {
@@ -11,5 +11,5 @@ module.exports = {
down: async (queryInterface, Sequelize) => { down: async (queryInterface, Sequelize) => {
await queryInterface.removeColumn("teams", "memberCollectionCreate"); await queryInterface.removeColumn("teams", "memberCollectionCreate");
} },
}; };
@@ -1,4 +1,4 @@
'use strict'; "use strict";
module.exports = { module.exports = {
up: async (queryInterface, Sequelize) => { up: async (queryInterface, Sequelize) => {
@@ -8,7 +8,7 @@ module.exports = {
allowNull: true, allowNull: true,
references: { references: {
model: "shares", model: "shares",
key: "id" key: "id",
}, },
}); });
}, },
@@ -1,4 +1,4 @@
'use strict'; "use strict";
module.exports = { module.exports = {
up: async (queryInterface, Sequelize) => { up: async (queryInterface, Sequelize) => {
@@ -23,7 +23,7 @@ module.exports = {
}); });
await queryInterface.changeColumn("stars", "documentId", { await queryInterface.changeColumn("stars", "documentId", {
type: Sequelize.UUID, type: Sequelize.UUID,
allowNull: true allowNull: true,
}); });
await queryInterface.changeColumn("stars", "documentId", { await queryInterface.changeColumn("stars", "documentId", {
type: Sequelize.UUID, type: Sequelize.UUID,
@@ -46,9 +46,9 @@ module.exports = {
await queryInterface.removeColumn("stars", "collectionId"); await queryInterface.removeColumn("stars", "collectionId");
await queryInterface.changeColumn("stars", "documentId", { await queryInterface.changeColumn("stars", "documentId", {
type: Sequelize.UUID, type: Sequelize.UUID,
allowNull: false allowNull: false,
}); });
await queryInterface.removeConstraint("stars", "stars_documentId_fkey") await queryInterface.removeConstraint("stars", "stars_documentId_fkey");
await queryInterface.removeConstraint("stars", "stars_userId_fkey") await queryInterface.removeConstraint("stars", "stars_userId_fkey");
} },
}; };
@@ -1,4 +1,4 @@
'use strict'; "use strict";
module.exports = { module.exports = {
up: async (queryInterface, Sequelize) => { up: async (queryInterface, Sequelize) => {
@@ -10,5 +10,5 @@ module.exports = {
down: async (queryInterface) => { down: async (queryInterface) => {
return queryInterface.removeColumn("users", "flags"); return queryInterface.removeColumn("users", "flags");
} },
}; };
@@ -1,4 +1,4 @@
'use strict'; "use strict";
module.exports = { module.exports = {
up: async (queryInterface, Sequelize) => { up: async (queryInterface, Sequelize) => {
@@ -13,5 +13,5 @@ module.exports = {
down: async (queryInterface) => { down: async (queryInterface) => {
return queryInterface.removeColumn("users", "invitedById"); return queryInterface.removeColumn("users", "invitedById");
} },
}; };
@@ -1,11 +1,11 @@
'use strict'; "use strict";
module.exports = { module.exports = {
up: async (queryInterface, Sequelize) => { up: async (queryInterface, Sequelize) => {
await queryInterface.addColumn("teams", "inviteRequired", { await queryInterface.addColumn("teams", "inviteRequired", {
type: Sequelize.BOOLEAN, type: Sequelize.BOOLEAN,
defaultValue: false, defaultValue: false,
allowNull: false allowNull: false,
}); });
}, },
down: async (queryInterface) => { down: async (queryInterface) => {
@@ -5,7 +5,9 @@ const { v4 } = require("uuid");
module.exports = { module.exports = {
up: async (queryInterface, Sequelize) => { up: async (queryInterface, Sequelize) => {
await queryInterface.sequelize.transaction(async (transaction) => { await queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.createTable("team_domains", { await queryInterface.createTable(
"team_domains",
{
id: { id: {
type: Sequelize.UUID, type: Sequelize.UUID,
allowNull: false, allowNull: false,
@@ -38,32 +40,45 @@ module.exports = {
type: Sequelize.DATE, type: Sequelize.DATE,
allowNull: false, allowNull: false,
}, },
}, { },
transaction {
}); transaction,
}
);
await queryInterface.addIndex("team_domains", ["teamId", "name"], { await queryInterface.addIndex("team_domains", ["teamId", "name"], {
transaction, transaction,
unique: true, unique: true,
}); });
const currentAllowedDomainsEnv = process.env.ALLOWED_DOMAINS || process.env.GOOGLE_ALLOWED_DOMAINS; const currentAllowedDomainsEnv =
const currentAllowedDomains = currentAllowedDomainsEnv ? currentAllowedDomainsEnv.split(",") : []; process.env.ALLOWED_DOMAINS || process.env.GOOGLE_ALLOWED_DOMAINS;
const currentAllowedDomains = currentAllowedDomainsEnv
? currentAllowedDomainsEnv.split(",")
: [];
if (currentAllowedDomains.length > 0) { if (currentAllowedDomains.length > 0) {
const [adminUserIDs] = await queryInterface.sequelize.query('select id from users where "isAdmin" = true limit 1', { transaction }) const [adminUserIDs] = await queryInterface.sequelize.query(
const adminUserID = adminUserIDs[0]?.id 'select id from users where "isAdmin" = true limit 1',
{ transaction }
);
const adminUserID = adminUserIDs[0]?.id;
if (adminUserID) { if (adminUserID) {
const [teams] = await queryInterface.sequelize.query('select id from teams', { transaction }) const [teams] = await queryInterface.sequelize.query(
"select id from teams",
{ transaction }
);
const now = new Date(); const now = new Date();
for (const team of teams) { for (const team of teams) {
for (const domain of currentAllowedDomains) { for (const domain of currentAllowedDomains) {
await queryInterface.sequelize.query(` await queryInterface.sequelize.query(
`
INSERT INTO team_domains ("id", "teamId", "createdById", "name", "createdAt", "updatedAt") INSERT INTO team_domains ("id", "teamId", "createdById", "name", "createdAt", "updatedAt")
VALUES (:id, :teamId, :createdById, :name, :createdAt, :updatedAt) VALUES (:id, :teamId, :createdById, :name, :createdAt, :updatedAt)
`, { `,
{
replacements: { replacements: {
id: v4(), id: v4(),
teamId: team.id, teamId: team.id,
@@ -1,11 +1,11 @@
'use strict'; "use strict";
module.exports = { module.exports = {
up: async (queryInterface, Sequelize) => { up: async (queryInterface, Sequelize) => {
await queryInterface.addColumn("file_operations", "format", { await queryInterface.addColumn("file_operations", "format", {
type: Sequelize.STRING, type: Sequelize.STRING,
defaultValue: "outline-markdown", defaultValue: "outline-markdown",
allowNull: false allowNull: false,
}); });
}, },
down: async (queryInterface) => { down: async (queryInterface) => {
@@ -1,4 +1,4 @@
'use strict'; "use strict";
module.exports = { module.exports = {
up: async (queryInterface) => { up: async (queryInterface) => {
@@ -6,18 +6,21 @@ module.exports = {
while (again) { while (again) {
console.log("Backfilling collection sort…"); console.log("Backfilling collection sort…");
const [, metadata] = await queryInterface.sequelize.query(` const [, metadata] = await queryInterface.sequelize.query(
`
WITH rows AS ( WITH rows AS (
SELECT id FROM collections WHERE "sort" IS NULL ORDER BY id LIMIT 1000 SELECT id FROM collections WHERE "sort" IS NULL ORDER BY id LIMIT 1000
) )
UPDATE collections UPDATE collections
SET "sort" = :sort::jsonb SET "sort" = :sort::jsonb
WHERE EXISTS (SELECT * FROM rows WHERE collections.id = rows.id) WHERE EXISTS (SELECT * FROM rows WHERE collections.id = rows.id)
`, { `,
{
replacements: { replacements: {
sort: JSON.stringify({ field: "title", direction: "asc" }), sort: JSON.stringify({ field: "title", direction: "asc" }),
},
} }
}); );
again = metadata.rowCount; again = metadata.rowCount;
} }
@@ -25,5 +28,5 @@ WHERE EXISTS (SELECT * FROM rows WHERE collections.id = rows.id)
down: async () => { down: async () => {
// cannot be undone // cannot be undone
} },
}; };
@@ -1,4 +1,4 @@
'use strict'; "use strict";
module.exports = { module.exports = {
up: async (queryInterface, Sequelize) => { up: async (queryInterface, Sequelize) => {
@@ -6,13 +6,17 @@ module.exports = {
await queryInterface.addColumn("user_authentications", "expiresAt", { await queryInterface.addColumn("user_authentications", "expiresAt", {
type: Sequelize.DATE, type: Sequelize.DATE,
allowNull: true, allowNull: true,
transaction transaction,
}); });
await queryInterface.addColumn("user_authentications", "lastValidatedAt", { await queryInterface.addColumn(
"user_authentications",
"lastValidatedAt",
{
type: Sequelize.DATE, type: Sequelize.DATE,
allowNull: true, allowNull: true,
transaction transaction,
}); }
);
}); });
}, },
down: async (queryInterface) => { down: async (queryInterface) => {
@@ -21,11 +25,11 @@ module.exports = {
"user_authentications", "user_authentications",
"lastValidatedAt", "lastValidatedAt",
{ {
transaction transaction,
} }
); );
await queryInterface.removeColumn("user_authentications", "expiresAt", { await queryInterface.removeColumn("user_authentications", "expiresAt", {
transaction transaction,
}); });
}); });
}, },
@@ -1,10 +1,10 @@
'use strict'; "use strict";
module.exports = { module.exports = {
up: async (queryInterface, Sequelize) => { up: async (queryInterface, Sequelize) => {
await queryInterface.addColumn("webhook_subscriptions", "deletedAt", { await queryInterface.addColumn("webhook_subscriptions", "deletedAt", {
type: Sequelize.DATE, type: Sequelize.DATE,
allowNull: true allowNull: true,
}); });
}, },
down: async (queryInterface) => { down: async (queryInterface) => {
@@ -1,4 +1,4 @@
'use strict'; "use strict";
module.exports = { module.exports = {
async up(queryInterface) { async up(queryInterface) {
@@ -16,7 +16,9 @@ module.exports = {
); );
if (teams[0].count > 0 && authenticationProviders[0].count === 0) { if (teams[0].count > 0 && authenticationProviders[0].count === 0) {
throw Error("Refusing to destroy deprecated columns without authentication providers"); throw Error(
"Refusing to destroy deprecated columns without authentication providers"
);
} }
} }
@@ -34,28 +36,28 @@ module.exports = {
type: Sequelize.STRING(4096), type: Sequelize.STRING(4096),
allowNull: false, allowNull: false,
defaultValue: "", defaultValue: "",
transaction transaction,
}); });
await queryInterface.addColumn("users", "service", { await queryInterface.addColumn("users", "service", {
type: Sequelize.STRING, type: Sequelize.STRING,
allowNull: true, allowNull: true,
transaction transaction,
}); });
await queryInterface.addColumn("users", "serviceId", { await queryInterface.addColumn("users", "serviceId", {
type: Sequelize.STRING, type: Sequelize.STRING,
allowNull: true, allowNull: true,
transaction transaction,
}); });
await queryInterface.addColumn("teams", "slackId", { await queryInterface.addColumn("teams", "slackId", {
type: Sequelize.STRING, type: Sequelize.STRING,
allowNull: true, allowNull: true,
transaction transaction,
}); });
await queryInterface.addColumn("teams", "googleId", { await queryInterface.addColumn("teams", "googleId", {
type: Sequelize.STRING, type: Sequelize.STRING,
allowNull: true, allowNull: true,
transaction transaction,
}); });
}); });
} },
}; };
@@ -1,4 +1,4 @@
'use strict'; "use strict";
module.exports = { module.exports = {
async up(queryInterface, Sequelize) { async up(queryInterface, Sequelize) {
@@ -8,7 +8,7 @@ module.exports = {
await queryInterface.addColumn("events", "updatedAt", { await queryInterface.addColumn("events", "updatedAt", {
type: Sequelize.DATE, type: Sequelize.DATE,
allowNull: false, allowNull: false,
defaultValue: Sequelize.fn('NOW'), defaultValue: Sequelize.fn("NOW"),
}); });
} },
}; };
@@ -1,21 +1,27 @@
'use strict'; "use strict";
module.exports = { module.exports = {
async up(queryInterface, Sequelize) { async up(queryInterface, Sequelize) {
await queryInterface.removeConstraint("authentication_providers", "authentication_providers_providerId_key"); await queryInterface.removeConstraint(
"authentication_providers",
"authentication_providers_providerId_key"
);
await queryInterface.addConstraint("authentication_providers", { await queryInterface.addConstraint("authentication_providers", {
type: 'unique', type: "unique",
fields: ["providerId", "teamId"], fields: ["providerId", "teamId"],
name: "authentication_providers_providerId_teamId_uk" name: "authentication_providers_providerId_teamId_uk",
}); });
}, },
async down(queryInterface, Sequelize) { async down(queryInterface, Sequelize) {
await queryInterface.removeConstraint("authentication_providers", "authentication_providers_providerId_teamId_uk"); await queryInterface.removeConstraint(
"authentication_providers",
"authentication_providers_providerId_teamId_uk"
);
await queryInterface.addConstraint("authentication_providers", { await queryInterface.addConstraint("authentication_providers", {
type: 'unique', type: "unique",
fields: ["providerId"], fields: ["providerId"],
name: "authentication_providers_providerId_key" name: "authentication_providers_providerId_key",
}); });
} },
}; };
@@ -1,21 +1,27 @@
'use strict'; "use strict";
module.exports = { module.exports = {
async up(queryInterface, Sequelize) { async up(queryInterface, Sequelize) {
await queryInterface.removeConstraint("user_authentications", "user_authentications_providerId_key"); await queryInterface.removeConstraint(
"user_authentications",
"user_authentications_providerId_key"
);
await queryInterface.addConstraint("user_authentications", { await queryInterface.addConstraint("user_authentications", {
type: 'unique', type: "unique",
fields: ["providerId", "userId"], fields: ["providerId", "userId"],
name: "user_authentications_providerId_userId_uk" name: "user_authentications_providerId_userId_uk",
}); });
}, },
async down(queryInterface, Sequelize) { async down(queryInterface, Sequelize) {
await queryInterface.removeConstraint("user_authentications", "user_authentications_providerId_userId_uk"); await queryInterface.removeConstraint(
"user_authentications",
"user_authentications_providerId_userId_uk"
);
await queryInterface.addConstraint("user_authentications", { await queryInterface.addConstraint("user_authentications", {
type: 'unique', type: "unique",
fields: ["providerId"], fields: ["providerId"],
name: "user_authentications_providerId_key" name: "user_authentications_providerId_key",
}); });
} },
}; };
@@ -1,4 +1,4 @@
'use strict'; "use strict";
module.exports = { module.exports = {
async up(queryInterface) { async up(queryInterface) {
@@ -7,5 +7,5 @@ module.exports = {
async down(queryInterface) { async down(queryInterface) {
await queryInterface.removeIndex("users", ["email"]); await queryInterface.removeIndex("users", ["email"]);
} },
}; };
@@ -1,10 +1,10 @@
'use strict'; "use strict";
module.exports = { module.exports = {
up: async (queryInterface, Sequelize) => { up: async (queryInterface, Sequelize) => {
await queryInterface.addColumn("shares", "views", { await queryInterface.addColumn("shares", "views", {
type: Sequelize.INTEGER, type: Sequelize.INTEGER,
defaultValue: 0 defaultValue: 0,
}); });
}, },
down: async (queryInterface) => { down: async (queryInterface) => {
@@ -1,4 +1,4 @@
'use strict'; "use strict";
module.exports = { module.exports = {
async up(queryInterface, Sequelize) { async up(queryInterface, Sequelize) {
@@ -10,5 +10,5 @@ module.exports = {
async down(queryInterface, Sequelize) { async down(queryInterface, Sequelize) {
return queryInterface.removeColumn("users", "preferences"); return queryInterface.removeColumn("users", "preferences");
} },
}; };
@@ -1,12 +1,28 @@
'use strict'; "use strict";
module.exports = { module.exports = {
up: async (queryInterface, Sequelize) => { up: async (queryInterface, Sequelize) => {
await queryInterface.sequelize.transaction(async (transaction) => { await queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.removeConstraint("notifications", "notifications_userId_fkey", { transaction }) await queryInterface.removeConstraint(
await queryInterface.removeConstraint("notifications", "notifications_actorId_fkey", { transaction }) "notifications",
await queryInterface.removeConstraint("notifications", "notifications_teamId_fkey", { transaction }) "notifications_userId_fkey",
await queryInterface.removeConstraint("notifications", "notifications_documentId_fkey", { transaction }) { transaction }
);
await queryInterface.removeConstraint(
"notifications",
"notifications_actorId_fkey",
{ transaction }
);
await queryInterface.removeConstraint(
"notifications",
"notifications_teamId_fkey",
{ transaction }
);
await queryInterface.removeConstraint(
"notifications",
"notifications_documentId_fkey",
{ transaction }
);
}); });
await queryInterface.sequelize.transaction(async (transaction) => { await queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.changeColumn("notifications", "userId", { await queryInterface.changeColumn("notifications", "userId", {
@@ -49,10 +65,26 @@ module.exports = {
down: async (queryInterface, Sequelize) => { down: async (queryInterface, Sequelize) => {
await queryInterface.sequelize.transaction(async (transaction) => { await queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.removeConstraint("notifications", "notifications_userId_fkey", { transaction }) await queryInterface.removeConstraint(
await queryInterface.removeConstraint("notifications", "notifications_actorId_fkey", { transaction }) "notifications",
await queryInterface.removeConstraint("notifications", "notifications_teamId_fkey", { transaction }) "notifications_userId_fkey",
await queryInterface.removeConstraint("notifications", "notifications_documentId_fkey", { transaction }) { transaction }
);
await queryInterface.removeConstraint(
"notifications",
"notifications_actorId_fkey",
{ transaction }
);
await queryInterface.removeConstraint(
"notifications",
"notifications_teamId_fkey",
{ transaction }
);
await queryInterface.removeConstraint(
"notifications",
"notifications_documentId_fkey",
{ transaction }
);
}); });
await queryInterface.sequelize.transaction(async (transaction) => { await queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.changeColumn("notifications", "userId", { await queryInterface.changeColumn("notifications", "userId", {
@@ -87,5 +119,5 @@ module.exports = {
transaction, transaction,
}); });
}); });
} },
}; };
@@ -10,5 +10,5 @@ module.exports = {
async down(queryInterface, Sequelize) { async down(queryInterface, Sequelize) {
return queryInterface.removeColumn("webhook_subscriptions", "secret"); return queryInterface.removeColumn("webhook_subscriptions", "secret");
} },
}; };
@@ -1,4 +1,4 @@
'use strict'; "use strict";
module.exports = { module.exports = {
up: async (queryInterface, Sequelize) => { up: async (queryInterface, Sequelize) => {
@@ -29,5 +29,5 @@ module.exports = {
transaction, transaction,
}); });
}); });
} },
}; };
@@ -1,4 +1,4 @@
'use strict'; "use strict";
module.exports = { module.exports = {
up: async (queryInterface, Sequelize) => { up: async (queryInterface, Sequelize) => {
@@ -15,5 +15,5 @@ module.exports = {
await queryInterface.changeColumn("users", "teamId", { await queryInterface.changeColumn("users", "teamId", {
type: Sequelize.UUID, type: Sequelize.UUID,
}); });
} },
}; };
@@ -20,29 +20,28 @@ module.exports = {
transaction, transaction,
}); });
await queryInterface.addIndex("documents", ["importId"], { await queryInterface.addIndex("documents", ["importId"], {
transaction transaction,
}); });
await queryInterface.addIndex("collections", ["importId"], { await queryInterface.addIndex("collections", ["importId"], {
transaction transaction,
}); });
}); });
}, },
async down(queryInterface) { async down(queryInterface) {
await queryInterface.sequelize.transaction(async (transaction) => { await queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.removeIndex("collections", ["importId"], { await queryInterface.removeIndex("collections", ["importId"], {
transaction transaction,
}); });
await queryInterface.removeIndex("documents", ["importId"], { await queryInterface.removeIndex("documents", ["importId"], {
transaction transaction,
}); });
await queryInterface.removeColumn("collections", "importId", { await queryInterface.removeColumn("collections", "importId", {
transaction transaction,
}); });
await queryInterface.removeColumn("documents", "importId", { await queryInterface.removeColumn("documents", "importId", {
transaction transaction,
}); });
}); });
} },
}; };
@@ -9,14 +9,18 @@ module.exports = {
transaction, transaction,
}); });
await queryInterface.addIndex("attachments", ["expiresAt"], { await queryInterface.addIndex("attachments", ["expiresAt"], {
transaction transaction,
}); });
}); });
}, },
down: async (queryInterface) => { down: async (queryInterface) => {
await queryInterface.sequelize.transaction(async (transaction) => { await queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.removeColumn("attachments", "expiresAt", { transaction }); await queryInterface.removeColumn("attachments", "expiresAt", {
await queryInterface.removeIndex("attachments", ["expiresAt"], { transaction }); transaction,
});
await queryInterface.removeIndex("attachments", ["expiresAt"], {
transaction,
});
}); });
}, },
}; };
@@ -4,15 +4,11 @@ module.exports = {
async up(queryInterface, Sequelize) { async up(queryInterface, Sequelize) {
try { try {
await queryInterface.sequelize.transaction(async (transaction) => { await queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.addColumn( await queryInterface.addColumn("shares", "urlId", {
"shares",
"urlId",
{
type: Sequelize.STRING, type: Sequelize.STRING,
allowNull: true, allowNull: true,
transaction, transaction,
}, });
);
await queryInterface.addConstraint("shares", { await queryInterface.addConstraint("shares", {
fields: ["urlId", "teamId"], fields: ["urlId", "teamId"],
@@ -1,8 +1,11 @@
'use strict'; "use strict";
module.exports = { module.exports = {
up: async (queryInterface, Sequelize) => { up: async (queryInterface, Sequelize) => {
await queryInterface.removeConstraint("webhook_subscriptions", "webhook_subscriptions_teamId_fkey") await queryInterface.removeConstraint(
"webhook_subscriptions",
"webhook_subscriptions_teamId_fkey"
);
await queryInterface.changeColumn("webhook_subscriptions", "teamId", { await queryInterface.changeColumn("webhook_subscriptions", "teamId", {
type: Sequelize.UUID, type: Sequelize.UUID,
allowNull: false, allowNull: false,
@@ -14,7 +17,10 @@ module.exports = {
}, },
down: async (queryInterface, Sequelize) => { down: async (queryInterface, Sequelize) => {
await queryInterface.removeConstraint("webhook_subscriptions", "webhook_subscriptions_teamId_fkey") await queryInterface.removeConstraint(
"webhook_subscriptions",
"webhook_subscriptions_teamId_fkey"
);
await queryInterface.changeColumn("webhook_subscriptions", "teamId", { await queryInterface.changeColumn("webhook_subscriptions", "teamId", {
type: Sequelize.UUID, type: Sequelize.UUID,
allowNull: false, allowNull: false,
@@ -22,5 +28,5 @@ module.exports = {
model: "teams", model: "teams",
}, },
}); });
} },
}; };
@@ -1,8 +1,11 @@
'use strict'; "use strict";
module.exports = { module.exports = {
up: async (queryInterface, Sequelize) => { up: async (queryInterface, Sequelize) => {
await queryInterface.removeConstraint("integrations", "integrations_collectionId_fkey") await queryInterface.removeConstraint(
"integrations",
"integrations_collectionId_fkey"
);
await queryInterface.changeColumn("integrations", "collectionId", { await queryInterface.changeColumn("integrations", "collectionId", {
type: Sequelize.UUID, type: Sequelize.UUID,
allowNull: true, allowNull: true,
@@ -11,7 +14,10 @@ module.exports = {
model: "collections", model: "collections",
}, },
}); });
await queryInterface.removeConstraint("integrations", "integrations_teamId_fkey") await queryInterface.removeConstraint(
"integrations",
"integrations_teamId_fkey"
);
await queryInterface.changeColumn("integrations", "teamId", { await queryInterface.changeColumn("integrations", "teamId", {
type: Sequelize.UUID, type: Sequelize.UUID,
allowNull: false, allowNull: false,
@@ -23,7 +29,10 @@ module.exports = {
}, },
down: async (queryInterface, Sequelize) => { down: async (queryInterface, Sequelize) => {
await queryInterface.removeConstraint("integrations", "integrations_collectionId_fkey") await queryInterface.removeConstraint(
"integrations",
"integrations_collectionId_fkey"
);
await queryInterface.changeColumn("integrations", "collectionId", { await queryInterface.changeColumn("integrations", "collectionId", {
type: Sequelize.UUID, type: Sequelize.UUID,
allowNull: true, allowNull: true,
@@ -31,7 +40,10 @@ module.exports = {
model: "collections", model: "collections",
}, },
}); });
await queryInterface.removeConstraint("integrations", "integrations_teamId_fkey") await queryInterface.removeConstraint(
"integrations",
"integrations_teamId_fkey"
);
await queryInterface.changeColumn("integrations", "teamId", { await queryInterface.changeColumn("integrations", "teamId", {
type: Sequelize.UUID, type: Sequelize.UUID,
allowNull: false, allowNull: false,
@@ -39,5 +51,5 @@ module.exports = {
model: "teams", model: "teams",
}, },
}); });
} },
}; };
@@ -1,8 +1,8 @@
'use strict'; "use strict";
module.exports = { module.exports = {
up: async (queryInterface, Sequelize) => { up: async (queryInterface, Sequelize) => {
await queryInterface.removeConstraint("stars", "stars_collectionId_fkey") await queryInterface.removeConstraint("stars", "stars_collectionId_fkey");
await queryInterface.changeColumn("stars", "collectionId", { await queryInterface.changeColumn("stars", "collectionId", {
type: Sequelize.UUID, type: Sequelize.UUID,
allowNull: true, allowNull: true,
@@ -14,7 +14,7 @@ module.exports = {
}, },
down: async (queryInterface, Sequelize) => { down: async (queryInterface, Sequelize) => {
await queryInterface.removeConstraint("stars", "stars_collectionId_fkey") await queryInterface.removeConstraint("stars", "stars_collectionId_fkey");
await queryInterface.changeColumn("stars", "collectionId", { await queryInterface.changeColumn("stars", "collectionId", {
type: Sequelize.UUID, type: Sequelize.UUID,
allowNull: true, allowNull: true,
@@ -22,5 +22,5 @@ module.exports = {
model: "collections", model: "collections",
}, },
}); });
} },
}; };
@@ -1,11 +1,19 @@
'use strict'; "use strict";
module.exports = { module.exports = {
async up(queryInterface, Sequelize) { async up(queryInterface, Sequelize) {
await queryInterface.addIndex("integrations", ["teamId", "type", "service"]); await queryInterface.addIndex("integrations", [
"teamId",
"type",
"service",
]);
}, },
async down(queryInterface, Sequelize) { async down(queryInterface, Sequelize) {
await queryInterface.removeIndex("integrations", ["teamId", "type", "service"]); await queryInterface.removeIndex("integrations", [
} "teamId",
"type",
"service",
]);
},
}; };
@@ -20,7 +20,7 @@ module.exports = {
"SELECT id FROM users", "SELECT id FROM users",
{ {
type: queryInterface.sequelize.QueryTypes.SELECT, type: queryInterface.sequelize.QueryTypes.SELECT,
transaction transaction,
} }
); );
@@ -30,13 +30,12 @@ module.exports = {
{ {
type: queryInterface.sequelize.QueryTypes.SELECT, type: queryInterface.sequelize.QueryTypes.SELECT,
replacements: { userId: user.id }, replacements: { userId: user.id },
transaction transaction,
} }
); );
const eventTypes = settings.map((setting) => setting.event); const eventTypes = settings.map((setting) => setting.event);
if (eventTypes.length > 0) { if (eventTypes.length > 0) {
const notificationSettings = {}; const notificationSettings = {};
@@ -52,7 +51,7 @@ module.exports = {
userId: user.id, userId: user.id,
notificationSettings: JSON.stringify(notificationSettings), notificationSettings: JSON.stringify(notificationSettings),
}, },
transaction transaction,
} }
); );
} }
@@ -62,5 +61,5 @@ module.exports = {
async down(queryInterface) { async down(queryInterface) {
return queryInterface.removeColumn("users", "notificationSettings"); return queryInterface.removeColumn("users", "notificationSettings");
} },
}; };
@@ -1,4 +1,4 @@
'use strict'; "use strict";
module.exports = { module.exports = {
up: async (queryInterface, Sequelize) => { up: async (queryInterface, Sequelize) => {
@@ -31,8 +31,8 @@ module.exports = {
}, },
down: async (queryInterface) => { down: async (queryInterface) => {
await queryInterface.removeColumn("notifications", "collectionId") await queryInterface.removeColumn("notifications", "collectionId");
await queryInterface.removeColumn("notifications", "revisionId") await queryInterface.removeColumn("notifications", "revisionId");
await queryInterface.removeColumn("notifications", "commentId") await queryInterface.removeColumn("notifications", "commentId");
} },
}; };
@@ -1,4 +1,4 @@
'use strict'; "use strict";
module.exports = { module.exports = {
async up(queryInterface) { async up(queryInterface) {
@@ -52,5 +52,5 @@ module.exports = {
type: queryInterface.sequelize.QueryTypes.SELECT, type: queryInterface.sequelize.QueryTypes.SELECT,
} }
); );
} },
}; };
@@ -1,4 +1,4 @@
'use strict'; "use strict";
module.exports = { module.exports = {
async up(queryInterface, Sequelize) { async up(queryInterface, Sequelize) {
@@ -6,6 +6,6 @@ module.exports = {
}, },
async down(queryInterface, Sequelize) { async down(queryInterface, Sequelize) {
throw new Error("Cannot undo this migration.") throw new Error("Cannot undo this migration.");
} },
}; };
@@ -1,4 +1,4 @@
'use strict'; "use strict";
module.exports = { module.exports = {
async up(queryInterface, Sequelize) { async up(queryInterface, Sequelize) {
@@ -11,5 +11,5 @@ module.exports = {
async down(queryInterface, Sequelize) { async down(queryInterface, Sequelize) {
await queryInterface.removeColumn("file_operations", "includeAttachments"); await queryInterface.removeColumn("file_operations", "includeAttachments");
} },
}; };
@@ -1,4 +1,4 @@
'use strict'; "use strict";
module.exports = { module.exports = {
async up(queryInterface, Sequelize) { async up(queryInterface, Sequelize) {
@@ -11,5 +11,5 @@ module.exports = {
async down(queryInterface, Sequelize) { async down(queryInterface, Sequelize) {
await queryInterface.removeColumn("documents", "insightsEnabled"); await queryInterface.removeColumn("documents", "insightsEnabled");
} },
}; };
@@ -1,57 +1,93 @@
'use strict'; "use strict";
module.exports = { module.exports = {
up: async (queryInterface, Sequelize) => { up: async (queryInterface, Sequelize) => {
await queryInterface.sequelize.transaction(async (transaction) => { await queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.removeConstraint("file_operations", "file_operations_collectionId_fkey", { transaction }); await queryInterface.removeConstraint(
await queryInterface.changeColumn("file_operations", "collectionId", { "file_operations",
"file_operations_collectionId_fkey",
{ transaction }
);
await queryInterface.changeColumn(
"file_operations",
"collectionId",
{
type: Sequelize.UUID, type: Sequelize.UUID,
allowNull: true, allowNull: true,
onDelete: "cascade", onDelete: "cascade",
references: { references: {
model: "collections", model: "collections",
}, },
}, { },
{
transaction, transaction,
}); }
);
await queryInterface.removeConstraint("file_operations", "file_operations_teamId_fkey", { transaction }); await queryInterface.removeConstraint(
await queryInterface.changeColumn("file_operations", "teamId", { "file_operations",
"file_operations_teamId_fkey",
{ transaction }
);
await queryInterface.changeColumn(
"file_operations",
"teamId",
{
type: Sequelize.UUID, type: Sequelize.UUID,
allowNull: false, allowNull: false,
onDelete: "cascade", onDelete: "cascade",
references: { references: {
model: "teams", model: "teams",
}, },
}, { },
transaction {
}); transaction,
}
);
}); });
}, },
down: async (queryInterface, Sequelize) => { down: async (queryInterface, Sequelize) => {
await queryInterface.sequelize.transaction(async (transaction) => { await queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.removeConstraint("file_operations", "file_operations_collectionId_fkey", { transaction }); await queryInterface.removeConstraint(
await queryInterface.changeColumn("file_operations", "collectionId", { "file_operations",
"file_operations_collectionId_fkey",
{ transaction }
);
await queryInterface.changeColumn(
"file_operations",
"collectionId",
{
type: Sequelize.UUID, type: Sequelize.UUID,
allowNull: true, allowNull: true,
references: { references: {
model: "collections", model: "collections",
}, },
}, { },
{
transaction, transaction,
}); }
);
await queryInterface.removeConstraint("file_operations", "file_operations_teamId_fkey", { transaction }); await queryInterface.removeConstraint(
await queryInterface.changeColumn("file_operations", "teamId", { "file_operations",
"file_operations_teamId_fkey",
{ transaction }
);
await queryInterface.changeColumn(
"file_operations",
"teamId",
{
type: Sequelize.UUID, type: Sequelize.UUID,
allowNull: false, allowNull: false,
references: { references: {
model: "teams", model: "teams",
}, },
}, { },
{
transaction, transaction,
});
});
} }
);
});
},
}; };
@@ -1,4 +1,4 @@
'use strict'; "use strict";
module.exports = { module.exports = {
async up(queryInterface, Sequelize) { async up(queryInterface, Sequelize) {
@@ -10,5 +10,5 @@ module.exports = {
async down(queryInterface) { async down(queryInterface) {
await queryInterface.removeColumn("revisions", "emoji"); await queryInterface.removeColumn("revisions", "emoji");
} },
}; };
@@ -1,4 +1,4 @@
'use strict'; "use strict";
module.exports = { module.exports = {
async up(queryInterface, Sequelize) { async up(queryInterface, Sequelize) {
@@ -10,5 +10,5 @@ module.exports = {
async down(queryInterface) { async down(queryInterface) {
await queryInterface.removeColumn("file_operations", "deletedAt"); await queryInterface.removeColumn("file_operations", "deletedAt");
} },
}; };
@@ -1,4 +1,4 @@
'use strict'; "use strict";
module.exports = { module.exports = {
async up(queryInterface, Sequelize) { async up(queryInterface, Sequelize) {
@@ -11,5 +11,5 @@ module.exports = {
async down(queryInterface) { async down(queryInterface) {
await queryInterface.removeColumn("shares", "domain"); await queryInterface.removeColumn("shares", "domain");
} },
}; };
@@ -1,4 +1,4 @@
'use strict'; "use strict";
module.exports = { module.exports = {
async up(queryInterface, Sequelize) { async up(queryInterface, Sequelize) {
@@ -10,5 +10,5 @@ module.exports = {
async down(queryInterface) { async down(queryInterface) {
await queryInterface.removeColumn("documents", "sourceMetadata"); await queryInterface.removeColumn("documents", "sourceMetadata");
} },
}; };
@@ -1,4 +1,4 @@
'use strict'; "use strict";
module.exports = { module.exports = {
async up(queryInterface, Sequelize) { async up(queryInterface, Sequelize) {
@@ -15,5 +15,5 @@ module.exports = {
async down(queryInterface) { async down(queryInterface) {
await queryInterface.removeColumn("revisions", "content"); await queryInterface.removeColumn("revisions", "content");
await queryInterface.removeColumn("documents", "content"); await queryInterface.removeColumn("documents", "content");
} },
}; };
@@ -1,8 +1,11 @@
'use strict'; "use strict";
module.exports = { module.exports = {
up: async (queryInterface, Sequelize) => { up: async (queryInterface, Sequelize) => {
await queryInterface.removeConstraint("webhook_subscriptions", "webhook_subscriptions_createdById_fkey") await queryInterface.removeConstraint(
"webhook_subscriptions",
"webhook_subscriptions_createdById_fkey"
);
await queryInterface.changeColumn("webhook_subscriptions", "createdById", { await queryInterface.changeColumn("webhook_subscriptions", "createdById", {
type: Sequelize.UUID, type: Sequelize.UUID,
onDelete: "cascade", onDelete: "cascade",
@@ -13,12 +16,15 @@ module.exports = {
}, },
down: async (queryInterface, Sequelize) => { down: async (queryInterface, Sequelize) => {
await queryInterface.removeConstraint("webhook_subscriptions", "webhook_subscriptions_createdById_fkey") await queryInterface.removeConstraint(
"webhook_subscriptions",
"webhook_subscriptions_createdById_fkey"
);
await queryInterface.changeColumn("webhook_subscriptions", "createdById", { await queryInterface.changeColumn("webhook_subscriptions", "createdById", {
type: Sequelize.UUID, type: Sequelize.UUID,
references: { references: {
model: "users", model: "users",
}, },
}); });
} },
}; };
@@ -11,7 +11,10 @@ module.exports = {
allowNull: true, allowNull: true,
}); });
await queryInterface.removeConstraint("user_permissions", "user_permissions_documentId_fkey") await queryInterface.removeConstraint(
"user_permissions",
"user_permissions_documentId_fkey"
);
await queryInterface.changeColumn("user_permissions", "documentId", { await queryInterface.changeColumn("user_permissions", "documentId", {
type: Sequelize.UUID, type: Sequelize.UUID,
onDelete: "cascade", onDelete: "cascade",
@@ -21,7 +24,10 @@ module.exports = {
}); });
}, },
async down(queryInterface) { async down(queryInterface) {
await queryInterface.removeConstraint("user_permissions", "user_permissions_documentId_fkey") await queryInterface.removeConstraint(
"user_permissions",
"user_permissions_documentId_fkey"
);
await queryInterface.changeColumn("user_permissions", "documentId", { await queryInterface.changeColumn("user_permissions", "documentId", {
type: Sequelize.UUID, type: Sequelize.UUID,
references: { references: {
@@ -1,8 +1,11 @@
'use strict'; "use strict";
module.exports = { module.exports = {
up: async (queryInterface, Sequelize) => { up: async (queryInterface, Sequelize) => {
await queryInterface.removeConstraint("comments", "comments_createdById_fkey") await queryInterface.removeConstraint(
"comments",
"comments_createdById_fkey"
);
await queryInterface.changeColumn("comments", "createdById", { await queryInterface.changeColumn("comments", "createdById", {
type: Sequelize.UUID, type: Sequelize.UUID,
onDelete: "cascade", onDelete: "cascade",
@@ -11,7 +14,10 @@ module.exports = {
}, },
}); });
await queryInterface.removeConstraint("comments", "comments_resolvedById_fkey") await queryInterface.removeConstraint(
"comments",
"comments_resolvedById_fkey"
);
await queryInterface.changeColumn("comments", "resolvedById", { await queryInterface.changeColumn("comments", "resolvedById", {
type: Sequelize.UUID, type: Sequelize.UUID,
onDelete: "set null", onDelete: "set null",
@@ -22,7 +28,10 @@ module.exports = {
}, },
down: async (queryInterface, Sequelize) => { down: async (queryInterface, Sequelize) => {
await queryInterface.removeConstraint("comments", "comments_resolvedById_fkey") await queryInterface.removeConstraint(
"comments",
"comments_resolvedById_fkey"
);
await queryInterface.changeColumn("comments", "resolvedById", { await queryInterface.changeColumn("comments", "resolvedById", {
type: Sequelize.UUID, type: Sequelize.UUID,
references: { references: {
@@ -30,12 +39,15 @@ module.exports = {
}, },
}); });
await queryInterface.removeConstraint("comments", "comments_createdById_fkey") await queryInterface.removeConstraint(
"comments",
"comments_createdById_fkey"
);
await queryInterface.changeColumn("comments", "createdById", { await queryInterface.changeColumn("comments", "createdById", {
type: Sequelize.UUID, type: Sequelize.UUID,
references: { references: {
model: "users", model: "users",
}, },
}); });
} },
}; };
@@ -6,7 +6,6 @@ module.exports = {
type: Sequelize.JSONB, type: Sequelize.JSONB,
allowNull: true, allowNull: true,
}); });
}, },
async down(queryInterface) { async down(queryInterface) {
await queryInterface.removeColumn("events", "changes"); await queryInterface.removeColumn("events", "changes");
@@ -1,8 +1,11 @@
'use strict'; "use strict";
module.exports = { module.exports = {
up: async (queryInterface, Sequelize) => { up: async (queryInterface, Sequelize) => {
await queryInterface.removeConstraint("search_queries", "search_queries_shareId_fkey") await queryInterface.removeConstraint(
"search_queries",
"search_queries_shareId_fkey"
);
await queryInterface.changeColumn("search_queries", "shareId", { await queryInterface.changeColumn("search_queries", "shareId", {
type: Sequelize.UUID, type: Sequelize.UUID,
allowNull: true, allowNull: true,
@@ -14,7 +17,10 @@ module.exports = {
}, },
down: async (queryInterface, Sequelize) => { down: async (queryInterface, Sequelize) => {
await queryInterface.removeConstraint("search_queries", "search_queries_shareId_fkey") await queryInterface.removeConstraint(
"search_queries",
"search_queries_shareId_fkey"
);
await queryInterface.changeColumn("search_queries", "shareId", { await queryInterface.changeColumn("search_queries", "shareId", {
type: Sequelize.UUID, type: Sequelize.UUID,
allowNull: true, allowNull: true,
@@ -22,5 +28,5 @@ module.exports = {
model: "shares", model: "shares",
}, },
}); });
} },
}; };
@@ -1,4 +1,4 @@
'use strict'; "use strict";
module.exports = { module.exports = {
async up(queryInterface, Sequelize) { async up(queryInterface, Sequelize) {
@@ -10,5 +10,5 @@ module.exports = {
async down(queryInterface) { async down(queryInterface) {
await queryInterface.removeColumn("authentications", "refreshToken"); await queryInterface.removeColumn("authentications", "refreshToken");
} },
}; };
@@ -1,4 +1,4 @@
'use strict'; "use strict";
/** @type {import('sequelize-cli').Migration} */ /** @type {import('sequelize-cli').Migration} */
module.exports = { module.exports = {
@@ -42,5 +42,5 @@ module.exports = {
transaction, transaction,
}); });
}); });
} },
}; };
@@ -1,4 +1,4 @@
'use strict'; "use strict";
module.exports = { module.exports = {
async up(queryInterface, Sequelize) { async up(queryInterface, Sequelize) {
@@ -37,5 +37,5 @@ module.exports = {
async down(queryInterface) { async down(queryInterface) {
await queryInterface.removeColumn("users", "role"); await queryInterface.removeColumn("users", "role");
} },
}; };
@@ -1,15 +1,15 @@
'use strict'; "use strict";
module.exports = { module.exports = {
async up(queryInterface, Sequelize) { async up(queryInterface, Sequelize) {
await queryInterface.sequelize.query( await queryInterface.sequelize.query(
'ALTER TABLE users ALTER COLUMN role SET NOT NULL;' "ALTER TABLE users ALTER COLUMN role SET NOT NULL;"
); );
}, },
async down(queryInterface) { async down(queryInterface) {
await queryInterface.sequelize.query( await queryInterface.sequelize.query(
'ALTER TABLE users ALTER COLUMN role DROP NOT NULL;' "ALTER TABLE users ALTER COLUMN role DROP NOT NULL;"
); );
} },
}; };
@@ -1,4 +1,4 @@
'use strict'; "use strict";
module.exports = { module.exports = {
async up(queryInterface) { async up(queryInterface) {
@@ -38,5 +38,5 @@ module.exports = {
} }
); );
}); });
} },
}; };
@@ -3,7 +3,7 @@
/** @type {import('sequelize-cli').Migration} */ /** @type {import('sequelize-cli').Migration} */
module.exports = { module.exports = {
async up(queryInterface, Sequelize) { async up(queryInterface, Sequelize) {
await queryInterface.sequelize.transaction(async transaction => { await queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.addColumn( await queryInterface.addColumn(
"documents", "documents",
"icon", "icon",
@@ -69,7 +69,7 @@ module.exports = {
}, },
async down(queryInterface, Sequelize) { async down(queryInterface, Sequelize) {
await queryInterface.sequelize.transaction(async transaction => { await queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.removeColumn("documents", "icon", { transaction }); await queryInterface.removeColumn("documents", "icon", { transaction });
await queryInterface.removeColumn("revisions", "icon", { transaction }); await queryInterface.removeColumn("revisions", "icon", { transaction });
await queryInterface.removeColumn("documents", "color", { transaction }); await queryInterface.removeColumn("documents", "color", { transaction });
@@ -3,14 +3,14 @@
/** @type {import('sequelize-cli').Migration} */ /** @type {import('sequelize-cli').Migration} */
module.exports = { module.exports = {
async up(queryInterface, Sequelize) { async up(queryInterface, Sequelize) {
await queryInterface.sequelize.transaction(async transaction => { await queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.removeColumn("documents", "emoji", { transaction }); await queryInterface.removeColumn("documents", "emoji", { transaction });
await queryInterface.removeColumn("revisions", "emoji", { transaction }); await queryInterface.removeColumn("revisions", "emoji", { transaction });
}); });
}, },
async down(queryInterface, Sequelize) { async down(queryInterface, Sequelize) {
await queryInterface.sequelize.transaction(async transaction => { await queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.addColumn( await queryInterface.addColumn(
"documents", "documents",
"emoji", "emoji",
@@ -11,7 +11,10 @@ module.exports = {
allowNull: true, allowNull: true,
}); });
await queryInterface.removeConstraint("group_permissions", "group_permissions_documentId_fkey") await queryInterface.removeConstraint(
"group_permissions",
"group_permissions_documentId_fkey"
);
await queryInterface.changeColumn("group_permissions", "documentId", { await queryInterface.changeColumn("group_permissions", "documentId", {
type: Sequelize.UUID, type: Sequelize.UUID,
onDelete: "cascade", onDelete: "cascade",
@@ -21,7 +24,10 @@ module.exports = {
}); });
}, },
async down(queryInterface) { async down(queryInterface) {
await queryInterface.removeConstraint("group_permissions", "group_permissions_documentId_fkey") await queryInterface.removeConstraint(
"group_permissions",
"group_permissions_documentId_fkey"
);
await queryInterface.changeColumn("group_permissions", "documentId", { await queryInterface.changeColumn("group_permissions", "documentId", {
type: Sequelize.UUID, type: Sequelize.UUID,
references: { references: {
@@ -1,4 +1,4 @@
'use strict'; "use strict";
/** @type {import('sequelize-cli').Migration} */ /** @type {import('sequelize-cli').Migration} */
module.exports = { module.exports = {
@@ -10,5 +10,5 @@ module.exports = {
async down() { async down() {
// No reverting possible // No reverting possible
} },
}; };
@@ -1,9 +1,9 @@
'use strict'; "use strict";
/** @type {import('sequelize-cli').Migration} */ /** @type {import('sequelize-cli').Migration} */
module.exports = { module.exports = {
async up(queryInterface) { async up(queryInterface) {
await queryInterface.removeColumn('group_users', 'deletedAt'); await queryInterface.removeColumn("group_users", "deletedAt");
// Cleanup any rows with duplicate groupId + userId // Cleanup any rows with duplicate groupId + userId
await queryInterface.sequelize.query(` await queryInterface.sequelize.query(`
@@ -16,21 +16,24 @@ module.exports = {
`); `);
// Add groupId + userId as primary key // Add groupId + userId as primary key
await queryInterface.addConstraint('group_users', { await queryInterface.addConstraint("group_users", {
fields: ['groupId', 'userId'], fields: ["groupId", "userId"],
type: 'primary key', type: "primary key",
name: 'group_users_pkey' name: "group_users_pkey",
}); });
await queryInterface.removeIndex("group_users", "group_users_group_id_user_id"); await queryInterface.removeIndex(
"group_users",
"group_users_group_id_user_id"
);
}, },
async down(queryInterface, Sequelize) { async down(queryInterface, Sequelize) {
await queryInterface.addIndex("group_users", ["groupId", "userId"]); await queryInterface.addIndex("group_users", ["groupId", "userId"]);
await queryInterface.removeConstraint('group_users', 'group_users_pkey'); await queryInterface.removeConstraint("group_users", "group_users_pkey");
await queryInterface.addColumn('group_users', 'deletedAt', { await queryInterface.addColumn("group_users", "deletedAt", {
type: Sequelize.DATE, type: Sequelize.DATE,
allowNull: true allowNull: true,
}); });
} },
}; };
@@ -1,12 +1,12 @@
'use strict'; "use strict";
/** @type {import('sequelize-cli').Migration} */ /** @type {import('sequelize-cli').Migration} */
module.exports = { module.exports = {
async up(queryInterface, Sequelize) { async up(queryInterface, Sequelize) {
await queryInterface.addIndex('notifications', ['teamId', 'userId']); await queryInterface.addIndex("notifications", ["teamId", "userId"]);
}, },
async down(queryInterface, Sequelize) { async down(queryInterface, Sequelize) {
await queryInterface.removeIndex('notifications', ['teamId', 'userId']); await queryInterface.removeIndex("notifications", ["teamId", "userId"]);
} },
}; };
@@ -1,12 +1,15 @@
'use strict'; "use strict";
/** @type {import('sequelize-cli').Migration} */ /** @type {import('sequelize-cli').Migration} */
module.exports = { module.exports = {
async up(queryInterface, Sequelize) { async up(queryInterface, Sequelize) {
await queryInterface.addIndex('user_permissions', ['documentId', 'userId']); await queryInterface.addIndex("user_permissions", ["documentId", "userId"]);
}, },
async down(queryInterface, Sequelize) { async down(queryInterface, Sequelize) {
await queryInterface.removeIndex('user_permissions', ['documentId', 'userId']); await queryInterface.removeIndex("user_permissions", [
} "documentId",
"userId",
]);
},
}; };
@@ -1,12 +1,12 @@
'use strict'; "use strict";
/** @type {import('sequelize-cli').Migration} */ /** @type {import('sequelize-cli').Migration} */
module.exports = { module.exports = {
async up(queryInterface, Sequelize) { async up(queryInterface, Sequelize) {
await queryInterface.addIndex('user_authentications', ['userId']); await queryInterface.addIndex("user_authentications", ["userId"]);
}, },
async down(queryInterface, Sequelize) { async down(queryInterface, Sequelize) {
await queryInterface.removeIndex('user_authentications', ['userId']); await queryInterface.removeIndex("user_authentications", ["userId"]);
} },
}; };
@@ -1,35 +1,55 @@
'use strict'; "use strict";
/** @type {import('sequelize-cli').Migration} */ /** @type {import('sequelize-cli').Migration} */
module.exports = { module.exports = {
async up(queryInterface, Sequelize) { async up(queryInterface, Sequelize) {
await queryInterface.sequelize.transaction(async transaction => { await queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.addColumn("apiKeys", "hash", { await queryInterface.addColumn(
"apiKeys",
"hash",
{
type: Sequelize.STRING, type: Sequelize.STRING,
allowNull: true, allowNull: true,
unique: true, unique: true,
}, { transaction }); },
{ transaction }
);
await queryInterface.addColumn("apiKeys", "last4", { await queryInterface.addColumn(
"apiKeys",
"last4",
{
type: Sequelize.STRING(4), type: Sequelize.STRING(4),
allowNull: true, allowNull: true,
}, { transaction }); },
{ transaction }
);
await queryInterface.changeColumn("apiKeys", "secret", { await queryInterface.changeColumn(
"apiKeys",
"secret",
{
type: Sequelize.STRING, type: Sequelize.STRING,
allowNull: true, allowNull: true,
}, { transaction }); },
{ transaction }
);
}); });
}, },
async down(queryInterface, Sequelize) { async down(queryInterface, Sequelize) {
await queryInterface.sequelize.transaction(async transaction => { await queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.removeColumn("apiKeys", "hash", { transaction }); await queryInterface.removeColumn("apiKeys", "hash", { transaction });
await queryInterface.removeColumn("apiKeys", "last4", { transaction }); await queryInterface.removeColumn("apiKeys", "last4", { transaction });
await queryInterface.changeColumn("apiKeys", "secret", { await queryInterface.changeColumn(
"apiKeys",
"secret",
{
type: Sequelize.STRING, type: Sequelize.STRING,
allowNull: false, allowNull: false,
}, { transaction }); },
{ transaction }
);
}); });
} },
}; };
@@ -3,7 +3,7 @@
/** @type {import('sequelize-cli').Migration} */ /** @type {import('sequelize-cli').Migration} */
module.exports = { module.exports = {
async up(queryInterface, Sequelize) { async up(queryInterface, Sequelize) {
await queryInterface.sequelize.transaction(async transaction => { await queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.createTable( await queryInterface.createTable(
"reactions", "reactions",
{ {
@@ -64,7 +64,7 @@ module.exports = {
}, },
async down(queryInterface, Sequelize) { async down(queryInterface, Sequelize) {
queryInterface.sequelize.transaction(async transaction => { queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.dropTable("reactions", { transaction }); await queryInterface.dropTable("reactions", { transaction });
await queryInterface.removeColumn("comments", "reactions", { await queryInterface.removeColumn("comments", "reactions", {
transaction, transaction,
@@ -3,19 +3,32 @@
/** @type {import('sequelize-cli').Migration} */ /** @type {import('sequelize-cli').Migration} */
module.exports = { module.exports = {
async up(queryInterface, Sequelize) { async up(queryInterface, Sequelize) {
await queryInterface.sequelize.transaction(async transaction => { await queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.addColumn("teams", "approximateTotalAttachmentsSize", { await queryInterface.addColumn(
"teams",
"approximateTotalAttachmentsSize",
{
type: Sequelize.BIGINT, type: Sequelize.BIGINT,
defaultValue: 0, defaultValue: 0,
}, { transaction }); },
await queryInterface.addIndex("attachments", ["createdAt"], { transaction }); { transaction }
);
await queryInterface.addIndex("attachments", ["createdAt"], {
transaction,
});
}); });
}, },
async down(queryInterface, Sequelize) { async down(queryInterface, Sequelize) {
await queryInterface.sequelize.transaction(async transaction => { await queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.removeIndex("attachments", ["createdAt"], { transaction }); await queryInterface.removeIndex("attachments", ["createdAt"], {
await queryInterface.removeColumn("teams", "approximateTotalAttachmentsSize", { transaction }); transaction,
});
await queryInterface.removeColumn(
"teams",
"approximateTotalAttachmentsSize",
{ transaction }
);
}); });
}, },
}; };
@@ -3,22 +3,39 @@
/** @type {import('sequelize-cli').Migration} */ /** @type {import('sequelize-cli').Migration} */
module.exports = { module.exports = {
async up(queryInterface, Sequelize) { async up(queryInterface, Sequelize) {
await queryInterface.sequelize.transaction(async transaction => { await queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.addColumn("groups", "externalId", { await queryInterface.addColumn(
"groups",
"externalId",
{
type: Sequelize.STRING, type: Sequelize.STRING,
}, { transaction }); },
{ transaction }
);
await queryInterface.addIndex("groups", ["externalId"], { transaction }); await queryInterface.addIndex("groups", ["externalId"], { transaction });
await queryInterface.addIndex("group_permissions", ["documentId"], { transaction }); await queryInterface.addIndex("group_permissions", ["documentId"], {
await queryInterface.addIndex("group_permissions", ["sourceId"], { transaction }); transaction,
});
await queryInterface.addIndex("group_permissions", ["sourceId"], {
transaction,
});
}); });
}, },
async down(queryInterface, Sequelize) { async down(queryInterface, Sequelize) {
await queryInterface.sequelize.transaction(async transaction => { await queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.removeIndex("group_permissions", ["sourceId"], { transaction }); await queryInterface.removeIndex("group_permissions", ["sourceId"], {
await queryInterface.removeIndex("group_permissions", ["documentId"], { transaction }); transaction,
await queryInterface.removeIndex("groups", ["externalId"], { transaction }); });
await queryInterface.removeColumn("groups", "externalId", { transaction }); await queryInterface.removeIndex("group_permissions", ["documentId"], {
transaction,
});
await queryInterface.removeIndex("groups", ["externalId"], {
transaction,
});
await queryInterface.removeColumn("groups", "externalId", {
transaction,
});
}); });
}, },
}; };
@@ -3,16 +3,21 @@
/** @type {import('sequelize-cli').Migration} */ /** @type {import('sequelize-cli').Migration} */
module.exports = { module.exports = {
async up(queryInterface, Sequelize) { async up(queryInterface, Sequelize) {
await queryInterface.sequelize.transaction(async transaction => { await queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.addColumn("apiKeys", "scope", { await queryInterface.addColumn(
"apiKeys",
"scope",
{
type: Sequelize.ARRAY(Sequelize.STRING), type: Sequelize.ARRAY(Sequelize.STRING),
allowNull: true, allowNull: true,
}, { transaction }); },
{ transaction }
);
}); });
}, },
async down(queryInterface) { async down(queryInterface) {
await queryInterface.sequelize.transaction(async transaction => { await queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.removeColumn("apiKeys", "scope", { transaction }); await queryInterface.removeColumn("apiKeys", "scope", { transaction });
}); });
}, },
@@ -3,7 +3,7 @@
/** @type {import('sequelize-cli').Migration} */ /** @type {import('sequelize-cli').Migration} */
module.exports = { module.exports = {
async up(queryInterface, Sequelize) { async up(queryInterface, Sequelize) {
await queryInterface.sequelize.transaction(async transaction => { await queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.addColumn( await queryInterface.addColumn(
"subscriptions", "subscriptions",
"collectionId", "collectionId",
@@ -30,7 +30,7 @@ module.exports = {
}, },
async down(queryInterface, Sequelize) { async down(queryInterface, Sequelize) {
await queryInterface.sequelize.transaction(async transaction => { await queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.removeIndex( await queryInterface.removeIndex(
"subscriptions", "subscriptions",
["userId", "collectionId", "event"], ["userId", "collectionId", "event"],
@@ -1,19 +1,19 @@
'use strict'; "use strict";
/** @type {import('sequelize-cli').Migration} */ /** @type {import('sequelize-cli').Migration} */
module.exports = { module.exports = {
async up(queryInterface) { async up(queryInterface) {
await queryInterface.sequelize.query( await queryInterface.sequelize.query(
`CREATE EXTENSION IF NOT EXISTS "pg_trgm";`, `CREATE EXTENSION IF NOT EXISTS "pg_trgm";`
); );
await queryInterface.sequelize.query( await queryInterface.sequelize.query(
`CREATE INDEX CONCURRENTLY documents_title_idx ON documents USING GIN (title gin_trgm_ops);`, `CREATE INDEX CONCURRENTLY documents_title_idx ON documents USING GIN (title gin_trgm_ops);`
); );
}, },
async down(queryInterface) { async down(queryInterface) {
await queryInterface.sequelize.query( await queryInterface.sequelize.query(
`DROP INDEX CONCURRENTLY documents_title_idx;`, `DROP INDEX CONCURRENTLY documents_title_idx;`
); );
} },
}; };
@@ -3,11 +3,16 @@
/** @type {import('sequelize-cli').Migration} */ /** @type {import('sequelize-cli').Migration} */
module.exports = { module.exports = {
async up(queryInterface, Sequelize) { async up(queryInterface, Sequelize) {
await queryInterface.sequelize.transaction(async transaction => { await queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.addColumn("teams", "previousSubdomains", { await queryInterface.addColumn(
"teams",
"previousSubdomains",
{
type: Sequelize.ARRAY(Sequelize.STRING), type: Sequelize.ARRAY(Sequelize.STRING),
allowNull: true, allowNull: true,
}, { transaction }); },
{ transaction }
);
await queryInterface.sequelize.query( await queryInterface.sequelize.query(
`CREATE INDEX teams_previous_subdomains ON teams USING GIN ("previousSubdomains");`, `CREATE INDEX teams_previous_subdomains ON teams USING GIN ("previousSubdomains");`,
{ transaction } { transaction }
@@ -16,12 +21,14 @@ module.exports = {
}, },
async down(queryInterface) { async down(queryInterface) {
await queryInterface.sequelize.transaction(async transaction => { await queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.sequelize.query( await queryInterface.sequelize.query(
`DROP INDEX teams_previous_subdomains;`, `DROP INDEX teams_previous_subdomains;`,
{ transaction } { transaction }
); );
await queryInterface.removeColumn("teams", "previousSubdomains", { transaction }); await queryInterface.removeColumn("teams", "previousSubdomains", {
transaction,
});
}); });
}, },
}; };
@@ -4,7 +4,7 @@ const tableName = "team_domains";
const constraintNames = [ const constraintNames = [
"team_domains_createdById_fkey", "team_domains_createdById_fkey",
"createdById_foreign_idx" "createdById_foreign_idx",
]; ];
module.exports = { module.exports = {
@@ -3,7 +3,7 @@
/** @type {import('sequelize-cli').Migration} */ /** @type {import('sequelize-cli').Migration} */
module.exports = { module.exports = {
async up(queryInterface, Sequelize) { async up(queryInterface, Sequelize) {
await queryInterface.sequelize.transaction(async transaction => { await queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.createTable( await queryInterface.createTable(
"imports", "imports",
{ {
@@ -80,7 +80,7 @@ module.exports = {
}, },
async down(queryInterface, Sequelize) { async down(queryInterface, Sequelize) {
await queryInterface.sequelize.transaction(async transaction => { await queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.removeIndex("imports", ["service", "teamId"], { await queryInterface.removeIndex("imports", ["service", "teamId"], {
transaction, transaction,
}); });
@@ -3,7 +3,7 @@
/** @type {import('sequelize-cli').Migration} */ /** @type {import('sequelize-cli').Migration} */
module.exports = { module.exports = {
async up(queryInterface, Sequelize) { async up(queryInterface, Sequelize) {
await queryInterface.sequelize.transaction(async transaction => { await queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.createTable( await queryInterface.createTable(
"import_tasks", "import_tasks",
{ {
@@ -54,7 +54,7 @@ module.exports = {
}, },
async down(queryInterface, Sequelize) { async down(queryInterface, Sequelize) {
await queryInterface.sequelize.transaction(async transaction => { await queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.removeIndex("import_tasks", ["importId"], { await queryInterface.removeIndex("import_tasks", ["importId"], {
transaction, transaction,
}); });
@@ -3,7 +3,7 @@
/** @type {import('sequelize-cli').Migration} */ /** @type {import('sequelize-cli').Migration} */
module.exports = { module.exports = {
async up(queryInterface, Sequelize) { async up(queryInterface, Sequelize) {
await queryInterface.sequelize.transaction(async transaction => { await queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.addColumn( await queryInterface.addColumn(
"collections", "collections",
"apiImportId", "apiImportId",
@@ -39,7 +39,7 @@ module.exports = {
}, },
async down(queryInterface, Sequelize) { async down(queryInterface, Sequelize) {
await queryInterface.sequelize.transaction(async transaction => { await queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.removeIndex("collections", [ await queryInterface.removeIndex("collections", [
"apiImportId", "apiImportId",
{ transaction }, { transaction },
@@ -3,7 +3,7 @@
/** @type {import('sequelize-cli').Migration} */ /** @type {import('sequelize-cli').Migration} */
module.exports = { module.exports = {
async up(queryInterface, Sequelize) { async up(queryInterface, Sequelize) {
await queryInterface.sequelize.transaction(async transaction => { await queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.addColumn( await queryInterface.addColumn(
"imports", "imports",
"error", "error",
@@ -27,7 +27,7 @@ module.exports = {
}, },
async down(queryInterface, Sequelize) { async down(queryInterface, Sequelize) {
await queryInterface.sequelize.transaction(async transaction => { await queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.removeColumn("imports", "error", { transaction }); await queryInterface.removeColumn("imports", "error", { transaction });
await queryInterface.removeColumn("import_tasks", "error", { await queryInterface.removeColumn("import_tasks", "error", {
transaction, transaction,
@@ -4,31 +4,33 @@
module.exports = { module.exports = {
async up(queryInterface, Sequelize) { async up(queryInterface, Sequelize) {
await queryInterface.sequelize.transaction(async (transaction) => { await queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.createTable("oauth_clients", { await queryInterface.createTable(
"oauth_clients",
{
id: { id: {
type: Sequelize.UUID, type: Sequelize.UUID,
primaryKey: true, primaryKey: true,
allowNull: false allowNull: false,
}, },
name: { name: {
type: Sequelize.STRING, type: Sequelize.STRING,
allowNull: false allowNull: false,
}, },
description: { description: {
type: Sequelize.STRING, type: Sequelize.STRING,
allowNull: true allowNull: true,
}, },
developerName: { developerName: {
type: Sequelize.STRING, type: Sequelize.STRING,
allowNull: true allowNull: true,
}, },
developerUrl: { developerUrl: {
type: Sequelize.STRING, type: Sequelize.STRING,
allowNull: true allowNull: true,
}, },
avatarUrl: { avatarUrl: {
type: Sequelize.STRING, type: Sequelize.STRING,
allowNull: true allowNull: true,
}, },
clientId: { clientId: {
type: Sequelize.STRING, type: Sequelize.STRING,
@@ -37,12 +39,12 @@ module.exports = {
}, },
clientSecret: { clientSecret: {
type: Sequelize.BLOB, type: Sequelize.BLOB,
allowNull: false allowNull: false,
}, },
published: { published: {
type: Sequelize.BOOLEAN, type: Sequelize.BOOLEAN,
allowNull: false, allowNull: false,
defaultValue: false defaultValue: false,
}, },
teamId: { teamId: {
type: Sequelize.UUID, type: Sequelize.UUID,
@@ -50,57 +52,61 @@ module.exports = {
model: "teams", model: "teams",
}, },
allowNull: false, allowNull: false,
onDelete: "cascade" onDelete: "cascade",
}, },
createdById: { createdById: {
type: Sequelize.UUID, type: Sequelize.UUID,
references: { references: {
model: "users", model: "users",
}, },
allowNull: false allowNull: false,
}, },
redirectUris: { redirectUris: {
type: Sequelize.ARRAY(Sequelize.STRING), type: Sequelize.ARRAY(Sequelize.STRING),
allowNull: false, allowNull: false,
defaultValue: [] defaultValue: [],
}, },
createdAt: { createdAt: {
type: Sequelize.DATE, type: Sequelize.DATE,
allowNull: false allowNull: false,
}, },
updatedAt: { updatedAt: {
type: Sequelize.DATE, type: Sequelize.DATE,
allowNull: false allowNull: false,
}, },
deletedAt: { deletedAt: {
type: Sequelize.DATE, type: Sequelize.DATE,
allowNull: true allowNull: true,
},
},
{
transaction,
} }
}, { );
transaction
});
await queryInterface.createTable("oauth_authorization_codes", { await queryInterface.createTable(
"oauth_authorization_codes",
{
id: { id: {
type: Sequelize.UUID, type: Sequelize.UUID,
primaryKey: true, primaryKey: true,
allowNull: false allowNull: false,
}, },
authorizationCodeHash: { authorizationCodeHash: {
type: Sequelize.STRING, type: Sequelize.STRING,
allowNull: false allowNull: false,
}, },
codeChallenge: { codeChallenge: {
type: Sequelize.STRING, type: Sequelize.STRING,
allowNull: true allowNull: true,
}, },
codeChallengeMethod: { codeChallengeMethod: {
type: Sequelize.STRING, type: Sequelize.STRING,
allowNull: true allowNull: true,
}, },
scope: { scope: {
type: Sequelize.ARRAY(Sequelize.STRING), type: Sequelize.ARRAY(Sequelize.STRING),
allowNull: false allowNull: false,
}, },
oauthClientId: { oauthClientId: {
type: Sequelize.UUID, type: Sequelize.UUID,
@@ -108,7 +114,7 @@ module.exports = {
model: "oauth_clients", model: "oauth_clients",
}, },
onDelete: "cascade", onDelete: "cascade",
allowNull: false allowNull: false,
}, },
userId: { userId: {
type: Sequelize.UUID, type: Sequelize.UUID,
@@ -116,55 +122,59 @@ module.exports = {
model: "users", model: "users",
}, },
onDelete: "cascade", onDelete: "cascade",
allowNull: false allowNull: false,
}, },
redirectUri: { redirectUri: {
type: Sequelize.STRING, type: Sequelize.STRING,
allowNull: false allowNull: false,
}, },
expiresAt: { expiresAt: {
type: Sequelize.DATE, type: Sequelize.DATE,
allowNull: false allowNull: false,
}, },
createdAt: { createdAt: {
type: Sequelize.DATE, type: Sequelize.DATE,
allowNull: false allowNull: false,
},
},
{
transaction,
} }
}, { );
transaction
});
await queryInterface.createTable("oauth_authentications", { await queryInterface.createTable(
"oauth_authentications",
{
id: { id: {
type: Sequelize.UUID, type: Sequelize.UUID,
primaryKey: true, primaryKey: true,
allowNull: false allowNull: false,
}, },
accessTokenHash: { accessTokenHash: {
type: Sequelize.STRING, type: Sequelize.STRING,
allowNull: false, allowNull: false,
unique: true unique: true,
}, },
accessTokenExpiresAt: { accessTokenExpiresAt: {
type: Sequelize.DATE, type: Sequelize.DATE,
allowNull: false allowNull: false,
}, },
refreshTokenHash: { refreshTokenHash: {
type: Sequelize.STRING, type: Sequelize.STRING,
allowNull: false, allowNull: false,
unique: true unique: true,
}, },
refreshTokenExpiresAt: { refreshTokenExpiresAt: {
type: Sequelize.DATE, type: Sequelize.DATE,
allowNull: false allowNull: false,
}, },
lastActiveAt: { lastActiveAt: {
type: Sequelize.DATE, type: Sequelize.DATE,
allowNull: true allowNull: true,
}, },
scope: { scope: {
type: Sequelize.ARRAY(Sequelize.STRING), type: Sequelize.ARRAY(Sequelize.STRING),
allowNull: false allowNull: false,
}, },
oauthClientId: { oauthClientId: {
type: Sequelize.UUID, type: Sequelize.UUID,
@@ -172,7 +182,7 @@ module.exports = {
model: "oauth_clients", model: "oauth_clients",
}, },
onDelete: "cascade", onDelete: "cascade",
allowNull: false allowNull: false,
}, },
userId: { userId: {
type: Sequelize.UUID, type: Sequelize.UUID,
@@ -180,33 +190,39 @@ module.exports = {
model: "users", model: "users",
}, },
onDelete: "cascade", onDelete: "cascade",
allowNull: false allowNull: false,
}, },
createdAt: { createdAt: {
type: Sequelize.DATE, type: Sequelize.DATE,
allowNull: false allowNull: false,
}, },
updatedAt: { updatedAt: {
type: Sequelize.DATE, type: Sequelize.DATE,
allowNull: false allowNull: false,
}, },
deletedAt: { deletedAt: {
type: Sequelize.DATE, type: Sequelize.DATE,
allowNull: true allowNull: true,
},
},
{
transaction,
} }
}, { );
transaction
});
await queryInterface.addIndex("oauth_clients", ["teamId"], { transaction }); await queryInterface.addIndex("oauth_clients", ["teamId"], {
transaction,
});
}); });
}, },
async down(queryInterface, Sequelize) { async down(queryInterface, Sequelize) {
await queryInterface.sequelize.transaction(async (transaction) => { await queryInterface.sequelize.transaction(async (transaction) => {
await queryInterface.dropTable("oauth_authentications", { transaction }); await queryInterface.dropTable("oauth_authentications", { transaction });
await queryInterface.dropTable("oauth_authorization_codes", { transaction }); await queryInterface.dropTable("oauth_authorization_codes", {
transaction,
});
await queryInterface.dropTable("oauth_clients", { transaction }); await queryInterface.dropTable("oauth_clients", { transaction });
}); });
} },
}; };
@@ -1,9 +1,9 @@
'use strict'; "use strict";
/** @type {import('sequelize-cli').Migration} */ /** @type {import('sequelize-cli').Migration} */
module.exports = { module.exports = {
async up(queryInterface, Sequelize) { async up(queryInterface, Sequelize) {
await queryInterface.addColumn('collections', 'commenting', { await queryInterface.addColumn("collections", "commenting", {
type: Sequelize.BOOLEAN, type: Sequelize.BOOLEAN,
allowNull: true, allowNull: true,
defaultValue: null, defaultValue: null,
@@ -11,7 +11,6 @@ module.exports = {
}, },
async down(queryInterface, Sequelize) { async down(queryInterface, Sequelize) {
await queryInterface.removeColumn('collections', 'commenting'); await queryInterface.removeColumn("collections", "commenting");
} },
}; };
@@ -1,15 +1,15 @@
'use strict'; "use strict";
/** @type {import('sequelize-cli').Migration} */ /** @type {import('sequelize-cli').Migration} */
module.exports = { module.exports = {
async up(queryInterface, Sequelize) { async up(queryInterface, Sequelize) {
await queryInterface.addColumn("revisions", "deletedAt", { await queryInterface.addColumn("revisions", "deletedAt", {
type: Sequelize.DATE, type: Sequelize.DATE,
allowNull: true allowNull: true,
}); });
}, },
async down(queryInterface, Sequelize) { async down(queryInterface, Sequelize) {
await queryInterface.removeColumn("revisions", "deletedAt"); await queryInterface.removeColumn("revisions", "deletedAt");
} },
}; };

Some files were not shown because too many files have changed in this diff Show More