Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

Record TABLE_TYPE, DATA_FREE, CREATE_OPTIONS, TABLE_COMMENT in the table schema and also display table and view spearate in the UI

天舟b85f814f7577
diff --git a/api/table.go b/api/table.go
index 7a21103ea7..12668338ef 100644
--- a/api/table.go
+++ b/api/table.go
@@ -22,6 +22,7 @@ type Table struct {
// Domain specific fields
Name string `jsonapi:"attr,name"`
+ Type string `jsonapi:"attr,type"`
Engine string `jsonapi:"attr,engine"`
Collation string `jsonapi:"attr,collation"`
SyncStatus SyncStatus `jsonapi:"attr,syncStatus"`
@@ -29,6 +30,9 @@ type Table struct {
RowCount int64 `jsonapi:"attr,rowCount"`
DataSize int64 `jsonapi:"attr,dataSize"`
IndexSize int64 `jsonapi:"attr,indexSize"`
+ DataFree int64 `jsonapi:"attr,dataFree"`
+ CreateOptions string `jsonapi:"attr,createOptions"`
+ Comment string `jsonapi:"attr,comment"`
}
type TableCreate struct {
@@ -37,15 +41,19 @@ type TableCreate struct {
CreatorId int
// Related fields
- DatabaseId int `jsonapi:"attr,databaseId"`
+ DatabaseId int
// Domain specific fields
- Name string `jsonapi:"attr,name"`
- Engine string `jsonapi:"attr,engine"`
- Collation string `jsonapi:"attr,collation"`
- RowCount int64
- DataSize int64
- IndexSize int64
+ Name string
+ Type string
+ Engine string
+ Collation string
+ RowCount int64
+ DataSize int64
+ IndexSize int64
+ DataFree int64
+ CreateOptions string
+ Comment string
}
type TableFind struct {
diff --git a/db/driver.go b/db/driver.go
index 847e6e63f9..e2e1e46039 100644
--- a/db/driver.go
+++ b/db/driver.go
@@ -25,14 +25,18 @@ func (e Type) String() string {
}
type DBTable struct {
- Name string
- CreatedTs int64
- UpdatedTs int64
- Engine string
- Collation string
- RowCount int64
- DataSize int64
- IndexSize int64
+ Name string
+ CreatedTs int64
+ UpdatedTs int64
+ Type string
+ Engine string
+ Collation string
+ RowCount int64
+ DataSize int64
+ IndexSize int64
+ DataFree int64
+ CreateOptions string
+ Comment string
}
type DBSchema struct {
diff --git a/db/mysql.go b/db/mysql.go
index 43c5cc8fa4..088e5f8d1d 100644
--- a/db/mysql.go
+++ b/db/mysql.go
@@ -79,11 +79,15 @@ func (driver *MySQLDriver) SyncSchema(ctx context.Context) ([]*DBSchema, error)
TABLE_NAME,
UNIX_TIMESTAMP(CREATE_TIME),
IFNULL(UNIX_TIMESTAMP(UPDATE_TIME), 0),
+ TABLE_TYPE,
IFNULL(ENGINE, ''),
IFNULL(TABLE_COLLATION, ''),
IFNULL(TABLE_ROWS, 0),
IFNULL(DATA_LENGTH, 0),
- IFNULL(INDEX_LENGTH, 0)
+ IFNULL(INDEX_LENGTH, 0),
+ IFNULL(DATA_FREE, 0),
+ IFNULL(CREATE_OPTIONS, ''),
+ IFNULL(TABLE_COMMENT, '')
FROM information_schema.TABLES
WHERE `+tableWhere,
)
@@ -101,11 +105,15 @@ func (driver *MySQLDriver) SyncSchema(ctx context.Context) ([]*DBSchema, error)
&table.Name,
&table.CreatedTs,
&table.UpdatedTs,
+ &table.Type,
&table.Engine,
&table.Collation,
&table.RowCount,
&table.DataSize,
&table.IndexSize,
+ &table.DataFree,
+ &table.CreateOptions,
+ &table.Comment,
); err != nil {
return nil, err
}
diff --git a/frontend/src/components/TableTable.vue b/frontend/src/components/TableTable.vue
index 34944e1c1c..90d46c0231 100644
--- a/frontend/src/components/TableTable.vue
+++ b/frontend/src/components/TableTable.vue
@@ -11,21 +11,24 @@
<BBTableCell :leftPadding="4" class="w-16">
{{ table.name }}
</BBTableCell>
- <BBTableCell class="w-8">
+ <BBTableCell v-if="mode == 'TABLE'" class="w-8">
{{ table.engine }}
</BBTableCell>
- <BBTableCell class="w-8">
+ <BBTableCell v-if="mode == 'TABLE'" class="w-8">
{{ table.collation }}
</BBTableCell>
- <BBTableCell class="w-16">
+ <BBTableCell v-if="mode == 'TABLE'" class="w-8">
{{ table.rowCount }}
</BBTableCell>
- <BBTableCell class="w-8">
+ <BBTableCell v-if="mode == 'TABLE'" class="w-8">
{{ bytesToString(table.dataSize) }}
</BBTableCell>
- <BBTableCell class="w-8">
+ <BBTableCell v-if="mode == 'TABLE'" class="w-8">
{{ bytesToString(table.indexSize) }}
</BBTableCell>
+ <BBTableCell v-if="mode == 'TABLE'" class="w-8">
+ {{ table.dataFree }}
+ </BBTableCell>
<BBTableCell class="w-8">
{{ table.syncStatus }}
</BBTableCell>
@@ -37,49 +40,80 @@
</template>
<script lang="ts">
-import { PropType } from "vue";
-import { useStore } from "vuex";
+import { computed, PropType } from "vue";
import { BBTableColumn } from "../bbkit/types";
import { Table } from "../types";
import { bytesToString } from "../utils";
-const columnList: BBTableColumn[] = [
- {
- title: "Name",
- },
- {
- title: "Engine",
- },
- {
- title: "Collation",
- },
- {
- title: "Row count est.",
- },
- {
- title: "Data size",
- },
- {
- title: "Index size",
- },
- {
- title: "Sync status",
- },
- {
- title: "Last successful sync",
- },
-];
+type Mode = "TABLE" | "VIEW";
+
+const columnListMap: Map<Mode, BBTableColumn[]> = new Map([
+ [
+ "TABLE",
+ [
+ {
+ title: "Name",
+ },
+ {
+ title: "Engine",
+ },
+ {
+ title: "Collation",
+ },
+ {
+ title: "Row count est.",
+ },
+ {
+ title: "Data size",
+ },
+ {
+ title: "Index size",
+ },
+ {
+ title: "Free size",
+ },
+ {
+ title: "Sync status",
+ },
+ {
+ title: "Last successful sync",
+ },
+ ],
+ ],
+ [
+ "VIEW",
+ [
+ {
+ title: "Name",
+ },
+ {
+ title: "Sync status",
+ },
+ {
+ title: "Last successful sync",
+ },
+ ],
+ ],
+]);
export default {
name: "TableTable",
components: {},
props: {
+ mode: {
+ default: "TABLE",
+ type: String as PropType<Mode>,
+ },
tableList: {
required: true,
type: Object as PropType<Table[]>,
},
},
setup(props, ctx) {
+ const columnList = computed(() => {
+ return columnListMap.get(props.mode);
+ });
+
return {
columnList,
bytesToString,
diff --git a/frontend/src/types/table.ts b/frontend/src/types/table.ts
index c3bcee796a..21fd177650 100644
--- a/frontend/src/types/table.ts
+++ b/frontend/src/types/table.ts
@@ -4,6 +4,9 @@ import { Principal } from "./principal";
// Similar to DatabaseSyncStatus, see comment
export type TableSyncStatus = "OK" | "NOT_FOUND";
+export type TableType = "BASE TABLE" | "VIEW";
+export type TableEngineType = "InnoDB";
+
// Table
export type Table = {
id: TableId;
@@ -19,11 +22,16 @@ export type Table = {
// Domain specific fields
name: string;
- engine: string;
+ table: string;
+ type: TableType;
+ engine: TableEngineType;
collation: string;
syncStatus: TableSyncStatus;
lastSuccessfulSyncTs: number;
rowCount: number;
dataSize: number;
indexSize: number;
+ dataFree: number;
+ createOptions: string;
+ comment: string;
};
diff --git a/frontend/src/views/DatabaseDetail.vue b/frontend/src/views/DatabaseDetail.vue
index 0045275d7e..496843c223 100644
--- a/frontend/src/views/DatabaseDetail.vue
+++ b/frontend/src/views/DatabaseDetail.vue
@@ -142,7 +142,18 @@
<div class="text-lg leading-6 font-medium text-main mb-4">
Tables
</div>
- <TableTable :tableList="tableList" />
+ <TableTable
+ :mode="'TABLE'"
+ :tableList="tableList.filter((item) => item.type == 'BASE TABLE')"
+ />
+
+ <div class="mt-6 text-lg leading-6 font-medium text-main mb-4">
+ Views
+ </div>
+ <TableTable
+ :mode="'VIEW'"
+ :tableList="tableList.filter((item) => item.type == 'VIEW')"
+ />
</div>
<!-- Hide data source list for now, as we don't allow adding new data source after creating the database. -->
diff --git a/server/sql.go b/server/sql.go
index 0e46a9f30e..f65ca22f65 100644
--- a/server/sql.go
+++ b/server/sql.go
@@ -149,14 +149,18 @@ func (s *Server) registerSqlRoutes(g *echo.Group) {
if err != nil {
if bytebase.ErrorCode(err) == bytebase.ENOTFOUND {
tableCreate := &api.TableCreate{
- CreatorId: api.SYSTEM_BOT_ID,
- DatabaseId: database.ID,
- Name: table.Name,
- Engine: table.Engine,
- Collation: table.Collation,
- RowCount: table.RowCount,
- DataSize: table.DataSize,
- IndexSize: table.IndexSize,
+ CreatorId: api.SYSTEM_BOT_ID,
+ DatabaseId: database.ID,
+ Name: table.Name,
+ Type: table.Type,
+ Engine: table.Engine,
+ Collation: table.Collation,
+ RowCount: table.RowCount,
+ DataSize: table.DataSize,
+ IndexSize: table.IndexSize,
+ DataFree: table.DataFree,
+ CreateOptions: table.CreateOptions,
+ Comment: table.Comment,
}
if err := createTable(database, tableCreate); err != nil {
return err
@@ -200,14 +204,18 @@ func (s *Server) registerSqlRoutes(g *echo.Group) {
for _, table := range schema.TableList {
tableCreate := &api.TableCreate{
- CreatorId: api.SYSTEM_BOT_ID,
- DatabaseId: database.ID,
- Name: table.Name,
- Engine: table.Engine,
- Collation: table.Collation,
- RowCount: table.RowCount,
- DataSize: table.DataSize,
- IndexSize: table.IndexSize,
+ CreatorId: api.SYSTEM_BOT_ID,
+ DatabaseId: database.ID,
+ Name: table.Name,
+ Type: table.Type,
+ Engine: table.Engine,
+ Collation: table.Collation,
+ RowCount: table.RowCount,
+ DataSize: table.DataSize,
+ IndexSize: table.IndexSize,
+ DataFree: table.DataFree,
+ CreateOptions: table.CreateOptions,
+ Comment: table.Comment,
}
if err := createTable(database, tableCreate); err != nil {
return err
@@ -331,14 +339,18 @@ func (s *Server) SyncSchema(instance *api.Instance) (rs *api.SqlResultSet) {
if err != nil {
if bytebase.ErrorCode(err) == bytebase.ENOTFOUND {
tableCreate := &api.TableCreate{
- CreatorId: api.SYSTEM_BOT_ID,
- DatabaseId: database.ID,
- Name: table.Name,
- Engine: table.Engine,
- Collation: table.Collation,
- RowCount: table.RowCount,
- DataSize: table.DataSize,
- IndexSize: table.IndexSize,
+ CreatorId: api.SYSTEM_BOT_ID,
+ DatabaseId: database.ID,
+ Name: table.Name,
+ Type: table.Type,
+ Engine: table.Engine,
+ Collation: table.Collation,
+ RowCount: table.RowCount,
+ DataSize: table.DataSize,
+ IndexSize: table.IndexSize,
+ DataFree: table.DataFree,
+ CreateOptions: table.CreateOptions,
+ Comment: table.Comment,
}
if err := createTable(database, tableCreate); err != nil {
return err
@@ -382,14 +394,18 @@ func (s *Server) SyncSchema(instance *api.Instance) (rs *api.SqlResultSet) {
for _, table := range schema.TableList {
tableCreate := &api.TableCreate{
- CreatorId: api.SYSTEM_BOT_ID,
- DatabaseId: database.ID,
- Name: table.Name,
- Engine: table.Engine,
- Collation: table.Collation,
- RowCount: table.RowCount,
- DataSize: table.DataSize,
- IndexSize: table.IndexSize,
+ CreatorId: api.SYSTEM_BOT_ID,
+ DatabaseId: database.ID,
+ Name: table.Name,
+ Type: table.Type,
+ Engine: table.Engine,
+ Collation: table.Collation,
+ RowCount: table.RowCount,
+ DataSize: table.DataSize,
+ IndexSize: table.IndexSize,
+ DataFree: table.DataFree,
+ CreateOptions: table.CreateOptions,
+ Comment: table.Comment,
}
if err := createTable(database, tableCreate); err != nil {
return err
diff --git a/store/migration/10001__init_schema.sql b/store/migration/10001__init_schema.sql
index 4a5a85e90b..93a7c988c7 100644
--- a/store/migration/10001__init_schema.sql
+++ b/store/migration/10001__init_schema.sql
@@ -335,6 +335,7 @@ CREATE TABLE tbl (
updated_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now')),
database_id INTEGER NOT NULL REFERENCES db (id),
name TEXT NOT NULL,
+ `type` TEXT NOT NULL,
`engine` TEXT NOT NULL,
`collation` TEXT NOT NULL,
sync_status TEXT NOT NULL CHECK (sync_status IN ('OK', 'NOT_FOUND')),
@@ -342,6 +343,9 @@ CREATE TABLE tbl (
row_count BIGINT NOT NULL,
data_size BIGINT NOT NULL,
index_size BIGINT NOT NULL,
+ data_free BIGINT NOT NULL,
+ create_options TEXT NOT NULL,
+ `comment` TEXT NOT NULL,
UNIQUE(database_id, name)
);
diff --git a/store/seed/test/10071__tbl.sql b/store/seed/test/10071__tbl.sql
index 45fd79dd6e..5ae5e7aba6 100644
--- a/store/seed/test/10071__tbl.sql
+++ b/store/seed/test/10071__tbl.sql
@@ -5,13 +5,17 @@ INSERT INTO
updater_id,
database_id,
name,
+ `type`,
ENGINE,
`collation`,
sync_status,
last_successful_sync_ts,
row_count,
data_size,
- index_size
+ index_size,
+ data_free,
+ create_options,
+ `comment`
)
VALUES
(
@@ -19,13 +23,17 @@ VALUES
101,
7002,
'tbl1',
+ 'BASE TABLE',
'InnoDB',
'utf8mb4_0900_ai_ci',
'OK',
1625075289,
1234,
16384,
- 0
+ 0,
+ 0,
+ '',
+ ''
);
-- Table for database 7006 testdb_integration
@@ -35,13 +43,17 @@ INSERT INTO
updater_id,
database_id,
name,
+ `type`,
ENGINE,
`collation`,
sync_status,
last_successful_sync_ts,
row_count,
data_size,
- index_size
+ index_size,
+ data_free,
+ create_options,
+ `comment`
)
VALUES
(
@@ -49,13 +61,17 @@ VALUES
101,
7006,
'tbl1',
+ 'BASE TABLE',
'InnoDB',
'utf8mb4_0900_ai_ci',
'OK',
1625075289,
1234,
16384,
- 16384
+ 16384,
+ 65536,
+ '',
+ ''
);
-- Table for database 7010 testdb_staging
@@ -65,13 +81,17 @@ INSERT INTO
updater_id,
database_id,
name,
+ `type`,
ENGINE,
`collation`,
sync_status,
last_successful_sync_ts,
row_count,
data_size,
- index_size
+ index_size,
+ data_free,
+ create_options,
+ `comment`
)
VALUES
(
@@ -79,13 +99,17 @@ VALUES
101,
7010,
'tbl1',
+ 'BASE TABLE',
'InnoDB',
'utf8mb4_0900_ai_ci',
'OK',
1624475289,
12234,
65536,
- 16384
+ 16384,
+ 655360,
+ '',
+ ''
);
-- Table for database 7014 testdb_prod
@@ -95,13 +119,17 @@ INSERT INTO
updater_id,
database_id,
name,
+ `type`,
ENGINE,
`collation`,
sync_status,
last_successful_sync_ts,
row_count,
data_size,
- index_size
+ index_size,
+ data_free,
+ create_options,
+ `comment`
)
VALUES
(
@@ -109,13 +137,17 @@ VALUES
101,
7014,
'tbl1',
+ 'BASE TABLE',
'InnoDB',
'utf8mb4_0900_ai_ci',
'OK',
1624475289,
1234,
32768,
- 4096
+ 4096,
+ 327680,
+ '',
+ ''
);
-- Table for database 7003 shop
@@ -125,13 +157,17 @@ INSERT INTO
updater_id,
database_id,
name,
+ `type`,
ENGINE,
`collation`,
sync_status,
last_successful_sync_ts,
row_count,
data_size,
- index_size
+ index_size,
+ data_free,
+ create_options,
+ `comment`
)
VALUES
(
@@ -139,13 +175,17 @@ VALUES
101,
7003,
'product',
+ 'BASE TABLE',
'InnoDB',
'utf8mb4_0900_ai_ci',
'OK',
1624275289,
1000,
4096,
- 0
+ 0,
+ 409600,
+ '',
+ ''
);
-- Table for database 7007 shop
@@ -155,13 +195,17 @@ INSERT INTO
updater_id,
database_id,
name,
+ `type`,
ENGINE,
`collation`,
sync_status,
last_successful_sync_ts,
row_count,
data_size,
- index_size
+ index_size,
+ data_free,
+ create_options,
+ `comment`
)
VALUES
(
@@ -169,13 +213,17 @@ VALUES
101,
7007,
'product',
+ 'BASE TABLE',
'InnoDB',
'utf8mb4_0900_ai_ci',
'OK',
1624575289,
1000,
4096,
- 1024
+ 1024,
+ 0,
+ '',
+ ''
);
-- Table for database 7004 blog
@@ -185,13 +233,17 @@ INSERT INTO
updater_id,
database_id,
name,
+ `type`,
ENGINE,
`collation`,
sync_status,
last_successful_sync_ts,
row_count,
data_size,
- index_size
+ index_size,
+ data_free,
+ create_options,
+ `comment`
)
VALUES
(
@@ -199,13 +251,17 @@ VALUES
101,
7004,
'user',
+ 'BASE TABLE',
'InnoDB',
'utf8mb4_0900_ai_ci',
'OK',
1624275289,
1000,
4096,
- 1024
+ 1024,
+ 204800,
+ '',
+ ''
);
INSERT INTO
@@ -214,13 +270,17 @@ INSERT INTO
updater_id,
database_id,
name,
+ `type`,
ENGINE,
`collation`,
sync_status,
last_successful_sync_ts,
row_count,
data_size,
- index_size
+ index_size,
+ data_free,
+ create_options,
+ `comment`
)
VALUES
(
@@ -228,13 +288,17 @@ VALUES
101,
7004,
'post',
+ 'BASE TABLE',
'InnoDB',
'utf8mb4_0900_ai_ci',
'OK',
1624275289,
1000,
8192,
- 1024
+ 1024,
+ 204800,
+ '',
+ ''
);
INSERT INTO
@@ -243,13 +307,17 @@ INSERT INTO
updater_id,
database_id,
name,
+ `type`,
ENGINE,
`collation`,
sync_status,
last_successful_sync_ts,
row_count,
data_size,
- index_size
+ index_size,
+ data_free,
+ create_options,
+ `comment`
)
VALUES
(
@@ -257,13 +325,17 @@ VALUES
101,
7004,
'comment',
+ 'BASE TABLE',
'InnoDB',
'utf8mb4_0900_ai_ci',
'OK',
1624275289,
30000,
65536,
- 4096
+ 4096,
+ 102400,
+ '',
+ ''
);
-- Table for database 7008 blog
@@ -273,13 +345,17 @@ INSERT INTO
updater_id,
database_id,
name,
+ `type`,
ENGINE,
`collation`,
sync_status,
last_successful_sync_ts,
row_count,
data_size,
- index_size
+ index_size,
+ data_free,
+ create_options,
+ `comment`
)
VALUES
(
@@ -287,13 +363,17 @@ VALUES
101,
7008,
'user',
+ 'BASE TABLE',
'InnoDB',
'utf8mb4_0900_ai_ci',
'OK',
1624675289,
100,
4096,
- 0
+ 0,
+ 204800,
+ '',
+ ''
);
INSERT INTO
@@ -302,13 +382,17 @@ INSERT INTO
updater_id,
database_id,
name,
+ `type`,
ENGINE,
`collation`,
sync_status,
last_successful_sync_ts,
row_count,
data_size,
- index_size
+ index_size,
+ data_free,
+ create_options,
+ `comment`
)
VALUES
(
@@ -316,13 +400,17 @@ VALUES
101,
7008,
'post',
+ 'BASE TABLE',
'InnoDB',
'utf8mb4_0900_ai_ci',
'OK',
1624675289,
300,
4096,
- 1024
+ 1024,
+ 102400,
+ '',
+ ''
);
INSERT INTO
@@ -331,13 +419,17 @@ INSERT INTO
updater_id,
database_id,
name,
+ `type`,
ENGINE,
`collation`,
sync_status,
last_successful_sync_ts,
row_count,
data_size,
- index_size
+ index_size,
+ data_free,
+ create_options,
+ `comment`
)
VALUES
(
@@ -345,13 +437,17 @@ VALUES
101,
7008,
'comment',
+ 'BASE TABLE',
'InnoDB',
'utf8mb4_0900_ai_ci',
'OK',
1624675289,
2000,
65536,
- 2048
+ 2048,
+ 40960,
+ '',
+ ''
);
-- Table for database 7012 blog
@@ -361,13 +457,17 @@ INSERT INTO
updater_id,
database_id,
name,
+ `type`,
ENGINE,
`collation`,
sync_status,
last_successful_sync_ts,
row_count,
data_size,
- index_size
+ index_size,
+ data_free,
+ create_options,
+ `comment`
)
VALUES
(
@@ -375,13 +475,17 @@ VALUES
101,
7012,
'user',
+ 'BASE TABLE',
'InnoDB',
'utf8mb4_0900_ai_ci',
'OK',
1622675289,
200,
4096,
- 1024
+ 1024,
+ 81920,
+ '',
+ ''
);
INSERT INTO
@@ -390,13 +494,17 @@ INSERT INTO
updater_id,
database_id,
name,
+ `type`,
ENGINE,
`collation`,
sync_status,
last_successful_sync_ts,
row_count,
data_size,
- index_size
+ index_size,
+ data_free,
+ create_options,
+ `comment`
)
VALUES
(
@@ -404,13 +512,17 @@ VALUES
101,
7012,
'post',
+ 'BASE TABLE',
'InnoDB',
'utf8mb4_0900_ai_ci',
'OK',
1622675289,
500,
4096,
- 1024
+ 1024,
+ 8192,
+ '',
+ ''
);
INSERT INTO
@@ -419,13 +531,17 @@ INSERT INTO
updater_id,
database_id,
name,
+ `type`,
ENGINE,
`collation`,
sync_status,
last_successful_sync_ts,
row_count,
data_size,
- index_size
+ index_size,
+ data_free,
+ create_options,
+ `comment`
)
VALUES
(
@@ -433,13 +549,17 @@ VALUES
101,
7012,
'comment',
+ 'BASE TABLE',
'InnoDB',
'utf8mb4_0900_ai_ci',
'OK',
1622675289,
4000,
65536,
- 65536
+ 65536,
+ 20480,
+ '',
+ ''
);
-- Table for database 7016 blog
@@ -449,13 +569,17 @@ INSERT INTO
updater_id,
database_id,
name,
+ `type`,
ENGINE,
`collation`,
sync_status,
last_successful_sync_ts,
row_count,
data_size,
- index_size
+ index_size,
+ data_free,
+ create_options,
+ `comment`
)
VALUES
(
@@ -463,13 +587,17 @@ VALUES
101,
7016,
'user',
+ 'BASE TABLE',
'InnoDB',
'utf8mb4_0900_ai_ci',
'OK',
1622275289,
200,
4096,
- 1024
+ 1024,
+ 0,
+ '',
+ ''
);
INSERT INTO
@@ -478,13 +606,17 @@ INSERT INTO
updater_id,
database_id,
name,
+ `type`,
ENGINE,
`collation`,
sync_status,
last_successful_sync_ts,
row_count,
data_size,
- index_size
+ index_size,
+ data_free,
+ create_options,
+ `comment`
)
VALUES
(
@@ -492,13 +624,17 @@ VALUES
101,
7016,
'post',
+ 'BASE TABLE',
'InnoDB',
'utf8mb4_0900_ai_ci',
'OK',
1622275289,
500,
4096,
- 1024
+ 1024,
+ 2048,
+ '',
+ ''
);
INSERT INTO
@@ -507,13 +643,17 @@ INSERT INTO
updater_id,
database_id,
name,
+ `type`,
ENGINE,
`collation`,
sync_status,
last_successful_sync_ts,
row_count,
data_size,
- index_size
+ index_size,
+ data_free,
+ create_options,
+ `comment`
)
VALUES
(
@@ -521,11 +661,15 @@ VALUES
101,
7016,
'comment',
+ 'BASE TABLE',
'InnoDB',
'utf8mb4_0900_ai_ci',
'OK',
1622275289,
7000,
8192,
- 0
+ 0,
+ 8192,
+ '',
+ ''
);
\ No newline at end of file
diff --git a/store/table.go b/store/table.go
index ddf562f6ec..710944042b 100644
--- a/store/table.go
+++ b/store/table.go
@@ -112,26 +112,34 @@ func (s *TableService) createTable(ctx context.Context, tx *Tx, create *api.Tabl
updater_id,
database_id,
name,
+ `+"`type`,"+`
engine,
collation,
sync_status,
last_successful_sync_ts,
row_count,
data_size,
- index_size
+ index_size,
+ data_free,
+ create_options,
+ comment
)
- VALUES (?, ?, ?, ?, ?, ?, 'OK', (strftime('%s', 'now')), ?, ?, ?)
- RETURNING id, creator_id, created_ts, updater_id, updated_ts, database_id, name, engine, collation, sync_status, last_successful_sync_ts, row_count, data_size, index_size
+ VALUES (?, ?, ?, ?, ?, ?, ?, 'OK', (strftime('%s', 'now')), ?, ?, ?, ?, ?, ?)
+ RETURNING id, creator_id, created_ts, updater_id, updated_ts, database_id, name, `+"`type`, engine, collation, sync_status, last_successful_sync_ts, row_count, data_size, index_size, data_free, create_options, comment"+`
`,
create.CreatorId,
create.CreatorId,
create.DatabaseId,
create.Name,
+ create.Type,
create.Engine,
create.Collation,
create.RowCount,
create.DataSize,
create.IndexSize,
+ create.DataFree,
+ create.CreateOptions,
+ create.Comment,
)
if err != nil {
@@ -149,6 +157,7 @@ func (s *TableService) createTable(ctx context.Context, tx *Tx, create *api.Tabl
&table.UpdatedTs,
&table.DatabaseId,
&table.Name,
+ &table.Type,
&table.Engine,
&table.Collation,
&table.SyncStatus,
@@ -156,6 +165,9 @@ func (s *TableService) createTable(ctx context.Context, tx *Tx, create *api.Tabl
&table.RowCount,
&table.DataSize,
&table.IndexSize,
+ &table.DataFree,
+ &table.CreateOptions,
+ &table.Comment,
); err != nil {
return nil, FormatError(err)
}
@@ -185,13 +197,17 @@ func (s *TableService) findTableList(ctx context.Context, tx *Tx, find *api.Tabl
updated_ts,
database_id,
name,
+ `+"`type`,"+`
engine,
collation,
sync_status,
last_successful_sync_ts,
row_count,
data_size,
- index_size
+ index_size,
+ data_free,
+ create_options,
+ comment
FROM tbl
WHERE `+strings.Join(where, " AND "),
args...,
@@ -213,6 +229,7 @@ func (s *TableService) findTableList(ctx context.Context, tx *Tx, find *api.Tabl
&table.UpdatedTs,
&table.DatabaseId,
&table.Name,
+ &table.Type,
&table.Engine,
&table.Collation,
&table.SyncStatus,
@@ -220,6 +237,9 @@ func (s *TableService) findTableList(ctx context.Context, tx *Tx, find *api.Tabl
&table.RowCount,
&table.DataSize,
&table.IndexSize,
+ &table.DataFree,
+ &table.CreateOptions,
+ &table.Comment,
); err != nil {
return nil, FormatError(err)
}
@@ -251,7 +271,7 @@ func (s *TableService) patchTable(ctx context.Context, tx *Tx, patch *api.TableP
UPDATE tbl
SET `+strings.Join(set, ", ")+`
WHERE id = ?
- RETURNING id, creator_id, created_ts, updater_id, updated_ts, database_id, name, engine, collation, sync_status, last_successful_sync_ts, row_count, data_size, index_size
+ RETURNING id, creator_id, created_ts, updater_id, updated_ts, database_id, name, `+"`type`, engine, collation, sync_status, last_successful_sync_ts, row_count, data_size, index_size, data_free, create_options, comment"+`
`,
args...,
)
@@ -270,6 +290,7 @@ func (s *TableService) patchTable(ctx context.Context, tx *Tx, patch *api.TableP
&table.UpdatedTs,
&table.DatabaseId,
&table.Name,
+ &table.Type,
&table.Engine,
&table.Collation,
&table.SyncStatus,
@@ -277,6 +298,9 @@ func (s *TableService) patchTable(ctx context.Context, tx *Tx, patch *api.TableP
&table.RowCount,
&table.DataSize,
&table.IndexSize,
+ &table.DataFree,
+ &table.CreateOptions,
+ &table.Comment,
); err != nil {
return nil, FormatError(err)
}