configstore: add parenttype to related tables
Add the parenttype column to project, projectgroup, secret, variable tables.
This commit is contained in:
parent
8b7a5602e0
commit
276c045c3b
|
@ -25,10 +25,10 @@ var Stmts = []string{
|
||||||
// changegrouprevision stores the current revision of the changegroup for optimistic locking
|
// changegrouprevision stores the current revision of the changegroup for optimistic locking
|
||||||
"create table changegrouprevision (id varchar, revision varchar, PRIMARY KEY (id, revision))",
|
"create table changegrouprevision (id varchar, revision varchar, PRIMARY KEY (id, revision))",
|
||||||
|
|
||||||
"create table projectgroup (id uuid, name varchar, parentid varchar, data bytea, PRIMARY KEY (id))",
|
"create table projectgroup (id uuid, name varchar, parentid varchar, parenttype varchar, data bytea, PRIMARY KEY (id))",
|
||||||
"create index projectgroup_name on projectgroup(name)",
|
"create index projectgroup_name on projectgroup(name)",
|
||||||
|
|
||||||
"create table project (id uuid, name varchar, parentid varchar, data bytea, PRIMARY KEY (id))",
|
"create table project (id uuid, name varchar, parentid varchar, parenttype varchar, data bytea, PRIMARY KEY (id))",
|
||||||
"create index project_name on project(name)",
|
"create index project_name on project(name)",
|
||||||
|
|
||||||
"create table user (id uuid, name varchar, data bytea, PRIMARY KEY (id))",
|
"create table user (id uuid, name varchar, data bytea, PRIMARY KEY (id))",
|
||||||
|
@ -48,9 +48,9 @@ var Stmts = []string{
|
||||||
|
|
||||||
"create table linkedaccount_project (id uuid, projectid uuid, PRIMARY KEY (id), FOREIGN KEY(projectid) REFERENCES user(id))",
|
"create table linkedaccount_project (id uuid, projectid uuid, PRIMARY KEY (id), FOREIGN KEY(projectid) REFERENCES user(id))",
|
||||||
|
|
||||||
"create table secret (id uuid, name varchar, parentid varchar, data bytea, PRIMARY KEY (id))",
|
"create table secret (id uuid, name varchar, parentid varchar, parenttype varchar, data bytea, PRIMARY KEY (id))",
|
||||||
"create index secret_name on secret(name)",
|
"create index secret_name on secret(name)",
|
||||||
|
|
||||||
"create table variable (id uuid, name varchar, parentid varchar, data bytea, PRIMARY KEY (id))",
|
"create table variable (id uuid, name varchar, parentid varchar, parenttype varchar, data bytea, PRIMARY KEY (id))",
|
||||||
"create index variable_name on variable(name)",
|
"create index variable_name on variable(name)",
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ import (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
projectSelect = sb.Select("id", "data").From("project")
|
projectSelect = sb.Select("id", "data").From("project")
|
||||||
projectInsert = sb.Insert("project").Columns("id", "name", "parentid", "data")
|
projectInsert = sb.Insert("project").Columns("id", "name", "parentid", "parenttype", "data")
|
||||||
)
|
)
|
||||||
|
|
||||||
func (r *ReadDB) insertProject(tx *db.Tx, data []byte) error {
|
func (r *ReadDB) insertProject(tx *db.Tx, data []byte) error {
|
||||||
|
@ -43,7 +43,7 @@ func (r *ReadDB) insertProject(tx *db.Tx, data []byte) error {
|
||||||
if err := r.deleteProject(tx, project.ID); err != nil {
|
if err := r.deleteProject(tx, project.ID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
q, args, err := projectInsert.Values(project.ID, project.Name, project.Parent.ID, data).ToSql()
|
q, args, err := projectInsert.Values(project.ID, project.Name, project.Parent.ID, project.Parent.Type, data).ToSql()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Errorf("failed to build query: %w", err)
|
return errors.Errorf("failed to build query: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ import (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
projectgroupSelect = sb.Select("id", "data").From("projectgroup")
|
projectgroupSelect = sb.Select("id", "data").From("projectgroup")
|
||||||
projectgroupInsert = sb.Insert("projectgroup").Columns("id", "name", "parentid", "data")
|
projectgroupInsert = sb.Insert("projectgroup").Columns("id", "name", "parentid", "parenttype", "data")
|
||||||
)
|
)
|
||||||
|
|
||||||
func (r *ReadDB) insertProjectGroup(tx *db.Tx, data []byte) error {
|
func (r *ReadDB) insertProjectGroup(tx *db.Tx, data []byte) error {
|
||||||
|
@ -44,7 +44,7 @@ func (r *ReadDB) insertProjectGroup(tx *db.Tx, data []byte) error {
|
||||||
if err := r.deleteProjectGroup(tx, group.ID); err != nil {
|
if err := r.deleteProjectGroup(tx, group.ID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
q, args, err := projectgroupInsert.Values(group.ID, group.Name, group.Parent.ID, data).ToSql()
|
q, args, err := projectgroupInsert.Values(group.ID, group.Name, group.Parent.ID, group.Parent.Type, data).ToSql()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Errorf("failed to build query: %w", err)
|
return errors.Errorf("failed to build query: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ import (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
secretSelect = sb.Select("id", "data").From("secret")
|
secretSelect = sb.Select("id", "data").From("secret")
|
||||||
secretInsert = sb.Insert("secret").Columns("id", "name", "parentid", "data")
|
secretInsert = sb.Insert("secret").Columns("id", "name", "parentid", "parenttype", "data")
|
||||||
)
|
)
|
||||||
|
|
||||||
func (r *ReadDB) insertSecret(tx *db.Tx, data []byte) error {
|
func (r *ReadDB) insertSecret(tx *db.Tx, data []byte) error {
|
||||||
|
@ -40,7 +40,7 @@ func (r *ReadDB) insertSecret(tx *db.Tx, data []byte) error {
|
||||||
if err := r.deleteSecret(tx, secret.ID); err != nil {
|
if err := r.deleteSecret(tx, secret.ID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
q, args, err := secretInsert.Values(secret.ID, secret.Name, secret.Parent.ID, data).ToSql()
|
q, args, err := secretInsert.Values(secret.ID, secret.Name, secret.Parent.ID, secret.Parent.Type, data).ToSql()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Errorf("failed to build query: %w", err)
|
return errors.Errorf("failed to build query: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ import (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
variableSelect = sb.Select("id", "data").From("variable")
|
variableSelect = sb.Select("id", "data").From("variable")
|
||||||
variableInsert = sb.Insert("variable").Columns("id", "name", "parentid", "data")
|
variableInsert = sb.Insert("variable").Columns("id", "name", "parentid", "parenttype", "data")
|
||||||
)
|
)
|
||||||
|
|
||||||
func (r *ReadDB) insertVariable(tx *db.Tx, data []byte) error {
|
func (r *ReadDB) insertVariable(tx *db.Tx, data []byte) error {
|
||||||
|
@ -40,7 +40,7 @@ func (r *ReadDB) insertVariable(tx *db.Tx, data []byte) error {
|
||||||
if err := r.deleteVariable(tx, variable.ID); err != nil {
|
if err := r.deleteVariable(tx, variable.ID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
q, args, err := variableInsert.Values(variable.ID, variable.Name, variable.Parent.ID, data).ToSql()
|
q, args, err := variableInsert.Values(variable.ID, variable.Name, variable.Parent.ID, variable.Parent.Type, data).ToSql()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Errorf("failed to build query: %w", err)
|
return errors.Errorf("failed to build query: %w", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue