refactor: sqlite schema

This commit is contained in:
appflowy 2022-06-11 17:13:52 +08:00
parent 7366acb58e
commit bf5247066d
18 changed files with 11 additions and 26 deletions

View File

@ -1,2 +0,0 @@
-- This file should undo anything in `up.sql`
DROP TABLE doc_table;

View File

@ -1,7 +0,0 @@
-- Your SQL goes here
CREATE TABLE doc_table (
id TEXT NOT NULL PRIMARY KEY,
-- data BLOB NOT NULL DEFAULT (x''),
data TEXT NOT NULL DEFAULT '',
rev_id BIGINT NOT NULL DEFAULT 0
);

View File

@ -1,2 +0,0 @@
-- This file should undo anything in `up.sql`
DROP TABLE kv_table;

View File

@ -1,5 +0,0 @@
-- Your SQL goes here
CREATE TABLE kv_table (
key TEXT NOT NULL PRIMARY KEY,
value BLOB NOT NULL DEFAULT (x'')
);

View File

@ -1,3 +1,4 @@
-- This file should undo anything in `up.sql`
DROP TABLE kv_table;
DROP TABLE grid_rev_table;
DROP TABLE grid_meta_rev_table;

View File

@ -1,4 +1,8 @@
-- Your SQL goes here
CREATE TABLE kv_table (
key TEXT NOT NULL PRIMARY KEY,
value BLOB NOT NULL DEFAULT (x'')
);
CREATE TABLE grid_rev_table (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
object_id TEXT NOT NULL DEFAULT '',

View File

@ -0,0 +1 @@
-- This file should undo anything in `up.sql`

View File

@ -0,0 +1,2 @@
-- Your SQL goes here
ALTER TABLE view_table ADD COLUMN ext_data TEXT NOT NULL DEFAULT '';

View File

@ -13,14 +13,6 @@ table! {
}
}
table! {
doc_table (id) {
id -> Text,
data -> Text,
rev_id -> BigInt,
}
}
table! {
grid_block_index_table (row_id) {
row_id -> Text,
@ -102,6 +94,7 @@ table! {
view_type -> Integer,
version -> BigInt,
is_trash -> Bool,
ext_data -> Text,
}
}
@ -119,7 +112,6 @@ table! {
allow_tables_to_appear_in_same_query!(
app_table,
doc_table,
grid_block_index_table,
grid_meta_rev_table,
grid_rev_table,

View File

@ -79,6 +79,7 @@ pub(crate) struct ViewTable {
pub view_type: SqlViewDataType,
pub version: i64,
pub is_trash: bool,
pub ext_data: String,
}
impl ViewTable {
@ -120,7 +121,7 @@ impl std::convert::From<ViewTable> for View {
modified_time: table.modified_time,
version: table.version,
create_time: table.create_time,
ext_data: "".to_string(),
ext_data: table.ext_data,
thumbnail: table.thumbnail,
// Store the view in ViewTable was deprecated since v0.0.2.
// No need worry about plugin_type.