Skip to content

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

Remove DRIFTED sync status and fingerprint column from db table for now and improve comment on db/table syncStatus

天舟bdd92ce6f16a
diff --git a/api/database.go b/api/database.go
index 3f3c8373dd..1348d887cd 100644
--- a/api/database.go
+++ b/api/database.go
@@ -16,7 +16,6 @@ type SyncStatus string
const (
OK SyncStatus = "OK"
- Drifted SyncStatus = "DRIFTED"
NotFound SyncStatus = "NOT_FOUND"
)
@@ -24,8 +23,6 @@ func (e SyncStatus) String() string {
switch e {
case OK:
return "OK"
- case Drifted:
- return "DRIFTED"
case NotFound:
return "NOT_FOUND"
}
@@ -56,7 +53,6 @@ type Database struct {
Collation string `jsonapi:"attr,collation"`
SyncStatus SyncStatus `jsonapi:"attr,syncStatus"`
LastSuccessfulSyncTs int64 `jsonapi:"attr,lastSuccessfulSyncTs"`
- Fingerprint string `jsonapi:"attr,fingerprint"`
}
type DatabaseCreate struct {
diff --git a/frontend/src/types/common.ts b/frontend/src/types/common.ts
index 0238587a48..b6885e1a97 100644
--- a/frontend/src/types/common.ts
+++ b/frontend/src/types/common.ts
@@ -200,7 +200,6 @@ export const unknown = (
collation: "",
syncStatus: "NOT_FOUND",
lastSuccessfulSyncTs: 0,
- fingerprint: "",
};
const UNKNOWN_DATA_SOURCE: DataSource = {
@@ -478,7 +477,6 @@ export const empty = (
collation: "",
syncStatus: "NOT_FOUND",
lastSuccessfulSyncTs: 0,
- fingerprint: "",
};
const EMPTY_DATA_SOURCE: DataSource = {
diff --git a/frontend/src/types/database.ts b/frontend/src/types/database.ts
index d4bd8f18b7..727a55ba2c 100644
--- a/frontend/src/types/database.ts
+++ b/frontend/src/types/database.ts
@@ -8,12 +8,9 @@ import { Principal } from "./principal";
import { Project } from "./project";
import { DataSource } from "./dataSource";
-// "OK" means find the exact match
-// "DRIFTED" means we find the database with the same name, but the fingerprint is different,
-// this usually indicates the underlying database has been recreated (might for a entirely different purpose)
-// "NOT_FOUND" means no matching database name found, this ususally means someone changes
-// the underlying db name.
-export type DatabaseSyncStatus = "OK" | "DRIFTED" | "NOT_FOUND";
+// "OK" means we find the database with the same name.
+// "NOT_FOUND" means no matching database name found, this ususally means someone changes the underlying db name without Bytebase knowledge.
+export type DatabaseSyncStatus = "OK" | "NOT_FOUND";
// Database
export type Database = {
id: DatabaseId;
@@ -35,7 +32,6 @@ export type Database = {
collation: string;
syncStatus: DatabaseSyncStatus;
lastSuccessfulSyncTs: number;
- fingerprint: string;
};
export type DatabaseCreate = {
diff --git a/frontend/src/types/table.ts b/frontend/src/types/table.ts
index b88e4496d4..a25906ef39 100644
--- a/frontend/src/types/table.ts
+++ b/frontend/src/types/table.ts
@@ -1,14 +1,9 @@
-// "OK" means find the exact match
-// "DRIFTED" means we find the table with the same name, but the fingerprint is different,
-// this usually indicates the underlying table has been recreated (might for a entirely different purpose)
-// "NOT_FOUND" means no matching table name found, this ususally means someone changes
-
import { Database } from "./database";
import { TableId } from "./id";
import { Principal } from "./principal";
-// the underlying table name.
-export type TableSyncStatus = "OK" | "DRIFTED" | "NOT_FOUND";
+// Similar to DatabaseSyncStatus, see comment
+export type TableSyncStatus = "OK" | "NOT_FOUND";
// Table
export type Table = {
id: TableId;
diff --git a/store/database.go b/store/database.go
index a1b666f5ef..cb004f7f3e 100644
--- a/store/database.go
+++ b/store/database.go
@@ -121,11 +121,10 @@ func (s *DatabaseService) createDatabase(ctx context.Context, tx *sql.Tx, create
character_set,
collation,
sync_status,
- last_successful_sync_ts,
- fingerprint
+ last_successful_sync_ts
)
- VALUES (?, ?, ?, ?, ?, ?, ?, 'OK', (strftime('%s', 'now')), '')
- RETURNING id, creator_id, created_ts, updater_id, updated_ts, instance_id, project_id, name, character_set, collation, sync_status, last_successful_sync_ts, fingerprint
+ VALUES (?, ?, ?, ?, ?, ?, ?, 'OK', (strftime('%s', 'now')))
+ RETURNING id, creator_id, created_ts, updater_id, updated_ts, instance_id, project_id, name, character_set, collation, sync_status, last_successful_sync_ts
`,
create.CreatorId,
create.CreatorId,
@@ -156,7 +155,6 @@ func (s *DatabaseService) createDatabase(ctx context.Context, tx *sql.Tx, create
&database.Collation,
&database.SyncStatus,
&database.LastSuccessfulSyncTs,
- &database.Fingerprint,
); err != nil {
return nil, FormatError(err)
}
@@ -196,8 +194,7 @@ func (s *DatabaseService) findDatabaseList(ctx context.Context, tx *Tx, find *ap
character_set,
collation,
sync_status,
- last_successful_sync_ts,
- fingerprint
+ last_successful_sync_ts
FROM db
WHERE `+strings.Join(where, " AND "),
args...,
@@ -224,7 +221,6 @@ func (s *DatabaseService) findDatabaseList(ctx context.Context, tx *Tx, find *ap
&database.Collation,
&database.SyncStatus,
&database.LastSuccessfulSyncTs,
- &database.Fingerprint,
); err != nil {
return nil, FormatError(err)
}
@@ -259,7 +255,7 @@ func (s *DatabaseService) patchDatabase(ctx context.Context, tx *Tx, patch *api.
UPDATE db
SET `+strings.Join(set, ", ")+`
WHERE id = ?
- RETURNING id, creator_id, created_ts, updater_id, updated_ts, instance_id, project_id, name, character_set, collation, sync_status, last_successful_sync_ts, fingerprint
+ RETURNING id, creator_id, created_ts, updater_id, updated_ts, instance_id, project_id, name, character_set, collation, sync_status, last_successful_sync_ts
`,
args...,
)
@@ -283,7 +279,6 @@ func (s *DatabaseService) patchDatabase(ctx context.Context, tx *Tx, patch *api.
&database.Collation,
&database.SyncStatus,
&database.LastSuccessfulSyncTs,
- &database.Fingerprint,
); err != nil {
return nil, FormatError(err)
}
diff --git a/store/migration/10001__init_schema.sql b/store/migration/10001__init_schema.sql
index 533561939c..10cb908742 100644
--- a/store/migration/10001__init_schema.sql
+++ b/store/migration/10001__init_schema.sql
@@ -263,11 +263,8 @@ CREATE TABLE db (
name TEXT NOT NULL,
character_set TEXT NOT NULL,
`collation` TEXT NOT NULL,
- sync_status TEXT NOT NULL CHECK (
- sync_status IN ('OK', 'DRIFTED', 'NOT_FOUND')
- ),
+ sync_status TEXT NOT NULL CHECK (sync_status IN ('OK', 'NOT_FOUND')),
last_successful_sync_ts BIGINT NOT NULL,
- fingerprint TEXT NOT NULL,
UNIQUE(instance_id, name)
);
@@ -307,9 +304,7 @@ CREATE TABLE tbl (
row_count BIGINT NOT NULL,
data_size BIGINT NOT NULL,
index_size BIGINT NOT NULL,
- sync_status TEXT NOT NULL CHECK (
- sync_status IN ('OK', 'DRIFTED', 'NOT_FOUND')
- ),
+ sync_status TEXT NOT NULL CHECK (sync_status IN ('OK', 'NOT_FOUND')),
last_successful_sync_ts BIGINT NOT NULL,
UNIQUE(database_id, name)
);
diff --git a/store/seed/release/10001__init_seed.sql b/store/seed/release/10001__init_seed.sql
index 37d8c90557..bff60fb2aa 100644
--- a/store/seed/release/10001__init_seed.sql
+++ b/store/seed/release/10001__init_seed.sql
@@ -71,8 +71,7 @@ INSERT INTO
character_set,
`collation`,
sync_status,
- last_successful_sync_ts,
- fingerprint
+ last_successful_sync_ts
)
VALUES
(
@@ -85,8 +84,7 @@ VALUES
'utf8mb4',
'utf8mb4_0900_ai_ci',
'OK',
- 0,
- ''
+ 0
);
INSERT INTO
@@ -151,8 +149,7 @@ INSERT INTO
character_set,
`collation`,
sync_status,
- last_successful_sync_ts,
- fingerprint
+ last_successful_sync_ts
)
VALUES
(
@@ -165,8 +162,7 @@ VALUES
'utf8mb4',
'utf8mb4_0900_ai_ci',
'OK',
- 0,
- ''
+ 0
);
INSERT INTO
diff --git a/store/seed/test/10070__db.sql b/store/seed/test/10070__db.sql
index 285a584da8..37a9cbe035 100644
--- a/store/seed/test/10070__db.sql
+++ b/store/seed/test/10070__db.sql
@@ -10,8 +10,7 @@ INSERT INTO
character_set,
`collation`,
sync_status,
- last_successful_sync_ts,
- fingerprint
+ last_successful_sync_ts
)
VALUES
(
@@ -24,8 +23,7 @@ VALUES
'utf8mb4',
'utf8mb4_0900_ai_ci',
'OK',
- 0,
- ''
+ 0
);
INSERT INTO
@@ -39,8 +37,7 @@ INSERT INTO
character_set,
`collation`,
sync_status,
- last_successful_sync_ts,
- fingerprint
+ last_successful_sync_ts
)
VALUES
(
@@ -53,8 +50,7 @@ VALUES
'utf8mb4',
'utf8mb4_0900_ai_ci',
'OK',
- 1624558090,
- ''
+ 1624558090
);
INSERT INTO
@@ -68,8 +64,7 @@ INSERT INTO
character_set,
`collation`,
sync_status,
- last_successful_sync_ts,
- fingerprint
+ last_successful_sync_ts
)
VALUES
(
@@ -82,8 +77,7 @@ VALUES
'utf8mb4',
'utf8mb4_0900_ai_ci',
'OK',
- 0,
- ''
+ 0
);
INSERT INTO
@@ -97,8 +91,7 @@ INSERT INTO
character_set,
`collation`,
sync_status,
- last_successful_sync_ts,
- fingerprint
+ last_successful_sync_ts
)
VALUES
(
@@ -111,8 +104,7 @@ VALUES
'utf8mb4',
'utf8mb4_0900_ai_ci',
'OK',
- 0,
- ''
+ 0
);
-- Database for integration environment instance 6002
@@ -127,8 +119,7 @@ INSERT INTO
character_set,
`collation`,
sync_status,
- last_successful_sync_ts,
- fingerprint
+ last_successful_sync_ts
)
VALUES
(
@@ -141,8 +132,7 @@ VALUES
'utf8mb4',
'utf8mb4_0900_ai_ci',
'OK',
- 0,
- ''
+ 0
);
INSERT INTO
@@ -156,8 +146,7 @@ INSERT INTO
character_set,
`collation`,
sync_status,
- last_successful_sync_ts,
- fingerprint
+ last_successful_sync_ts
)
VALUES
(
@@ -170,8 +159,7 @@ VALUES
'utf8mb4',
'utf8mb4_0900_ai_ci',
'OK',
- 0,
- ''
+ 0
);
INSERT INTO
@@ -185,8 +173,7 @@ INSERT INTO
character_set,
`collation`,
sync_status,
- last_successful_sync_ts,
- fingerprint
+ last_successful_sync_ts
)
VALUES
(
@@ -199,8 +186,7 @@ VALUES
'utf8mb4',
'utf8mb4_0900_ai_ci',
'OK',
- 0,
- ''
+ 0
);
INSERT INTO
@@ -214,8 +200,7 @@ INSERT INTO
character_set,
`collation`,
sync_status,
- last_successful_sync_ts,
- fingerprint
+ last_successful_sync_ts
)
VALUES
(
@@ -228,8 +213,7 @@ VALUES
'utf8mb4',
'utf8mb4_0900_ai_ci',
'OK',
- 0,
- ''
+ 0
);
-- Database for staging environment instance 6003
@@ -244,8 +228,7 @@ INSERT INTO
character_set,
`collation`,
sync_status,
- last_successful_sync_ts,
- fingerprint
+ last_successful_sync_ts
)
VALUES
(
@@ -258,8 +241,7 @@ VALUES
'utf8mb4',
'utf8mb4_0900_ai_ci',
'OK',
- 0,
- ''
+ 0
);
INSERT INTO
@@ -273,8 +255,7 @@ INSERT INTO
character_set,
`collation`,
sync_status,
- last_successful_sync_ts,
- fingerprint
+ last_successful_sync_ts
)
VALUES
(
@@ -287,8 +268,7 @@ VALUES
'utf8mb4',
'utf8mb4_0900_ai_ci',
'OK',
- 0,
- ''
+ 0
);
INSERT INTO
@@ -302,8 +282,7 @@ INSERT INTO
character_set,
`collation`,
sync_status,
- last_successful_sync_ts,
- fingerprint
+ last_successful_sync_ts
)
VALUES
(
@@ -316,8 +295,7 @@ VALUES
'utf8mb4',
'utf8mb4_0900_ai_ci',
'OK',
- 0,
- ''
+ 0
);
INSERT INTO
@@ -331,8 +309,7 @@ INSERT INTO
character_set,
`collation`,
sync_status,
- last_successful_sync_ts,
- fingerprint
+ last_successful_sync_ts
)
VALUES
(
@@ -345,8 +322,7 @@ VALUES
'utf8mb4',
'utf8mb4_0900_ai_ci',
'OK',
- 0,
- ''
+ 0
);
-- Database for prod environment instance 6004
@@ -361,8 +337,7 @@ INSERT INTO
character_set,
`collation`,
sync_status,
- last_successful_sync_ts,
- fingerprint
+ last_successful_sync_ts
)
VALUES
(
@@ -375,8 +350,7 @@ VALUES
'utf8mb4',
'utf8mb4_0900_ai_ci',
'OK',
- 0,
- ''
+ 0
);
INSERT INTO
@@ -390,8 +364,7 @@ INSERT INTO
character_set,
`collation`,
sync_status,
- last_successful_sync_ts,
- fingerprint
+ last_successful_sync_ts
)
VALUES
(
@@ -404,8 +377,7 @@ VALUES
'utf8mb4',
'utf8mb4_0900_ai_ci',
'OK',
- 0,
- ''
+ 0
);
INSERT INTO
@@ -419,8 +391,7 @@ INSERT INTO
character_set,
`collation`,
sync_status,
- last_successful_sync_ts,
- fingerprint
+ last_successful_sync_ts
)
VALUES
(
@@ -433,8 +404,7 @@ VALUES
'utf8mb4',
'utf8mb4_0900_ai_ci',
'OK',
- 0,
- ''
+ 0
);
INSERT INTO
@@ -448,8 +418,7 @@ INSERT INTO
character_set,
`collation`,
sync_status,
- last_successful_sync_ts,
- fingerprint
+ last_successful_sync_ts
)
VALUES
(
@@ -462,8 +431,7 @@ VALUES
'utf8mb4',
'utf8mb4_0900_ai_ci',
'OK',
- 0,
- ''
+ 0
);
INSERT INTO
@@ -477,8 +445,7 @@ INSERT INTO
character_set,
`collation`,
sync_status,
- last_successful_sync_ts,
- fingerprint
+ last_successful_sync_ts
)
VALUES
(
@@ -491,6 +458,5 @@ VALUES
'utf8mb4',
'utf8mb4_0900_ai_ci',
'OK',
- 0,
- ''
+ 0
);
\ No newline at end of file