mirror of
https://github.com/makeplane/plane.git
synced 2025-12-25 08:09:33 +01:00
* fix layout switching when filter is not yet completely fetched * add layout in issue filter params * Handle cases when DB intilization failed * chore: permission layer and updated issues v1 query from workspace to project level * - Switch to using wa-sqlite instead of sqlite-wasm * Code cleanup and fix indexes * Add missing files * - Import only required functions from sentry - Wait till all the tables are created * Skip workspace sync if one is already in progress. * Sync workspace without using transaction * Minor cleanup * Close DB connection before deleting files Fix clear OPFS on safari * Fix type issue * Improve issue insert performance * Refactor workspace sync * Close the DB connection while switching workspaces * Update web/core/local-db/worker/db.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Worker cleanup and error handling Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update web/core/local-db/worker/db.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update web/core/local-db/storage.sqlite.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update web/core/local-db/worker/db.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Code cleanup * Set default order by to created at and descending * Wait for transactions to complete. --------- Co-authored-by: rahulramesha <rahulramesham@gmail.com> Co-authored-by: gurusainath <gurusainath007@gmail.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
68 lines
2.2 KiB
TypeScript
68 lines
2.2 KiB
TypeScript
import { persistence } from "../storage.sqlite";
|
|
import { log } from "./utils";
|
|
|
|
export const createIssueIndexes = async () => {
|
|
const columns = [
|
|
"state_id",
|
|
"sort_order",
|
|
// "priority",
|
|
"priority_proxy",
|
|
"project_id",
|
|
"created_by",
|
|
"cycle_id",
|
|
"sequence_id",
|
|
];
|
|
|
|
const promises: Promise<any>[] = [];
|
|
|
|
promises.push(persistence.db.exec({ sql: `CREATE UNIQUE INDEX issues_issue_id_idx ON issues (id)` }));
|
|
|
|
columns.forEach((column) => {
|
|
promises.push(
|
|
persistence.db.exec({ sql: `CREATE INDEX issues_issue_${column}_idx ON issues (project_id, ${column})` })
|
|
);
|
|
});
|
|
await Promise.all(promises);
|
|
};
|
|
|
|
export const createIssueMetaIndexes = async () => {
|
|
// Drop indexes
|
|
await persistence.db.exec({ sql: `CREATE INDEX issue_meta_all_idx ON issue_meta (issue_id,key,value)` });
|
|
};
|
|
|
|
export const createWorkSpaceIndexes = async () => {
|
|
const promises: Promise<any>[] = [];
|
|
// Labels
|
|
promises.push(persistence.db.exec({ sql: `CREATE INDEX labels_name_idx ON labels (id,name,project_id)` }));
|
|
// Modules
|
|
promises.push(persistence.db.exec({ sql: `CREATE INDEX modules_name_idx ON modules (id,name,project_id)` }));
|
|
// States
|
|
promises.push(persistence.db.exec({ sql: `CREATE INDEX states_name_idx ON states (id,name,project_id)` }));
|
|
// Cycles
|
|
promises.push(persistence.db.exec({ sql: `CREATE INDEX cycles_name_idx ON cycles (id,name,project_id)` }));
|
|
|
|
// Members
|
|
promises.push(persistence.db.exec({ sql: `CREATE INDEX members_name_idx ON members (id,first_name)` }));
|
|
|
|
// Estimate Points @todo
|
|
promises.push(persistence.db.exec({ sql: `CREATE INDEX estimate_points_name_idx ON estimate_points (id,value)` }));
|
|
// Options
|
|
promises.push(persistence.db.exec({ sql: `CREATE INDEX options_key_idx ON options (key)` }));
|
|
|
|
await Promise.all(promises);
|
|
};
|
|
|
|
const createIndexes = async () => {
|
|
log("### Creating indexes");
|
|
const start = performance.now();
|
|
const promises = [createIssueIndexes(), createIssueMetaIndexes(), createWorkSpaceIndexes()];
|
|
try {
|
|
await Promise.all(promises);
|
|
} catch (e) {
|
|
console.log((e as Error).message);
|
|
}
|
|
log("### Indexes created in", `${performance.now() - start}ms`);
|
|
};
|
|
|
|
export default createIndexes;
|