Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix table inheritance
  • Loading branch information
dbhoot committed Apr 25, 2024
commit 2e83572eb15e43fb4b98f09756f5bb5cfc95efcf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- name: GetAllParties :many
SELECT * FROM party;

-- name: GetAllPeople :many
SELECT * FROM person;

-- name: GetAllOrganisations :many
SELECT * FROM organisation;
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
CREATE TYPE party_rank AS ENUM('ensign', 'lieutenant', 'commander');

CREATE TABLE party (
party_id uuid PRIMARY KEY,
name text NOT NULL,
joined_on timestamptz NOT NULL,
ronk party_rank,
unnecessary_column text
);

CREATE TABLE person (
first_name text NOT NULL,
last_name text NOT NULL
) INHERITS (party);

CREATE TABLE organisation (
legal_name text
) INHERITS (party);

CREATE TABLE llc (
incorporation_date timestamp,
legal_name text NOT NULL
) INHERITS (organisation);


ALTER TABLE party ALTER COLUMN ronk SET NOT NULL;
ALTER TABLE party RENAME COLUMN ronk TO rank;
ALTER TABLE party ALTER COLUMN joined_on DROP NOT NULL;
ALTER TABLE party DROP COLUMN unnecessary_column;
ALTER TABLE party ADD COLUMN region text;

ALTER TYPE party_rank ADD VALUE 'captain';
ALTER TYPE party_rank ADD VALUE 'admiral';
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": "1",
"packages": [
{
"path": "go",
"engine": "postgresql",
"sql_package": "pgx/v4",
"name": "querytest",
"schema": "schema.sql",
"queries": "query.sql"
}
]
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading