Skip to content

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

Use the synced CreatedTs and UpdateTs from the schema

天舟d8a13997fc34
diff --git a/api/table.go b/api/table.go
index 4b39d102f4..bed20e4a7c 100644
--- a/api/table.go
+++ b/api/table.go
@@ -39,6 +39,8 @@ type TableCreate struct {
// Standard fields
// Value is assigned from the jwt subject field passed by the client.
CreatorId int
+ CreatedTs int
+ UpdatedTs int
// Related fields
DatabaseId int
diff --git a/server/sql.go b/server/sql.go
index a91047ee59..2c11762e24 100644
--- a/server/sql.go
+++ b/server/sql.go
@@ -164,6 +164,8 @@ func (s *Server) SyncEngineVersionAndSchema(ctx context.Context, instance *api.I
// Table
tableCreate := &api.TableCreate{
CreatorId: api.SYSTEM_BOT_ID,
+ CreatedTs: table.CreatedTs,
+ UpdatedTs: table.UpdatedTs,
DatabaseId: database.ID,
Name: table.Name,
Type: table.Type,
diff --git a/store/table.go b/store/table.go
index 2809e85060..37fa65e9a2 100644
--- a/store/table.go
+++ b/store/table.go
@@ -109,7 +109,9 @@ func (s *TableService) createTable(ctx context.Context, tx *Tx, create *api.Tabl
row, err := tx.QueryContext(ctx, `
INSERT INTO tbl (
creator_id,
+ created_ts,
updater_id,
+ updated_ts,
database_id,
name,
`+"`type`,"+`
@@ -122,11 +124,13 @@ func (s *TableService) createTable(ctx context.Context, tx *Tx, create *api.Tabl
create_options,
comment
)
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
RETURNING id, creator_id, created_ts, updater_id, updated_ts, database_id, name, `+"`type`, engine, collation, row_count, data_size, index_size, data_free, create_options, comment"+`
`,
create.CreatorId,
+ create.CreatedTs,
create.CreatorId,
+ create.UpdatedTs,
create.DatabaseId,
create.Name,
create.Type,