Память и сейф: первый публичный выпуск 1.0.0
This commit is contained in:
commit
85ecb086fb
16 changed files with 2811 additions and 0 deletions
54
sql/schema.sql
Normal file
54
sql/schema.sql
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
-- Memory & Vault: схема PostgreSQL.
|
||||
-- Выполнить один раз в базе плагина: psql "$DSH_MEMORY_PG_URL" -f sql/schema.sql
|
||||
-- Плагин сам создаёт недостающие объекты при первом подключении, поэтому
|
||||
-- минимально достаточно: CREATE EXTENSION IF NOT EXISTS pg_trgm;
|
||||
|
||||
CREATE EXTENSION IF NOT EXISTS pg_trgm;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS memory_entries (
|
||||
id text PRIMARY KEY,
|
||||
body text NOT NULL,
|
||||
tags text[] NOT NULL DEFAULT '{}',
|
||||
scope text NOT NULL CHECK (scope IN ('global', 'workspace')),
|
||||
workspace text,
|
||||
pinned boolean NOT NULL DEFAULT false,
|
||||
collection text NOT NULL DEFAULT 'general',
|
||||
created_at timestamptz NOT NULL DEFAULT now(),
|
||||
updated_at timestamptz NOT NULL DEFAULT now(),
|
||||
synced boolean NOT NULL DEFAULT true,
|
||||
CONSTRAINT memory_scope_workspace CHECK (
|
||||
(scope = 'global' AND workspace IS NULL)
|
||||
OR (scope = 'workspace' AND workspace IS NOT NULL)
|
||||
)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS memory_entries_scope_idx
|
||||
ON memory_entries (scope, workspace);
|
||||
CREATE INDEX IF NOT EXISTS memory_entries_updated_idx
|
||||
ON memory_entries (pinned DESC, updated_at DESC);
|
||||
CREATE INDEX IF NOT EXISTS memory_entries_collection_idx
|
||||
ON memory_entries (collection, pinned DESC, updated_at DESC);
|
||||
CREATE INDEX IF NOT EXISTS memory_entries_body_trgm
|
||||
ON memory_entries USING gin (body gin_trgm_ops);
|
||||
CREATE INDEX IF NOT EXISTS memory_entries_body_tsv
|
||||
ON memory_entries USING gin (to_tsvector('russian', body));
|
||||
CREATE INDEX IF NOT EXISTS memory_entries_tags_idx
|
||||
ON memory_entries USING gin (tags);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS memory_secrets (
|
||||
id text PRIMARY KEY,
|
||||
name text NOT NULL,
|
||||
username text,
|
||||
value text NOT NULL,
|
||||
url text,
|
||||
notes text,
|
||||
tags text[] NOT NULL DEFAULT '{}',
|
||||
created_at timestamptz NOT NULL DEFAULT now(),
|
||||
updated_at timestamptz NOT NULL DEFAULT now(),
|
||||
synced boolean NOT NULL DEFAULT true
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS memory_secrets_name
|
||||
ON memory_secrets (lower(name));
|
||||
CREATE INDEX IF NOT EXISTS memory_secrets_updated
|
||||
ON memory_secrets (updated_at DESC);
|
||||
Loading…
Add table
Add a link
Reference in a new issue