mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 11:03:34 +00:00
chore: remove unnecessary fields from containers table in machine.db
This commit is contained in:
@@ -36,16 +36,11 @@ func NewDB(path string) (*sqlx.DB, error) {
|
|||||||
schema := `
|
schema := `
|
||||||
CREATE TABLE IF NOT EXISTS containers (
|
CREATE TABLE IF NOT EXISTS containers (
|
||||||
id TEXT NOT NULL PRIMARY KEY,
|
id TEXT NOT NULL PRIMARY KEY,
|
||||||
service_id TEXT NOT NULL,
|
|
||||||
service_name TEXT AS (json_extract(service_spec, '$.Name')),
|
|
||||||
service_spec TEXT NOT NULL CHECK (json_valid(service_spec)),
|
service_spec TEXT NOT NULL CHECK (json_valid(service_spec)),
|
||||||
-- 'subsecond' modifier is used to store timestamps with millisecond precision.
|
-- 'subsecond' modifier is used to store timestamps with millisecond precision.
|
||||||
created_at TIMESTAMP NOT NULL DEFAULT (datetime('subsecond')),
|
created_at TIMESTAMP NOT NULL DEFAULT (datetime('subsecond')),
|
||||||
updated_at TIMESTAMP NOT NULL DEFAULT (datetime('subsecond'))
|
updated_at TIMESTAMP NOT NULL DEFAULT (datetime('subsecond'))
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_containers_service_id ON containers (service_id);
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_containers_service_name ON containers (service_name);
|
|
||||||
`
|
`
|
||||||
|
|
||||||
if _, err = db.Exec(schema); err != nil {
|
if _, err = db.Exec(schema); err != nil {
|
||||||
|
|||||||
@@ -527,9 +527,8 @@ func (s *Server) CreateServiceContainer(
|
|||||||
return nil, status.Errorf(codes.Internal, "marshal service spec: %v", err)
|
return nil, status.Errorf(codes.Internal, "marshal service spec: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err = s.db.ExecContext(ctx,
|
if _, err = s.db.ExecContext(ctx, `INSERT INTO containers (id, service_spec) VALUES ($1, $2)`,
|
||||||
`INSERT INTO containers (id, service_id, service_spec) VALUES ($1, $2, $3)`,
|
resp.ID, string(specBytes)); err != nil {
|
||||||
resp.ID, req.ServiceId, string(specBytes)); err != nil {
|
|
||||||
removeContainer()
|
removeContainer()
|
||||||
return nil, status.Errorf(codes.Internal, "store container in database: %v", err)
|
return nil, status.Errorf(codes.Internal, "store container in database: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user