File tree 4 files changed +38
-0
lines changed
4 files changed +38
-0
lines changed File renamed without changes.
Original file line number Diff line number Diff line change
1
+ -- Revision Version: V7
2
+ -- Revises: V6
3
+ -- Creation Date: 2024-06-25 22:08:13.554817 UTC
4
+ -- Reason: snippets
5
+
6
+ CREATE TABLE IF NOT EXISTS snippets (
7
+ id SERIAL PRIMARY KEY ,
8
+ name TEXT ,
9
+ content TEXT ,
10
+ uses INTEGER DEFAULT (0 ),
11
+ owner_id BIGINT ,
12
+ location_id BIGINT ,
13
+ created_at TIMESTAMPTZ DEFAULT (now() at time zone ' utc' )
14
+ );
15
+
16
+ -- Create indices to speed up regular and trigram searches
17
+ CREATE INDEX IF NOT EXISTS snippets_name_idx ON snippets (name);
18
+ CREATE INDEX IF NOT EXISTS snippets_location_id_idx ON snippets (location_id);
19
+ CREATE INDEX IF NOT EXISTS snippets_name_trgm_idx ON snippets USING GIN (name gin_trgm_ops);
20
+ CREATE INDEX IF NOT EXISTS snippets_name_lower_idx ON snippets (LOWER (name));
21
+ CREATE UNIQUE INDEX IF NOT EXISTS snippets_uniq_idx ON snippets (LOWER (name), location_id);
22
+
23
+ CREATE TABLE IF NOT EXISTS snippets_lookup (
24
+ id SERIAL PRIMARY KEY ,
25
+ name TEXT ,
26
+ location_id BIGINT ,
27
+ owner_id BIGINT ,
28
+ created_at TIMESTAMPTZ DEFAULT (now() at time zone ' utc' ),
29
+ snippets_id INTEGER REFERENCES snippets (id) ON DELETE CASCADE ON UPDATE NO ACTION
30
+ );
31
+
32
+ CREATE INDEX IF NOT EXISTS snippets_lookup_name_idx ON snippets_lookup (name);
33
+ CREATE INDEX IF NOT EXISTS snippets_lookup_location_id_idx ON snippets_lookup (location_id);
34
+ CREATE INDEX IF NOT EXISTS snippets_lookup_name_trgm_idx ON snippets_lookup USING GIN (name gin_trgm_ops);
35
+ CREATE INDEX IF NOT EXISTS snippets_lookup_name_lower_idx ON snippets_lookup (LOWER (name));
36
+ CREATE UNIQUE INDEX IF NOT EXISTS snippets_lookup_uniq_idx ON snippets_lookup (LOWER (name), location_id);
Original file line number Diff line number Diff line change 4
4
psql -v ON_ERROR_STOP=1 --username " $POSTGRES_USER " --dbname " $POSTGRES_DB " << -EOSQL
5
5
CREATE ROLE rodhaj WITH LOGIN PASSWORD '$RODHAJ_PASSWORD ';
6
6
CREATE DATABASE rodhaj OWNER rodhaj;
7
+ CREATE EXTENSION IF NOT EXISTS pg_trgm;
7
8
EOSQL
Original file line number Diff line number Diff line change @@ -96,6 +96,7 @@ The following SQL queries can be used to create the user and database:
96
96
97
97
CREATE ROLE rodhaj WITH LOGIN PASSWORD 'somepass';
98
98
CREATE DATABASE rodhaj OWNER rodhaj;
99
+ CREATE EXTENSION IF NOT EXISTS pg_trgm;
99
100
100
101
.. note ::
101
102
You can’t perform that action at this time.
0 commit comments