Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions __fixtures__/apply/reuse/packages/catalog/catalog.control
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# catalog extension
comment = 'catalog extension'
default_version = '0.0.1'
module_pathname = '$libdir/catalog'
requires = 'plpgsql'
relocatable = false
superuser = false
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-- Deploy schemas/catalog/functions/product_slug to pg

-- requires: schemas/catalog/schema
-- requires: schemas/catalog/functions/slugify
-- requires: schemas/catalog/tables/products/table

BEGIN;

CREATE FUNCTION catalog.product_slug(pid uuid) RETURNS text AS $$
SELECT catalog.slugify(name) FROM catalog.products WHERE id = pid;
$$ LANGUAGE sql STABLE;

COMMIT;
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-- Deploy schemas/catalog/functions/slugify to pg

-- requires: schemas/catalog/schema

BEGIN;

CREATE FUNCTION catalog.slugify(input text) RETURNS text AS $$
SELECT lower(regexp_replace(input, '\s+', '-', 'g'));
$$ LANGUAGE sql IMMUTABLE;

COMMIT;
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- Deploy schemas/catalog/schema to pg

BEGIN;

CREATE SCHEMA catalog;

COMMIT;
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-- Deploy schemas/catalog/tables/products/table to pg

-- requires: schemas/catalog/schema

BEGIN;

CREATE TABLE catalog.products (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
name text NOT NULL
);

COMMIT;
8 changes: 8 additions & 0 deletions __fixtures__/apply/reuse/packages/catalog/pgpm.plan
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
%syntax-version=1.0.0
%project=catalog
%uri=catalog

schemas/catalog/schema 2024-01-01T00:00:00Z Dev <dev@example.com> # add catalog schema
schemas/catalog/functions/slugify [schemas/catalog/schema] 2024-01-01T00:00:01Z Dev <dev@example.com> # add slugify helper
schemas/catalog/tables/products/table [schemas/catalog/schema] 2024-01-01T00:00:02Z Dev <dev@example.com> # add products table
schemas/catalog/functions/product_slug [schemas/catalog/schema schemas/catalog/functions/slugify schemas/catalog/tables/products/table] 2024-01-01T00:00:03Z Dev <dev@example.com> # add product_slug
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- Revert schemas/catalog/functions/product_slug from pg

BEGIN;

DROP FUNCTION catalog.product_slug(uuid);

COMMIT;
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- Revert schemas/catalog/functions/slugify from pg

BEGIN;

DROP FUNCTION catalog.slugify(text);

COMMIT;
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- Revert schemas/catalog/schema from pg

BEGIN;

DROP SCHEMA catalog;

COMMIT;
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- Revert schemas/catalog/tables/products/table from pg

BEGIN;

DROP TABLE catalog.products;

COMMIT;
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- Verify schemas/catalog/functions/product_slug on pg

BEGIN;

SELECT catalog.product_slug('00000000-0000-0000-0000-000000000000'::uuid);

ROLLBACK;
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- Verify schemas/catalog/functions/slugify on pg

BEGIN;

SELECT catalog.slugify('Hello World');

ROLLBACK;
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- Verify schemas/catalog/schema on pg

BEGIN;

SELECT pg_catalog.has_schema_privilege('catalog', 'usage');

ROLLBACK;
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- Verify schemas/catalog/tables/products/table on pg

BEGIN;

SELECT id, name FROM catalog.products WHERE false;

ROLLBACK;
14 changes: 14 additions & 0 deletions __fixtures__/apply/reuse/packages/tenant-a/pgpm.apply.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"source": "catalog",
"schemas": {
"catalog": "tenant_a"
},
"reuse": {
"sharedSchema": {
"catalog": "catalog_shared"
},
"perTenant": [
{ "fromSchema": "catalog", "kind": "table", "name": "products" }
]
}
}
14 changes: 14 additions & 0 deletions __fixtures__/apply/reuse/packages/tenant-b/pgpm.apply.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"source": "catalog",
"schemas": {
"catalog": "tenant_b"
},
"reuse": {
"sharedSchema": {
"catalog": "catalog_shared"
},
"perTenant": [
{ "fromSchema": "catalog", "kind": "table", "name": "products" }
]
}
}
5 changes: 5 additions & 0 deletions __fixtures__/apply/reuse/pgpm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"packages": [
"packages/*"
]
}
Loading
Loading