535 lines
17 KiB
JSON
535 lines
17 KiB
JSON
{
|
|
"_meta": {
|
|
"description": "This file contains a serialized version of schema entities for drift.",
|
|
"version": "1.3.0"
|
|
},
|
|
"options": {
|
|
"store_date_time_values_as_text": false
|
|
},
|
|
"entities": [
|
|
{
|
|
"id": 0,
|
|
"references": [],
|
|
"type": "table",
|
|
"data": {
|
|
"name": "container",
|
|
"was_declared_in_moor": true,
|
|
"columns": [
|
|
{
|
|
"name": "id",
|
|
"getter_name": "id",
|
|
"moor_type": "string",
|
|
"nullable": false,
|
|
"customConstraints": "PRIMARY KEY NOT NULL",
|
|
"default_dart": null,
|
|
"default_client_dart": null,
|
|
"dsl_features": [
|
|
"primary-key"
|
|
]
|
|
},
|
|
{
|
|
"name": "name",
|
|
"getter_name": "name",
|
|
"moor_type": "string",
|
|
"nullable": true,
|
|
"customConstraints": "",
|
|
"default_dart": null,
|
|
"default_client_dart": null,
|
|
"dsl_features": []
|
|
},
|
|
{
|
|
"name": "color",
|
|
"getter_name": "color",
|
|
"moor_type": "int",
|
|
"nullable": false,
|
|
"customConstraints": "NOT NULL",
|
|
"default_dart": null,
|
|
"default_client_dart": null,
|
|
"dsl_features": [],
|
|
"type_converter": {
|
|
"dart_expr": "const ColorConverter()",
|
|
"dart_type_name": "Color"
|
|
}
|
|
},
|
|
{
|
|
"name": "metadata",
|
|
"getter_name": "metadata",
|
|
"moor_type": "string",
|
|
"nullable": true,
|
|
"customConstraints": "",
|
|
"default_dart": null,
|
|
"default_client_dart": null,
|
|
"dsl_features": [],
|
|
"type_converter": {
|
|
"dart_expr": "const ContainerMetadataConverter()",
|
|
"dart_type_name": "ContainerMetadata"
|
|
}
|
|
}
|
|
],
|
|
"is_virtual": false,
|
|
"without_rowid": false,
|
|
"constraints": []
|
|
}
|
|
},
|
|
{
|
|
"id": 1,
|
|
"references": [
|
|
0
|
|
],
|
|
"type": "table",
|
|
"data": {
|
|
"name": "tab",
|
|
"was_declared_in_moor": true,
|
|
"columns": [
|
|
{
|
|
"name": "id",
|
|
"getter_name": "id",
|
|
"moor_type": "string",
|
|
"nullable": false,
|
|
"customConstraints": "PRIMARY KEY NOT NULL",
|
|
"default_dart": null,
|
|
"default_client_dart": null,
|
|
"dsl_features": [
|
|
"primary-key"
|
|
]
|
|
},
|
|
{
|
|
"name": "source",
|
|
"getter_name": "source",
|
|
"moor_type": "int",
|
|
"nullable": false,
|
|
"customConstraints": "NOT NULL",
|
|
"default_dart": null,
|
|
"default_client_dart": null,
|
|
"dsl_features": [],
|
|
"type_converter": {
|
|
"dart_expr": "const EnumIndexConverter<TabSource>(TabSource.values)",
|
|
"dart_type_name": "TabSource"
|
|
}
|
|
},
|
|
{
|
|
"name": "parent_id",
|
|
"getter_name": "parentId",
|
|
"moor_type": "string",
|
|
"nullable": true,
|
|
"customConstraints": "REFERENCES tab(id)ON DELETE SET NULL",
|
|
"default_dart": null,
|
|
"default_client_dart": null,
|
|
"dsl_features": []
|
|
},
|
|
{
|
|
"name": "container_id",
|
|
"getter_name": "containerId",
|
|
"moor_type": "string",
|
|
"nullable": true,
|
|
"customConstraints": "REFERENCES container(id)ON DELETE CASCADE",
|
|
"default_dart": null,
|
|
"default_client_dart": null,
|
|
"dsl_features": [
|
|
{
|
|
"foreign_key": {
|
|
"to": {
|
|
"table": "container",
|
|
"column": "id"
|
|
},
|
|
"initially_deferred": false,
|
|
"on_update": null,
|
|
"on_delete": "cascade"
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "order_key",
|
|
"getter_name": "orderKey",
|
|
"moor_type": "string",
|
|
"nullable": false,
|
|
"customConstraints": "NOT NULL",
|
|
"default_dart": null,
|
|
"default_client_dart": null,
|
|
"dsl_features": []
|
|
},
|
|
{
|
|
"name": "url",
|
|
"getter_name": "url",
|
|
"moor_type": "string",
|
|
"nullable": true,
|
|
"customConstraints": "",
|
|
"default_dart": null,
|
|
"default_client_dart": null,
|
|
"dsl_features": [],
|
|
"type_converter": {
|
|
"dart_expr": "const UriConverterNullable()",
|
|
"dart_type_name": "Uri?"
|
|
}
|
|
},
|
|
{
|
|
"name": "title",
|
|
"getter_name": "title",
|
|
"moor_type": "string",
|
|
"nullable": true,
|
|
"customConstraints": "",
|
|
"default_dart": null,
|
|
"default_client_dart": null,
|
|
"dsl_features": []
|
|
},
|
|
{
|
|
"name": "tab_mode",
|
|
"getter_name": "tabMode",
|
|
"moor_type": "int",
|
|
"nullable": false,
|
|
"customConstraints": "NOT NULL DEFAULT 0",
|
|
"default_dart": "const CustomExpression('0')",
|
|
"default_client_dart": null,
|
|
"dsl_features": [],
|
|
"type_converter": {
|
|
"dart_expr": "const EnumIndexConverter<TabModeDbValue>(TabModeDbValue.values)",
|
|
"dart_type_name": "TabModeDbValue"
|
|
}
|
|
},
|
|
{
|
|
"name": "isolation_context_id",
|
|
"getter_name": "isolationContextId",
|
|
"moor_type": "string",
|
|
"nullable": true,
|
|
"customConstraints": "",
|
|
"default_dart": null,
|
|
"default_client_dart": null,
|
|
"dsl_features": []
|
|
},
|
|
{
|
|
"name": "is_pinned",
|
|
"getter_name": "isPinned",
|
|
"moor_type": "bool",
|
|
"nullable": false,
|
|
"customConstraints": "NOT NULL DEFAULT 0",
|
|
"default_dart": "const CustomExpression('0')",
|
|
"default_client_dart": null,
|
|
"dsl_features": []
|
|
},
|
|
{
|
|
"name": "is_probably_readerable",
|
|
"getter_name": "isProbablyReaderable",
|
|
"moor_type": "bool",
|
|
"nullable": true,
|
|
"customConstraints": "",
|
|
"default_dart": null,
|
|
"default_client_dart": null,
|
|
"dsl_features": []
|
|
},
|
|
{
|
|
"name": "extracted_content_markdown",
|
|
"getter_name": "extractedContentMarkdown",
|
|
"moor_type": "string",
|
|
"nullable": true,
|
|
"customConstraints": "",
|
|
"default_dart": null,
|
|
"default_client_dart": null,
|
|
"dsl_features": []
|
|
},
|
|
{
|
|
"name": "extracted_content_plain",
|
|
"getter_name": "extractedContentPlain",
|
|
"moor_type": "string",
|
|
"nullable": true,
|
|
"customConstraints": "",
|
|
"default_dart": null,
|
|
"default_client_dart": null,
|
|
"dsl_features": []
|
|
},
|
|
{
|
|
"name": "full_content_markdown",
|
|
"getter_name": "fullContentMarkdown",
|
|
"moor_type": "string",
|
|
"nullable": true,
|
|
"customConstraints": "",
|
|
"default_dart": null,
|
|
"default_client_dart": null,
|
|
"dsl_features": []
|
|
},
|
|
{
|
|
"name": "full_content_plain",
|
|
"getter_name": "fullContentPlain",
|
|
"moor_type": "string",
|
|
"nullable": true,
|
|
"customConstraints": "",
|
|
"default_dart": null,
|
|
"default_client_dart": null,
|
|
"dsl_features": []
|
|
},
|
|
{
|
|
"name": "timestamp",
|
|
"getter_name": "timestamp",
|
|
"moor_type": "dateTime",
|
|
"nullable": false,
|
|
"customConstraints": "NOT NULL",
|
|
"default_dart": null,
|
|
"default_client_dart": null,
|
|
"dsl_features": []
|
|
}
|
|
],
|
|
"is_virtual": false,
|
|
"without_rowid": false,
|
|
"constraints": [
|
|
"CHECK((tab_mode = 2 AND isolation_context_id IS NOT NULL)OR(tab_mode != 2 AND isolation_context_id IS NULL))"
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"id": 2,
|
|
"references": [],
|
|
"type": "table",
|
|
"data": {
|
|
"name": "closed_tab_tombstone",
|
|
"was_declared_in_moor": true,
|
|
"columns": [
|
|
{
|
|
"name": "tab_id",
|
|
"getter_name": "tabId",
|
|
"moor_type": "string",
|
|
"nullable": false,
|
|
"customConstraints": "PRIMARY KEY NOT NULL",
|
|
"default_dart": null,
|
|
"default_client_dart": null,
|
|
"dsl_features": [
|
|
"primary-key"
|
|
]
|
|
},
|
|
{
|
|
"name": "closed_at",
|
|
"getter_name": "closedAt",
|
|
"moor_type": "dateTime",
|
|
"nullable": false,
|
|
"customConstraints": "NOT NULL",
|
|
"default_dart": null,
|
|
"default_client_dart": null,
|
|
"dsl_features": []
|
|
}
|
|
],
|
|
"is_virtual": false,
|
|
"without_rowid": false,
|
|
"constraints": []
|
|
}
|
|
},
|
|
{
|
|
"id": 3,
|
|
"references": [
|
|
1
|
|
],
|
|
"type": "index",
|
|
"data": {
|
|
"on": 1,
|
|
"name": "idx_tab_parent_container",
|
|
"sql": "CREATE INDEX idx_tab_parent_container ON tab(parent_id, container_id);",
|
|
"unique": false,
|
|
"columns": []
|
|
}
|
|
},
|
|
{
|
|
"id": 4,
|
|
"references": [
|
|
1
|
|
],
|
|
"type": "table",
|
|
"data": {
|
|
"name": "tab_fts",
|
|
"was_declared_in_moor": true,
|
|
"columns": [
|
|
{
|
|
"name": "title",
|
|
"getter_name": "title",
|
|
"moor_type": "string",
|
|
"nullable": false,
|
|
"customConstraints": "",
|
|
"default_dart": null,
|
|
"default_client_dart": null,
|
|
"dsl_features": []
|
|
},
|
|
{
|
|
"name": "url",
|
|
"getter_name": "url",
|
|
"moor_type": "string",
|
|
"nullable": false,
|
|
"customConstraints": "",
|
|
"default_dart": null,
|
|
"default_client_dart": null,
|
|
"dsl_features": []
|
|
},
|
|
{
|
|
"name": "extracted_content_plain",
|
|
"getter_name": "extractedContentPlain",
|
|
"moor_type": "string",
|
|
"nullable": false,
|
|
"customConstraints": "",
|
|
"default_dart": null,
|
|
"default_client_dart": null,
|
|
"dsl_features": []
|
|
},
|
|
{
|
|
"name": "full_content_plain",
|
|
"getter_name": "fullContentPlain",
|
|
"moor_type": "string",
|
|
"nullable": false,
|
|
"customConstraints": "",
|
|
"default_dart": null,
|
|
"default_client_dart": null,
|
|
"dsl_features": []
|
|
}
|
|
],
|
|
"is_virtual": true,
|
|
"create_virtual_stmt": "CREATE VIRTUAL TABLE \"tab_fts\" USING fts5(title, url, extracted_content_plain, full_content_plain, content=tab, tokenize=\"trigram\")",
|
|
"without_rowid": false,
|
|
"constraints": []
|
|
}
|
|
},
|
|
{
|
|
"id": 5,
|
|
"references": [
|
|
1
|
|
],
|
|
"type": "trigger",
|
|
"data": {
|
|
"on": 1,
|
|
"references_in_body": [
|
|
1
|
|
],
|
|
"name": "tab_maintain_parent_chain_on_delete",
|
|
"sql": "CREATE TRIGGER tab_maintain_parent_chain_on_delete BEFORE DELETE ON tab BEGIN\n -- Update all children of the deleted row to point to its parent (grandparent)\n -- Only if the grandparent exists, otherwise set to NULL\n UPDATE tab\n SET parent_id = CASE\n WHEN OLD.parent_id IS NOT NULL AND\n EXISTS(SELECT 1 FROM tab WHERE id = OLD.parent_id)\n THEN OLD.parent_id\n ELSE NULL\n END\n WHERE parent_id = OLD.id;\nEND;"
|
|
}
|
|
},
|
|
{
|
|
"id": 6,
|
|
"references": [
|
|
1,
|
|
4
|
|
],
|
|
"type": "trigger",
|
|
"data": {
|
|
"on": 1,
|
|
"references_in_body": [
|
|
1,
|
|
4
|
|
],
|
|
"name": "tab_after_insert",
|
|
"sql": "CREATE TRIGGER tab_after_insert AFTER INSERT ON tab BEGIN\n INSERT INTO \n tab_fts(rowid, title, url, extracted_content_plain, full_content_plain) \n VALUES (new.rowid, new.title, new.url, new.extracted_content_plain, new.full_content_plain);\nEND;"
|
|
}
|
|
},
|
|
{
|
|
"id": 7,
|
|
"references": [
|
|
1,
|
|
4
|
|
],
|
|
"type": "trigger",
|
|
"data": {
|
|
"on": 1,
|
|
"references_in_body": [
|
|
1,
|
|
4
|
|
],
|
|
"name": "tab_after_delete",
|
|
"sql": "CREATE TRIGGER tab_after_delete AFTER DELETE ON tab BEGIN\n INSERT INTO \n tab_fts(tab_fts, rowid, title, url, extracted_content_plain, full_content_plain) \n VALUES('delete', old.rowid, old.title, old.url, old.extracted_content_plain, old.full_content_plain);\nEND;"
|
|
}
|
|
},
|
|
{
|
|
"id": 8,
|
|
"references": [
|
|
1,
|
|
4
|
|
],
|
|
"type": "trigger",
|
|
"data": {
|
|
"on": 1,
|
|
"references_in_body": [
|
|
1,
|
|
4
|
|
],
|
|
"name": "tab_after_update",
|
|
"sql": "CREATE TRIGGER tab_after_update AFTER UPDATE ON tab BEGIN\n INSERT INTO \n tab_fts(tab_fts, rowid, title, url, extracted_content_plain, full_content_plain) \n VALUES('delete', old.rowid, old.title, old.url, old.extracted_content_plain, old.full_content_plain);\n INSERT INTO \n tab_fts(rowid, title, url, extracted_content_plain, full_content_plain) \n VALUES (new.rowid, new.title, new.url, new.extracted_content_plain, new.full_content_plain);\nEND;"
|
|
}
|
|
}
|
|
],
|
|
"fixed_sql": [
|
|
{
|
|
"name": "container",
|
|
"sql": [
|
|
{
|
|
"dialect": "sqlite",
|
|
"sql": "CREATE TABLE IF NOT EXISTS \"container\" (\"id\" TEXT PRIMARY KEY NOT NULL, \"name\" TEXT, \"color\" INTEGER NOT NULL, \"metadata\" TEXT);"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "tab",
|
|
"sql": [
|
|
{
|
|
"dialect": "sqlite",
|
|
"sql": "CREATE TABLE IF NOT EXISTS \"tab\" (\"id\" TEXT PRIMARY KEY NOT NULL, \"source\" INTEGER NOT NULL, \"parent_id\" TEXT REFERENCES tab(id)ON DELETE SET NULL, \"container_id\" TEXT REFERENCES container(id)ON DELETE CASCADE, \"order_key\" TEXT NOT NULL, \"url\" TEXT, \"title\" TEXT, \"tab_mode\" INTEGER NOT NULL DEFAULT 0, \"isolation_context_id\" TEXT, \"is_pinned\" INTEGER NOT NULL DEFAULT 0, \"is_probably_readerable\" INTEGER, \"extracted_content_markdown\" TEXT, \"extracted_content_plain\" TEXT, \"full_content_markdown\" TEXT, \"full_content_plain\" TEXT, \"timestamp\" INTEGER NOT NULL, CHECK((tab_mode = 2 AND isolation_context_id IS NOT NULL)OR(tab_mode != 2 AND isolation_context_id IS NULL)));"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "closed_tab_tombstone",
|
|
"sql": [
|
|
{
|
|
"dialect": "sqlite",
|
|
"sql": "CREATE TABLE IF NOT EXISTS \"closed_tab_tombstone\" (\"tab_id\" TEXT PRIMARY KEY NOT NULL, \"closed_at\" INTEGER NOT NULL);"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "idx_tab_parent_container",
|
|
"sql": [
|
|
{
|
|
"dialect": "sqlite",
|
|
"sql": "CREATE INDEX idx_tab_parent_container ON tab (parent_id, container_id)"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "tab_fts",
|
|
"sql": [
|
|
{
|
|
"dialect": "sqlite",
|
|
"sql": "CREATE VIRTUAL TABLE IF NOT EXISTS \"tab_fts\" USING fts5(title, url, extracted_content_plain, full_content_plain, content=tab, tokenize=\"trigram\");"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "tab_maintain_parent_chain_on_delete",
|
|
"sql": [
|
|
{
|
|
"dialect": "sqlite",
|
|
"sql": "CREATE TRIGGER tab_maintain_parent_chain_on_delete BEFORE DELETE ON tab BEGIN UPDATE tab SET parent_id = CASE WHEN OLD.parent_id IS NOT NULL AND EXISTS (SELECT 1 FROM tab WHERE id = OLD.parent_id) THEN OLD.parent_id ELSE NULL END WHERE parent_id = OLD.id;END"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "tab_after_insert",
|
|
"sql": [
|
|
{
|
|
"dialect": "sqlite",
|
|
"sql": "CREATE TRIGGER tab_after_insert AFTER INSERT ON tab BEGIN INSERT INTO tab_fts (\"rowid\", title, url, extracted_content_plain, full_content_plain) VALUES (new.\"rowid\", new.title, new.url, new.extracted_content_plain, new.full_content_plain);END"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "tab_after_delete",
|
|
"sql": [
|
|
{
|
|
"dialect": "sqlite",
|
|
"sql": "CREATE TRIGGER tab_after_delete AFTER DELETE ON tab BEGIN INSERT INTO tab_fts (tab_fts, \"rowid\", title, url, extracted_content_plain, full_content_plain) VALUES ('delete', old.\"rowid\", old.title, old.url, old.extracted_content_plain, old.full_content_plain);END"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "tab_after_update",
|
|
"sql": [
|
|
{
|
|
"dialect": "sqlite",
|
|
"sql": "CREATE TRIGGER tab_after_update AFTER UPDATE ON tab BEGIN INSERT INTO tab_fts (tab_fts, \"rowid\", title, url, extracted_content_plain, full_content_plain) VALUES ('delete', old.\"rowid\", old.title, old.url, old.extracted_content_plain, old.full_content_plain);INSERT INTO tab_fts (\"rowid\", title, url, extracted_content_plain, full_content_plain) VALUES (new.\"rowid\", new.title, new.url, new.extracted_content_plain, new.full_content_plain);END"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
} |