123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- -- migration_history
- CREATE TABLE migration_history (
- version TEXT NOT NULL PRIMARY KEY,
- created_ts BIGINT NOT NULL DEFAULT EXTRACT(EPOCH FROM NOW())
- );
- -- system_setting
- CREATE TABLE system_setting (
- name TEXT NOT NULL PRIMARY KEY,
- value TEXT NOT NULL,
- description TEXT NOT NULL
- );
- -- user
- CREATE TABLE "user" (
- id SERIAL PRIMARY KEY,
- created_ts BIGINT NOT NULL DEFAULT EXTRACT(EPOCH FROM NOW()),
- updated_ts BIGINT NOT NULL DEFAULT EXTRACT(EPOCH FROM NOW()),
- row_status TEXT NOT NULL DEFAULT 'NORMAL',
- username TEXT NOT NULL UNIQUE,
- role TEXT NOT NULL DEFAULT 'USER',
- email TEXT NOT NULL DEFAULT '',
- nickname TEXT NOT NULL DEFAULT '',
- password_hash TEXT NOT NULL,
- avatar_url TEXT NOT NULL,
- description TEXT NOT NULL DEFAULT ''
- );
- -- user_setting
- CREATE TABLE user_setting (
- user_id INTEGER NOT NULL,
- key TEXT NOT NULL,
- value TEXT NOT NULL,
- UNIQUE(user_id, key)
- );
- -- memo
- CREATE TABLE memo (
- id SERIAL PRIMARY KEY,
- uid TEXT NOT NULL UNIQUE,
- creator_id INTEGER NOT NULL,
- created_ts BIGINT NOT NULL DEFAULT EXTRACT(EPOCH FROM NOW()),
- updated_ts BIGINT NOT NULL DEFAULT EXTRACT(EPOCH FROM NOW()),
- row_status TEXT NOT NULL DEFAULT 'NORMAL',
- content TEXT NOT NULL,
- visibility TEXT NOT NULL DEFAULT 'PRIVATE',
- tags JSONB NOT NULL DEFAULT '[]',
- payload JSONB NOT NULL DEFAULT '{}'
- );
- -- memo_organizer
- CREATE TABLE memo_organizer (
- memo_id INTEGER NOT NULL,
- user_id INTEGER NOT NULL,
- pinned INTEGER NOT NULL DEFAULT 0,
- UNIQUE(memo_id, user_id)
- );
- -- memo_relation
- CREATE TABLE memo_relation (
- memo_id INTEGER NOT NULL,
- related_memo_id INTEGER NOT NULL,
- type TEXT NOT NULL,
- UNIQUE(memo_id, related_memo_id, type)
- );
- -- resource
- CREATE TABLE resource (
- id SERIAL PRIMARY KEY,
- uid TEXT NOT NULL UNIQUE,
- creator_id INTEGER NOT NULL,
- created_ts BIGINT NOT NULL DEFAULT EXTRACT(EPOCH FROM NOW()),
- updated_ts BIGINT NOT NULL DEFAULT EXTRACT(EPOCH FROM NOW()),
- filename TEXT NOT NULL,
- blob BYTEA,
- type TEXT NOT NULL DEFAULT '',
- size INTEGER NOT NULL DEFAULT 0,
- memo_id INTEGER DEFAULT NULL,
- storage_type TEXT NOT NULL DEFAULT '',
- reference TEXT NOT NULL DEFAULT '',
- payload TEXT NOT NULL DEFAULT '{}'
- );
- -- activity
- CREATE TABLE activity (
- id SERIAL PRIMARY KEY,
- creator_id INTEGER NOT NULL,
- created_ts BIGINT NOT NULL DEFAULT EXTRACT(EPOCH FROM NOW()),
- type TEXT NOT NULL DEFAULT '',
- level TEXT NOT NULL DEFAULT 'INFO',
- payload JSONB NOT NULL DEFAULT '{}'
- );
- -- idp
- CREATE TABLE idp (
- id SERIAL PRIMARY KEY,
- name TEXT NOT NULL,
- type TEXT NOT NULL,
- identifier_filter TEXT NOT NULL DEFAULT '',
- config JSONB NOT NULL DEFAULT '{}'
- );
- -- inbox
- CREATE TABLE inbox (
- id SERIAL PRIMARY KEY,
- created_ts BIGINT NOT NULL DEFAULT EXTRACT(EPOCH FROM NOW()),
- sender_id INTEGER NOT NULL,
- receiver_id INTEGER NOT NULL,
- status TEXT NOT NULL,
- message TEXT NOT NULL
- );
- -- webhook
- CREATE TABLE webhook (
- id SERIAL PRIMARY KEY,
- created_ts BIGINT NOT NULL DEFAULT EXTRACT(EPOCH FROM NOW()),
- updated_ts BIGINT NOT NULL DEFAULT EXTRACT(EPOCH FROM NOW()),
- row_status TEXT NOT NULL DEFAULT 'NORMAL',
- creator_id INTEGER NOT NULL,
- name TEXT NOT NULL,
- url TEXT NOT NULL
- );
- -- reaction
- CREATE TABLE reaction (
- id SERIAL PRIMARY KEY,
- created_ts BIGINT NOT NULL DEFAULT EXTRACT(EPOCH FROM NOW()),
- creator_id INTEGER NOT NULL,
- content_id TEXT NOT NULL,
- reaction_type TEXT NOT NULL,
- UNIQUE(creator_id, content_id, reaction_type)
- );
|