chore: remove unused sqlite table (#2704)

* chore: remove unused sqlite table

* ci: fix tests
This commit is contained in:
Nathan.fooo 2023-06-05 18:30:14 +08:00 committed by GitHub
parent e24a8aabeb
commit f2dd58a4f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 17 additions and 393 deletions

View File

@ -1,5 +0,0 @@
-- This file should undo anything in `up.sql`
DROP TABLE user_table;
DROP TABLE workspace_table;
DROP TABLE app_table;
DROP TABLE view_table;

View File

@ -1,53 +0,0 @@
-- Your SQL goes here
CREATE TABLE user_table (
id TEXT NOT NULL PRIMARY KEY,
name TEXT NOT NULL DEFAULT '',
token TEXT NOT NULL DEFAULT '',
email TEXT NOT NULL DEFAULT ''
);
CREATE TABLE workspace_table (
id TEXT NOT NULL PRIMARY KEY,
name TEXT NOT NULL DEFAULT '',
desc TEXT NOT NULL DEFAULT '',
modified_time BIGINT NOT NULL DEFAULT 0,
create_time BIGINT NOT NULL DEFAULT 0,
user_id TEXT NOT NULL DEFAULT '',
version BIGINT NOT NULL DEFAULT 0
);
CREATE TABLE app_table (
id TEXT NOT NULL PRIMARY KEY,
workspace_id TEXT NOT NULL DEFAULT '',
name TEXT NOT NULL DEFAULT '',
desc TEXT NOT NULL DEFAULT '',
color_style BLOB NOT NULL DEFAULT (x''),
last_view_id TEXT DEFAULT '',
modified_time BIGINT NOT NULL DEFAULT 0,
create_time BIGINT NOT NULL DEFAULT 0,
version BIGINT NOT NULL DEFAULT 0,
is_trash Boolean NOT NULL DEFAULT false
);
CREATE TABLE view_table (
id TEXT NOT NULL PRIMARY KEY,
belong_to_id TEXT NOT NULL DEFAULT '',
name TEXT NOT NULL DEFAULT '',
desc TEXT NOT NULL DEFAULT '',
modified_time BIGINT NOT NULL DEFAULT 0,
create_time BIGINT NOT NULL DEFAULT 0,
thumbnail TEXT NOT NULL DEFAULT '',
view_type INTEGER NOT NULL DEFAULT 0,
version BIGINT NOT NULL DEFAULT 0,
is_trash Boolean NOT NULL DEFAULT false
);
CREATE TABLE trash_table (
id TEXT NOT NULL PRIMARY KEY,
name TEXT NOT NULL DEFAULT '',
desc TEXT NOT NULL DEFAULT '',
modified_time BIGINT NOT NULL DEFAULT 0,
create_time BIGINT NOT NULL DEFAULT 0,
ty INTEGER NOT NULL DEFAULT 0
);

View File

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

View File

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

View File

@ -1,10 +0,0 @@
-- Your SQL goes here
CREATE TABLE rev_table (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
doc_id TEXT NOT NULL DEFAULT '',
base_rev_id BIGINT NOT NULL DEFAULT 0,
rev_id BIGINT NOT NULL DEFAULT 0,
data BLOB NOT NULL DEFAULT (x''),
state INTEGER NOT NULL DEFAULT 0,
ty INTEGER NOT NULL DEFAULT 0
);

View File

@ -1,4 +0,0 @@
-- 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,22 +0,0 @@
-- 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 '',
base_rev_id BIGINT NOT NULL DEFAULT 0,
rev_id BIGINT NOT NULL DEFAULT 0,
data BLOB NOT NULL DEFAULT (x''),
state INTEGER NOT NULL DEFAULT 0
);
CREATE TABLE grid_meta_rev_table (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
object_id TEXT NOT NULL DEFAULT '',
base_rev_id BIGINT NOT NULL DEFAULT 0,
rev_id BIGINT NOT NULL DEFAULT 0,
data BLOB NOT NULL DEFAULT (x''),
state INTEGER NOT NULL DEFAULT 0
);

View File

@ -1,3 +0,0 @@
-- This file should undo anything in `up.sql`
DROP TABLE grid_block_index_table;
-- DROP TABLE grid_block_fts_table;

View File

@ -1,7 +0,0 @@
-- Your SQL goes here
CREATE TABLE grid_block_index_table (
row_id TEXT NOT NULL PRIMARY KEY,
block_id TEXT NOT NULL
);
-- CREATE VIRTUAL TABLE grid_block_fts_table USING FTS5(content, grid_id, block_id, row_id);

View File

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

View File

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

View File

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

View File

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

View File

@ -1 +0,0 @@
ALTER TABLE user_table DROP COLUMN icon_url;

View File

@ -1 +0,0 @@
ALTER TABLE user_table ADD COLUMN icon_url TEXT NOT NULL DEFAULT '';

View File

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

View File

@ -1,11 +0,0 @@
-- Your SQL goes here
CREATE TABLE grid_view_rev_table (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
object_id TEXT NOT NULL DEFAULT '',
base_rev_id BIGINT NOT NULL DEFAULT 0,
rev_id BIGINT NOT NULL DEFAULT 0,
data BLOB NOT NULL DEFAULT (x''),
state INTEGER NOT NULL DEFAULT 0
);

View File

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

View File

@ -1,9 +0,0 @@
-- Your SQL goes here
CREATE TABLE document_rev_table (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
document_id TEXT NOT NULL DEFAULT '',
base_rev_id BIGINT NOT NULL DEFAULT 0,
rev_id BIGINT NOT NULL DEFAULT 0,
data BLOB NOT NULL DEFAULT (x''),
state INTEGER NOT NULL DEFAULT 0
);

View File

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

View File

@ -1,9 +0,0 @@
-- Your SQL goes here
CREATE TABLE grid_rev_snapshot (
snapshot_id TEXT NOT NULL PRIMARY KEY DEFAULT '',
object_id TEXT NOT NULL DEFAULT '',
rev_id BIGINT NOT NULL DEFAULT 0,
base_rev_id BIGINT NOT NULL DEFAULT 0,
timestamp BIGINT NOT NULL DEFAULT 0,
data BLOB NOT NULL DEFAULT (x'')
);

View File

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

View File

@ -1,9 +0,0 @@
-- Your SQL goes here
CREATE TABLE folder_rev_snapshot (
snapshot_id TEXT NOT NULL PRIMARY KEY DEFAULT '',
object_id TEXT NOT NULL DEFAULT '',
rev_id BIGINT NOT NULL DEFAULT 0,
base_rev_id BIGINT NOT NULL DEFAULT 0,
timestamp BIGINT NOT NULL DEFAULT 0,
data BLOB NOT NULL DEFAULT (x'')
);

View File

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

View File

@ -1,9 +0,0 @@
-- Your SQL goes here
CREATE TABLE document_rev_snapshot (
snapshot_id TEXT NOT NULL PRIMARY KEY DEFAULT '',
object_id TEXT NOT NULL DEFAULT '',
rev_id BIGINT NOT NULL DEFAULT 0,
base_rev_id BIGINT NOT NULL DEFAULT 0,
timestamp BIGINT NOT NULL DEFAULT 0,
data BLOB NOT NULL DEFAULT (x'')
);

View File

@ -1 +0,0 @@
ALTER TABLE user_table DROP COLUMN openai_key;

View File

@ -1 +0,0 @@
ALTER TABLE user_table ADD COLUMN openai_key TEXT NOT NULL DEFAULT '';

View File

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

View File

@ -1,8 +0,0 @@
-- Your SQL goes here
CREATE TABLE database_refs (
ref_id TEXT NOT NULL PRIMARY KEY DEFAULT '',
name TEXT NOT NULL DEFAULT '',
is_base Boolean NOT NULL DEFAULT false,
view_id TEXT NOT NULL DEFAULT '',
database_id TEXT NOT NULL DEFAULT ''
);

View File

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

View File

@ -0,0 +1,10 @@
-- Your SQL goes here
CREATE TABLE user_table (
id TEXT NOT NULL PRIMARY KEY,
name TEXT NOT NULL DEFAULT '',
workspace TEXT NOT NULL DEFAULT '',
icon_url TEXT NOT NULL DEFAULT '',
openai_key TEXT NOT NULL DEFAULT '',
token TEXT NOT NULL DEFAULT '',
email TEXT NOT NULL DEFAULT ''
);

View File

@ -1,209 +1,13 @@
// @generated automatically by Diesel CLI. // @generated automatically by Diesel CLI.
diesel::table! {
app_table (id) {
id -> Text,
workspace_id -> Text,
name -> Text,
desc -> Text,
color_style -> Binary,
last_view_id -> Nullable<Text>,
modified_time -> BigInt,
create_time -> BigInt,
version -> BigInt,
is_trash -> Bool,
}
}
diesel::table! {
database_refs (ref_id) {
ref_id -> Text,
name -> Text,
is_base -> Bool,
view_id -> Text,
database_id -> Text,
}
}
diesel::table! {
document_rev_snapshot (snapshot_id) {
snapshot_id -> Text,
object_id -> Text,
rev_id -> BigInt,
base_rev_id -> BigInt,
timestamp -> BigInt,
data -> Binary,
}
}
diesel::table! {
document_rev_table (id) {
id -> Integer,
document_id -> Text,
base_rev_id -> BigInt,
rev_id -> BigInt,
data -> Binary,
state -> Integer,
}
}
diesel::table! {
folder_rev_snapshot (snapshot_id) {
snapshot_id -> Text,
object_id -> Text,
rev_id -> BigInt,
base_rev_id -> BigInt,
timestamp -> BigInt,
data -> Binary,
}
}
diesel::table! {
grid_block_index_table (row_id) {
row_id -> Text,
block_id -> Text,
}
}
diesel::table! {
grid_meta_rev_table (id) {
id -> Integer,
object_id -> Text,
base_rev_id -> BigInt,
rev_id -> BigInt,
data -> Binary,
state -> Integer,
}
}
diesel::table! {
grid_rev_snapshot (snapshot_id) {
snapshot_id -> Text,
object_id -> Text,
rev_id -> BigInt,
base_rev_id -> BigInt,
timestamp -> BigInt,
data -> Binary,
}
}
diesel::table! {
grid_rev_table (id) {
id -> Integer,
object_id -> Text,
base_rev_id -> BigInt,
rev_id -> BigInt,
data -> Binary,
state -> Integer,
}
}
diesel::table! {
grid_view_rev_table (id) {
id -> Integer,
object_id -> Text,
base_rev_id -> BigInt,
rev_id -> BigInt,
data -> Binary,
state -> Integer,
}
}
diesel::table! {
kv_table (key) {
key -> Text,
value -> Binary,
}
}
diesel::table! {
rev_snapshot (id) {
id -> Integer,
object_id -> Text,
rev_id -> BigInt,
data -> Binary,
}
}
diesel::table! {
rev_table (id) {
id -> Integer,
doc_id -> Text,
base_rev_id -> BigInt,
rev_id -> BigInt,
data -> Binary,
state -> Integer,
ty -> Integer,
}
}
diesel::table! {
trash_table (id) {
id -> Text,
name -> Text,
desc -> Text,
modified_time -> BigInt,
create_time -> BigInt,
ty -> Integer,
}
}
diesel::table! { diesel::table! {
user_table (id) { user_table (id) {
id -> Text, id -> Text,
name -> Text, name -> Text,
token -> Text,
email -> Text,
workspace -> Text, workspace -> Text,
icon_url -> Text, icon_url -> Text,
openai_key -> Text, openai_key -> Text,
token -> Text,
email -> Text,
} }
} }
diesel::table! {
view_table (id) {
id -> Text,
belong_to_id -> Text,
name -> Text,
desc -> Text,
modified_time -> BigInt,
create_time -> BigInt,
thumbnail -> Text,
view_type -> Integer,
version -> BigInt,
is_trash -> Bool,
ext_data -> Text,
}
}
diesel::table! {
workspace_table (id) {
id -> Text,
name -> Text,
desc -> Text,
modified_time -> BigInt,
create_time -> BigInt,
user_id -> Text,
version -> BigInt,
}
}
diesel::allow_tables_to_appear_in_same_query!(
app_table,
database_refs,
document_rev_snapshot,
document_rev_table,
folder_rev_snapshot,
grid_block_index_table,
grid_meta_rev_table,
grid_rev_snapshot,
grid_rev_table,
grid_view_rev_table,
kv_table,
rev_snapshot,
rev_table,
trash_table,
user_table,
view_table,
workspace_table,
);

View File

@ -105,16 +105,18 @@ lazy_static! {
static ref COLLAB_DB_MAP: RwLock<HashMap<i64, Arc<RocksCollabDB>>> = RwLock::new(HashMap::new()); static ref COLLAB_DB_MAP: RwLock<HashMap<i64, Arc<RocksCollabDB>>> = RwLock::new(HashMap::new());
} }
/// The order of the fields in the struct must be the same as the order of the fields in the table.
/// Check out the [schema.rs] for table schema.
#[derive(Clone, Default, Queryable, Identifiable, Insertable)] #[derive(Clone, Default, Queryable, Identifiable, Insertable)]
#[table_name = "user_table"] #[table_name = "user_table"]
pub struct UserTable { pub struct UserTable {
pub(crate) id: String, pub(crate) id: String,
pub(crate) name: String, pub(crate) name: String,
pub(crate) token: String,
pub(crate) email: String,
pub(crate) workspace: String, pub(crate) workspace: String,
pub(crate) icon_url: String, pub(crate) icon_url: String,
pub(crate) openai_key: String, pub(crate) openai_key: String,
pub(crate) token: String,
pub(crate) email: String,
} }
impl UserTable { impl UserTable {