-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading faster, and a loading screen
- Loading branch information
Showing
12 changed files
with
483 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
demos/linearlite/db/migrations-client/post-initial-sync-fts-index.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CREATE INDEX IF NOT EXISTS "issue_search_idx" ON "issue" USING GIN ((setweight(to_tsvector('simple', coalesce(title, '')), 'A') || setweight(to_tsvector('simple', coalesce(description, '')), 'B'))); |
11 changes: 11 additions & 0 deletions
11
demos/linearlite/db/migrations-client/post-initial-sync-indexes.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
CREATE INDEX IF NOT EXISTS "issue_priority_idx" ON "issue" ("priority"); | ||
CREATE INDEX IF NOT EXISTS "issue_status_idx" ON "issue" ("status"); | ||
CREATE INDEX IF NOT EXISTS "issue_modified_idx" ON "issue" ("modified"); | ||
CREATE INDEX IF NOT EXISTS "issue_created_idx" ON "issue" ("created"); | ||
CREATE INDEX IF NOT EXISTS "issue_kanbanorder_idx" ON "issue" ("kanbanorder"); | ||
CREATE INDEX IF NOT EXISTS "issue_deleted_idx" ON "issue" ("deleted"); | ||
CREATE INDEX IF NOT EXISTS "issue_synced_idx" ON "issue" ("synced"); | ||
CREATE INDEX IF NOT EXISTS "comment_issue_id_idxx" ON "comment" ("issue_id"); | ||
CREATE INDEX IF NOT EXISTS "comment_created_idx" ON "comment" ("created"); | ||
CREATE INDEX IF NOT EXISTS "comment_deleted_idx" ON "comment" ("deleted"); | ||
CREATE INDEX IF NOT EXISTS "comment_synced_idx" ON "comment" ("synced"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,30 @@ | ||
import type { PGlite } from '@electric-sql/pglite' | ||
import type { PGlite, PGliteInterface } from '@electric-sql/pglite' | ||
import m1 from '../db/migrations-client/01-create_tables.sql?raw' | ||
import postInitialSyncIndexes from '../db/migrations-client/post-initial-sync-indexes.sql?raw' | ||
import postInitialSyncFtsIndex from '../db/migrations-client/post-initial-sync-fts-index.sql?raw' | ||
|
||
export async function migrate(pg: PGlite) { | ||
await pg.exec(m1) | ||
const tables = await pg.query( | ||
`SELECT table_name FROM information_schema.tables WHERE table_schema='public'` | ||
) | ||
if (tables.rows.length === 0) { | ||
await pg.exec(m1) | ||
} | ||
} | ||
|
||
export async function postInitialSync(pg: PGliteInterface) { | ||
const commands = postInitialSyncIndexes | ||
.split('\n') | ||
.map((c) => c.trim()) | ||
.filter((c) => c.length > 0) | ||
for (const command of commands) { | ||
// wait 100ms between commands | ||
console.time(`command: ${command}`) | ||
await pg.exec(command) | ||
console.timeEnd(`command: ${command}`) | ||
} | ||
} | ||
|
||
export async function createFTSIndex(pg: PGliteInterface) { | ||
await pg.exec(postInitialSyncFtsIndex) | ||
} |
Oops, something went wrong.