From 82f08b38122efda6fdbcd78549f0ccdb2480f475 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Mon, 16 Dec 2024 10:29:08 +0000 Subject: [PATCH] Tutorial update --- .../tutorials/database-cache/db_repo.yaml | 26 ------------------- .../tutorials/database-cache/porch-db.sql | 23 +++++++++++++++- 2 files changed, 22 insertions(+), 27 deletions(-) delete mode 100644 examples/tutorials/database-cache/db_repo.yaml diff --git a/examples/tutorials/database-cache/db_repo.yaml b/examples/tutorials/database-cache/db_repo.yaml deleted file mode 100644 index 720bd719..00000000 --- a/examples/tutorials/database-cache/db_repo.yaml +++ /dev/null @@ -1,26 +0,0 @@ -apiVersion: v1 -kind: Namespace -metadata: - name: porch-demo - labels: - name: porch-demo - ---- - -apiVersion: config.porch.kpt.dev/v1alpha1 -kind: Repository - -metadata: - name: db-repo - namespace: porch-demo - -spec: - description: db-repo - content: Package - deployment: false - type: db - db: - driver: pgx - dataSource: postgresql://porch:porch@172.18.255.201:55432/porch - packageResourceEncoding: yaml - \ No newline at end of file diff --git a/examples/tutorials/database-cache/porch-db.sql b/examples/tutorials/database-cache/porch-db.sql index 682970cd..f92727c2 100644 --- a/examples/tutorials/database-cache/porch-db.sql +++ b/examples/tutorials/database-cache/porch-db.sql @@ -1,6 +1,7 @@ DROP TABLE IF EXISTS package_revisions; DROP TABLE IF EXISTS packages; DROP TABLE IF EXISTS repositories; +DROP TABLE IF EXISTS resources; DROP TYPE IF EXISTS package_rev_lifecycle; @@ -17,8 +18,10 @@ CREATE TABLE IF NOT EXISTS repositories ( CREATE TABLE IF NOT EXISTS packages ( namespace TEXT NOT NULL, - repo_name TEXT NOT NULL, + repo_name TEXT NOT NULL, package_name TEXT NOT NULL, + meta JSONB NOT NULL, + spec JSONB NOT NULL, updated TIMESTAMPTZ NOT NULL, updatedby TEXT NOT NULL, PRIMARY KEY (namespace, repo_name, package_name), @@ -36,9 +39,27 @@ CREATE TABLE IF NOT EXISTS package_revisions ( package_name TEXT NOT NULL, package_rev TEXT NOT NULL, workspace_name TEXT NOT NULL, + meta JSONB NOT NULL, + spec JSONB NOT NULL, updated TIMESTAMPTZ NOT NULL, updatedby TEXT NOT NULL, lifecycle package_rev_lifecycle NOT NULL, + PRIMARY KEY (namespace, repo_name, package_name, package_rev), + CONSTRAINT fk_package + FOREIGN KEY (namespace, repo_name, package_name) + REFERENCES packages (namespace, repo_name, package_name) + ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS resources ( + namespace TEXT NOT NULL, + repo_name TEXT NOT NULL, + package_name TEXT NOT NULL, + package_rev TEXT NOT NULL, + workspace_name TEXT NOT NULL, + resource_key TEXT NOT NULL, + resource_value JSONB NOT NULL, + lifecycle package_rev_lifecycle NOT NULL, resources BYTEA, PRIMARY KEY (namespace, repo_name, package_name, package_rev), CONSTRAINT fk_package