Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes to table inheritance #3354

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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

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,15 @@
-- name: GetAllParties :many
SELECT * FROM party;

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

-- name: GetAllOrganisations :many
SELECT * FROM organisation;

-- name: GetOrganizationsByRegion :many
SELECT *
FROM organisation
WHERE
region = 'us' AND
rank = 'ensign';
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
Loading