fix: address PostgreSQL registry review
This commit is contained in:
@@ -16,36 +16,6 @@ limitations under the License.
|
||||
|
||||
package registry
|
||||
|
||||
var bootstrapStatements = []string{
|
||||
`CREATE SCHEMA IF NOT EXISTS postgresql_tenant_operator`,
|
||||
`CREATE TABLE IF NOT EXISTS postgresql_tenant_operator.schema_version (
|
||||
singleton boolean PRIMARY KEY DEFAULT true CHECK (singleton),
|
||||
version integer NOT NULL
|
||||
)`,
|
||||
`INSERT INTO postgresql_tenant_operator.schema_version (singleton, version)
|
||||
VALUES (true, 1)
|
||||
ON CONFLICT (singleton) DO NOTHING`,
|
||||
`CREATE TABLE IF NOT EXISTS postgresql_tenant_operator.tenant_ownership (
|
||||
instance_uid text NOT NULL,
|
||||
tenant_uid text NOT NULL,
|
||||
tenant_namespace text NOT NULL,
|
||||
tenant_name text NOT NULL,
|
||||
database_name text NOT NULL,
|
||||
role_name text NOT NULL,
|
||||
credential_path text NOT NULL,
|
||||
managed boolean NOT NULL DEFAULT true,
|
||||
created_at timestamptz NOT NULL DEFAULT clock_timestamp(),
|
||||
updated_at timestamptz NOT NULL DEFAULT clock_timestamp(),
|
||||
retained_at timestamptz,
|
||||
PRIMARY KEY (instance_uid, tenant_uid),
|
||||
UNIQUE (instance_uid, tenant_namespace, tenant_name),
|
||||
UNIQUE (instance_uid, database_name),
|
||||
UNIQUE (instance_uid, role_name),
|
||||
UNIQUE (credential_path),
|
||||
CHECK (managed OR retained_at IS NOT NULL)
|
||||
)`,
|
||||
}
|
||||
|
||||
const claimStatement = `
|
||||
INSERT INTO postgresql_tenant_operator.tenant_ownership (
|
||||
instance_uid,
|
||||
@@ -56,7 +26,19 @@ INSERT INTO postgresql_tenant_operator.tenant_ownership (
|
||||
role_name,
|
||||
credential_path
|
||||
) VALUES ($1, $2, $3, $4, $5, $6, $7)
|
||||
ON CONFLICT DO NOTHING`
|
||||
ON CONFLICT DO NOTHING
|
||||
RETURNING
|
||||
instance_uid,
|
||||
tenant_uid,
|
||||
tenant_namespace,
|
||||
tenant_name,
|
||||
database_name,
|
||||
role_name,
|
||||
credential_path,
|
||||
managed,
|
||||
created_at,
|
||||
updated_at,
|
||||
retained_at`
|
||||
|
||||
const getByTenantUIDStatement = `
|
||||
SELECT
|
||||
|
||||
Reference in New Issue
Block a user