313 lines · 9.0 KB · JSONRaw
{ "format_version": 1, "id": "post", "name": "Post", "plural": "Posts", "picture": null, "builtin": true, "delete": false, "engine": "posts", "columns": [ { "key": "caption", "type": "longtext", "readonly": true }, { "key": "author_name", "name": "Author", "type": "text", "readonly": true }, { "key": "author_handle", "name": "Handle", "type": "text", "readonly": true }, { "key": "person_id", "name": "Person", "type": "link", "link_to": "person", "readonly": true }, { "key": "saved", "name": "Saved", "type": "bool", "readonly": true }, { "key": "source", "name": "Site", "type": "text", "readonly": true }, { "key": "account", "name": "Account", "type": "text", "readonly": true }, { "key": "posted_at", "name": "Posted", "type": "date", "readonly": true }, { "key": "saved_at", "name": "Saved on", "type": "date", "readonly": true }, { "key": "permalink", "name": "Web address", "type": "text", "readonly": true } ], "title": "caption", "date": "posted_at", "project": null, "order": null, "slip": { "title": "caption", "subtitle": "author_name", "trailing": "posted_at", "photo": null, "toggle": null }, "tile": { "face": "slip-list" }, "page": [ { "heading": null, "columns": [ "caption", "author_name", "author_handle", "posted_at" ] }, { "heading": "Details", "columns": [ "saved", "saved_at", "source", "account", "person_id", "permalink" ] } ], "instructions": "A post is one item the owner put on a social site, or saved there, with its caption, pictures, date and link. Posts arrive only from a site's reader or its export import; nobody types or edits one.", "add": false, "tables": [ { "name": "cotton_posts", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "source", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n source TEXT NOT NULL", "position": 2 }, { "name": "account", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n account TEXT NOT NULL", "position": 3 }, { "name": "external_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n external_id TEXT NOT NULL", "position": 4 }, { "name": "saved", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n saved INTEGER NOT NULL DEFAULT 0", "position": 5 }, { "name": "author_handle", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n author_handle TEXT", "position": 6 }, { "name": "author_name", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n author_name TEXT", "position": 7 }, { "name": "person_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n person_id TEXT", "position": 8 }, { "name": "caption", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n caption TEXT", "position": 9 }, { "name": "media", "type": "TEXT", "default": "'[]'", "nullable": false, "primary_key": false, "declaration": "\n media TEXT NOT NULL DEFAULT '[]'", "position": 10 }, { "name": "posted_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n posted_at TEXT", "position": 11 }, { "name": "saved_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n saved_at TEXT", "position": 12 }, { "name": "permalink", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n permalink TEXT", "position": 13 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 14 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 15 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 16 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 17 } ], "constraints": [ { "declaration": "\n CHECK (saved IN (0, 1))", "position": 18 }, { "declaration": "\n CHECK (trim(external_id) <> '')", "position": 19 }, { "declaration": "\n CHECK (json_valid(media) AND json_type(media) = 'array')", "position": 20 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 21 } ], "prefix": "CREATE TABLE IF NOT EXISTS cotton_posts (", "suffix": ")", "indexes": [ "CREATE UNIQUE INDEX IF NOT EXISTS uq_cotton_posts_external ON cotton_posts (workspace_id, source, account, external_id)", "CREATE INDEX IF NOT EXISTS idx_cotton_posts_posted ON cotton_posts (workspace_id, saved, posted_at)", "CREATE INDEX IF NOT EXISTS idx_cotton_posts_author ON cotton_posts (substr(_hlc, 20), _hlc)" ], "full_text": [ "CREATE VIRTUAL TABLE fts_posts USING fts5(\n caption, author_name, author_handle, content = 'cotton_posts', content_rowid = 'rowid',\n tokenize = 'unicode61 remove_diacritics 2'\n )" ], "triggers": [ "CREATE TRIGGER fts_posts_ai AFTER INSERT ON cotton_posts WHEN new.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_posts'), 0) BEGIN\n INSERT INTO fts_posts (rowid, caption, author_name, author_handle) VALUES (new.rowid, new.caption, new.author_name, new.author_handle);\n END", "CREATE TRIGGER fts_posts_ad AFTER DELETE ON cotton_posts WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_posts'), 0) BEGIN\n INSERT INTO fts_posts (fts_posts, rowid, caption, author_name, author_handle) VALUES ('delete', old.rowid, old.caption, old.author_name, old.author_handle);\n END", "CREATE TRIGGER fts_posts_au AFTER UPDATE OF caption, author_name, author_handle ON cotton_posts\n FOR EACH ROW WHEN old.rowid >= coalesce((SELECT floor FROM _fts_fill WHERE fts = 'fts_posts'), 0) AND (new.caption IS NOT old.caption OR new.author_name IS NOT old.author_name OR new.author_handle IS NOT old.author_handle) BEGIN\n INSERT INTO fts_posts (fts_posts, rowid, caption, author_name, author_handle) VALUES ('delete', old.rowid, old.caption, old.author_name, old.author_handle);\n INSERT INTO fts_posts (rowid, caption, author_name, author_handle) VALUES (new.rowid, new.caption, new.author_name, new.author_handle);\n END" ] } ]}