diff --git a/v2-transition/services/column-builder/api-views/01-views.sql b/v2-transition/services/column-builder/api-views/01-views.sql index 001d7f103..12e140648 100644 --- a/v2-transition/services/column-builder/api-views/01-views.sql +++ b/v2-transition/services/column-builder/api-views/01-views.sql @@ -1,77 +1,106 @@ -/* +/* Macrostrat's postgrest api is expressed through the macrostrat_api schema. -Any functions, views or tables in the macrostrat_api schema can be accessed +Any functions, views or tables in the macrostrat_api schema can be accessed through the postgrest api. -Below are a multitude of views that are made from the macrostrat data schema. +Below are a multitude of views that are made from the macrostrat data schema. Many are direct copies, however some are more customized data views for the frontend. */ CREATE SCHEMA IF NOT EXISTS macrostrat_api; +DROP ROLE IF EXISTS api_user; +CREATE ROLE api_user NOINHERIT; +GRANT USAGE ON SCHEMA macrostrat_api TO api_user; +GRANT USAGE ON SCHEMA macrostrat TO api_user; +GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA macrostrat_api TO api_user; +GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA macrostrat TO api_user; +GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA macrostrat TO api_user; + CREATE OR REPLACE VIEW macrostrat_api.projects AS SELECT * FROM macrostrat.projects; +ALTER VIEW macrostrat_api.projects OWNER TO api_user; + CREATE OR REPLACE VIEW macrostrat_api.cols AS SELECT * FROM macrostrat.cols; +ALTER VIEW macrostrat_api.cols OWNER TO api_user; + CREATE OR REPLACE VIEW macrostrat_api.col_groups AS SELECT * FROM macrostrat.col_groups; +ALTER VIEW macrostrat_api.col_groups OWNER TO api_user; CREATE OR REPLACE VIEW macrostrat_api.environs AS SELECT * FROM macrostrat.environs; +ALTER VIEW macrostrat_api.environs OWNER TO api_user; CREATE OR REPLACE VIEW macrostrat_api.liths AS SELECT * FROM macrostrat.liths; +ALTER VIEW macrostrat_api.liths OWNER TO api_user; CREATE OR REPLACE VIEW macrostrat_api.intervals AS SELECT * FROM macrostrat.intervals; +ALTER VIEW macrostrat_api.intervals OWNER TO api_user; CREATE OR REPLACE VIEW macrostrat_api.timescales AS SELECT * FROM macrostrat.timescales; +ALTER VIEW macrostrat_api.timescales OWNER TO api_user; CREATE OR REPLACE VIEW macrostrat_api.strat_tree AS SELECT * FROM macrostrat.strat_tree; +ALTER VIEW macrostrat_api.strat_tree OWNER TO api_user; CREATE OR REPLACE VIEW macrostrat_api.refs AS SELECT * FROM macrostrat.refs; +ALTER VIEW macrostrat_api.refs OWNER TO api_user; CREATE OR REPLACE VIEW macrostrat_api.units AS SELECT * FROM macrostrat.units; +ALTER VIEW macrostrat_api.units OWNER TO api_user; CREATE OR REPLACE VIEW macrostrat_api.col_refs AS SELECT * FROM macrostrat.col_refs; +ALTER VIEW macrostrat_api.col_refs OWNER TO api_user; CREATE OR REPLACE VIEW macrostrat_api.unit_environs AS SELECT * FROM macrostrat.unit_environs; +ALTER VIEW macrostrat_api.environs OWNER TO api_user; CREATE OR REPLACE VIEW macrostrat_api.unit_liths AS SELECT * FROM macrostrat.unit_liths; +ALTER VIEW macrostrat_api.unit_liths OWNER TO api_user; CREATE OR REPLACE VIEW macrostrat_api.sections AS SELECT * FROM macrostrat.sections; +ALTER VIEW macrostrat_api.sections OWNER TO api_user; + CREATE OR REPLACE VIEW macrostrat_api.strat_names AS SELECT * FROM macrostrat.strat_names; +ALTER VIEW macrostrat_api.strat_names OWNER TO api_user; + CREATE OR REPLACE VIEW macrostrat_api.unit_strat_names AS SELECT * FROM macrostrat.unit_strat_names; +ALTER VIEW macrostrat_api.unit_strat_names OWNER TO api_user; CREATE OR REPLACE VIEW macrostrat_api.strat_names_ref AS -SELECT -s.id, -s.strat_name, -s.rank, -row_to_json(r.*) ref, -row_to_json(sm.*) concept +SELECT +s.id, +s.strat_name, +s.rank, +row_to_json(r.*) ref, +row_to_json(sm.*) concept FROM macrostrat.strat_names s LEFT JOIN macrostrat.refs r ON r.id = s.ref_id LEFT JOIN macrostrat.strat_names_meta sm -ON sm.concept_id = s.concept_id; +ON sm.concept_id = s.concept_id; +ALTER VIEW macrostrat_api.strat_names_ref OWNER TO api_user; CREATE OR REPLACE VIEW macrostrat_api.col_group_with_cols AS -SELECT +SELECT cg.id, cg.col_group, cg.col_group_long, @@ -79,34 +108,37 @@ SELECT COALESCE(jsonb_agg( jsonb_build_object( 'col_id', c.id, - 'status_code', c.status_code, - 'col_number', c.col, - 'col_name', c.col_name)) + 'status_code', c.status_code, + 'col_number', c.col, + 'col_name', c.col_name)) FILTER (WHERE c.id IS NOT NULL), '[]') AS cols FROM macrostrat.col_groups cg LEFT JOIN macrostrat.cols c ON c.col_group_id = cg.id GROUP BY cg.id, c.project_id; +ALTER VIEW macrostrat_api.col_group_with_cols OWNER TO api_user; CREATE OR REPLACE VIEW macrostrat_api.environ_unit AS SELECT e.*, ue.unit_id, ue.ref_id from macrostrat.environs e JOIN macrostrat.unit_environs ue ON e.id = ue.environ_id; +ALTER VIEW macrostrat_api.environ_unit OWNER TO api_user; CREATE OR REPLACE VIEW macrostrat_api.econ_unit AS SELECT e.*, ue.unit_id, ue.ref_id from macrostrat.econs e JOIN macrostrat.unit_econs ue ON e.id = ue.econ_id; +ALTER VIEW macrostrat_api.econ_unit OWNER TO api_user; CREATE OR REPLACE VIEW macrostrat_api.lith_attr_unit AS -SELECT -la.id as lith_attr_id, -la.lith_att, +SELECT +la.id as lith_attr_id, +la.lith_att, la.att_type, -la.lith_att_fill, -l.*, -ul.unit_id +la.lith_att_fill, +l.*, +ul.unit_id from macrostrat.lith_atts la JOIN macrostrat.unit_lith_atts ula ON ula.lith_att_id = la.id @@ -114,28 +146,30 @@ JOIN macrostrat.unit_liths ul ON ul.id = ula.unit_lith_id JOIN macrostrat.liths l ON ul.lith_id = l.id; +ALTER VIEW macrostrat_api.lith_attr_unit OWNER TO api_user; CREATE OR REPLACE VIEW macrostrat_api.lith_unit AS -SELECT +SELECT l.id, -l.lith, -l.lith_group, +l.lith, +l.lith_group, l.lith_type, -l.lith_class, +l.lith_class, l.lith_color, ul.dom, ul.prop, ul.mod_prop, -ul.comp_prop, +ul.comp_prop, ul.ref_id, -ul.unit_id +ul.unit_id from macrostrat.liths l JOIN macrostrat.unit_liths ul ON ul.lith_id = l.id; +ALTER VIEW macrostrat_api.lith_unit OWNER TO api_user; /*LO is top and FO is bottom*/ CREATE OR REPLACE VIEW macrostrat_api.unit_strat_name_expanded AS -SELECT +SELECT usn.id, usn.unit_id, usn.strat_name_id, @@ -163,8 +197,10 @@ LEFT JOIN macrostrat.strat_names sn LEFT JOIN macrostrat.intervals fo ON u.fo = fo.id LEFT JOIN macrostrat.intervals lo ON u.lo = lo.id; +ALTER VIEW macrostrat_api.unit_strat_name_expanded OWNER TO api_user; + CREATE OR REPLACE VIEW macrostrat_api.col_sections AS -SELECT c.id col_id, c.col_name, u.section_id, u.position_top, u.position_bottom, fo.interval_name bottom, +SELECT c.id col_id, c.col_name, u.section_id, u.position_top, u.position_bottom, fo.interval_name bottom, lo.interval_name top FROM macrostrat.cols c LEFT JOIN macrostrat.units u ON u.col_id = c.id @@ -172,30 +208,36 @@ LEFT JOIN macrostrat.intervals fo ON u.fo = fo.id LEFT JOIN macrostrat.intervals lo ON u.lo = lo.id; +ALTER VIEW macrostrat_api.col_sections OWNER TO api_user; CREATE OR REPLACE VIEW macrostrat_api.col_ref_expanded AS -SELECT -c.id col_id, -c.col_name, +SELECT +c.id col_id, +c.col_name, c.col col_number, c.notes, c.lat, c.lng, -json_build_object( -'id', r.id, -'pub_year', r.pub_year, -'author', r.author, -'ref', r.ref, -'doi',r.doi, +json_build_object( +'id', r.id, +'pub_year', r.pub_year, +'author', r.author, +'ref', r.ref, +'doi',r.doi, 'url', r.url) ref FROM macrostrat.cols c LEFT JOIN macrostrat.col_refs cr ON c.id = cr.col_id LEFT JOIN macrostrat.refs r ON cr.ref_id = r.id; +ALTER VIEW macrostrat_api.col_ref_expanded OWNER TO api_user; + CREATE OR REPLACE VIEW macrostrat_api.strat_names_meta AS SELECT * FROM macrostrat.strat_names_meta; +ALTER VIEW macrostrat_api.strat_names_meta OWNER TO api_user; + CREATE OR REPLACE VIEW macrostrat_api.unit_boundaries AS -SELECT * FROM macrostrat.unit_boundaries; \ No newline at end of file +SELECT * FROM macrostrat.unit_boundaries; +ALTER VIEW macrostrat_api.unit_boundaries OWNER TO api_user; diff --git a/v2-transition/services/column-builder/api-views/02-auth.sql b/v2-transition/services/column-builder/api-views/02-auth.sql new file mode 100644 index 000000000..077bc7228 --- /dev/null +++ b/v2-transition/services/column-builder/api-views/02-auth.sql @@ -0,0 +1,374 @@ +/* Authentication in db using postgrest https://postgrest.org/en/stable/auth.html +Postgrest uses JWT to authenticate incoming requests, but the db can authorize db queries based +on users. + + +authenticator is passed via db-uri +anon: db-anon-role (PGRST_DB_ANON_ROLE) +jwt-secret (PGRST_JWT_SECRET) + + +HOW LOGIN WORKS --> { + take username and password, + get the role and any other info we want tokenized, + if login successful --> return json token +} + +Generate JWT in SQL ---> pgjwt +https://github.com/michelp/pgjwt +https://app.bountysource.com/issues/89971002-example-code-to-show-how-to-install-pgjwt-extension-in-docker + + +How to access info on JWT for the current user --> to be user in policy creation:: +current_setting('request.jwt.claims', true)::json->>'username'; + + +*/ + + +/* AUTH schema and functions */ +DROP SCHEMA IF EXISTS auth CASCADE; +CREATE SCHEMA auth; + + +/* necesary extenstions */ +CREATE EXTENSION IF NOT EXISTS pgcrypto; +CREATE EXTENSION IF NOT EXISTS pgjwt; + +/* an auth user table */ +CREATE TABLE IF NOT EXISTS +auth.users( + id serial primary key, + firstname text not null, + lastname text not null, + username text not null, + pass text not null check (length(pass) < 512), + role name not null check (length(role) < 512) +); + +-- data privilege roles +CREATE TABLE IF NOT EXISTS auth.data_roles( + id SERIAL PRIMARY KEY, + role text, + description text +); +-- default data roles +INSERT INTO auth.data_roles(role, description) VALUES + ('reader', 'user can only perform SELECT on data'), + ('writer', 'user can SELECT, INSERT, and UPDATE'), + ('deleter', 'user can SELECT, INSERT, and UPDATE'), + ('manager', 'user encompasses privileges of deleter and can manage user permissions on data'); + +/* Example of a basic data id to role */ +CREATE TABLE IF NOT EXISTS +auth.user_projects( + id serial primary key, + user_ int REFERENCES auth.users(id), + project int REFERENCES macrostrat.projects(id), + role_id integer REFERENCES auth.data_roles(id) +); + +/* make sure the role being added to user table actually exists!! */ +CREATE OR REPLACE FUNCTION +auth.check_role_exists() RETURNS trigger AS $$ +BEGIN + IF NOT EXISTS (SELECT 1 FROM pg_roles AS r WHERE r.rolname = new.role) THEN + raise foreign_key_violation USING message = + 'unknown database role: ' || new.role; + RETURN NULL; + END IF; + RETURN new; +END +$$ LANGUAGE plpgsql; + +DROP trigger IF EXISTS ensure_user_role_exists ON auth.users; +CREATE trigger ensure_user_role_exists + BEFORE INSERT OR UPDATE ON auth.users + FOR EACH ROW + EXECUTE PROCEDURE auth.check_role_exists(); + +/* Encrypt the password so it's not just sitting in the table */ +CREATE OR REPLACE FUNCTION +auth.encrypt_pass() RETURNS trigger AS $$ +BEGIN + IF tg_op = 'INSERT' OR new.pass <> old.pass THEN + new.pass := public.crypt(new.pass, public.gen_salt('md5')); + END IF; + RETURN new; +END +$$ LANGUAGE plpgsql; + +DROP trigger IF EXISTS encrypt_pass ON auth.users; +CREATE trigger encrypt_pass + BEFORE INSERT OR UPDATE ON auth.users + FOR EACH ROW + EXECUTE PROCEDURE auth.encrypt_pass(); + + +/* Access the stored role on a user -- used in login! +*/ +CREATE OR REPLACE FUNCTION +auth.user_role(username TEXT, pass TEXT) RETURNS name + LANGUAGE plpgsql + AS $$ +BEGIN + RETURN ( + SELECT role FROM auth.users + WHERE users.username = user_role.username + AND users.pass = public.crypt(user_role.pass, users.pass) + ); +END; +$$; + +CREATE TYPE auth.jwt_token AS ( + token text +); + +/* +Login function! + */ +CREATE OR REPLACE FUNCTION +macrostrat_api.login(username text, pass text) RETURNS auth.jwt_token AS $$ +DECLARE + _role name; + result auth.jwt_token; +BEGIN + SELECT auth.user_role(username, pass) INTO _role; + IF _role IS NULL THEN + raise invalid_password using message = 'invalid user or password'; + END IF; + -- sign function comes from pgjwt extension. + SELECT sign( + row_to_json(r), 'reallyreallyreallyreallyverysafesafesafesafe' + ) AS token + FROM ( + SELECT 'api_user' as role, login.username as username, + extract(epoch FROM now())::integer + 86400 AS exp --expires in 1 day + ) r + INTO result; + RETURN result; +END +$$ language plpgsql SECURITY DEFINER; + +CREATE OR REPLACE FUNCTION +macrostrat_api.create_user(firstname text, lastname text, pass text, username text) +RETURNS BOOLEAN AS $$ +DECLARE + _role name; +BEGIN + INSERT INTO auth.users(username, firstname, lastname, pass, role) + VALUES (username, firstname, lastname, pass, 'api_user'); + SELECT auth.user_role(username, pass) INTO _role; + + IF _role IS NULL THEN + RETURN FALSE; + END IF; + + RETURN TRUE; +END +$$ language plpgsql SECURITY DEFINER; + +/*####################### BASE DB ROLES ##########################*/ + +-- these are the basic auth roles used by postgrest. +DROP ROLE IF EXISTS anon; +CREATE ROLE anon NOINHERIT; +DROP ROLE IF EXISTS authenticator; +CREATE ROLE authenticator NOINHERIT LOGIN; +GRANT anon TO authenticator; + +GRANT USAGE ON SCHEMA macrostrat_api TO anon; +GRANT USAGE ON SCHEMA macrostrat_api TO authenticator; + +GRANT EXECUTE ON FUNCTION macrostrat_api.login(text,text) TO anon; +GRANT EXECUTE ON FUNCTION macrostrat_api.create_user(text,text,text, text) TO anon; +GRANT EXECUTE ON FUNCTION macrostrat_api.login(text,text) TO authenticator; +GRANT EXECUTE ON FUNCTION macrostrat_api.create_user(text,text,text, text) TO authenticator; + +-- a general api_user, data privileges depend on RLS +GRANT USAGE ON SCHEMA auth TO api_user; +GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA auth TO api_user; +GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA auth TO api_user; + +GRANT api_user to authenticator; + +/* ################### Row level policies ################### */ + + +/* function to get username off of jwt claims*/ +CREATE OR REPLACE FUNCTION +macrostrat_api.get_username() returns text AS $$ +DECLARE + username_ text; +BEGIN + SELECT current_setting('request.jwt.claims', true)::json->>'username' INTO username_; +RETURN username_; +END +$$language plpgsql SECURITY DEFINER; + +CREATE OR REPLACE FUNCTION +auth.user_project_insert() RETURNS trigger AS $$ +DECLARE + username_ text; + id_ int; + manager_id int; +BEGIN + IF tg_op = 'INSERT' THEN + select macrostrat_api.get_username() into username_; + select id from auth.users where users.username = username_ INTO id_; + SELECT id FROM auth.data_roles WHERE role = 'manager' INTO manager_id; + INSERT INTO auth.user_projects(user_, project, role_id) + VALUES(id_, new.id, manager_id); + END IF; + RETURN new; +END +$$ LANGUAGE plpgsql SECURITY DEFINER; + +DROP trigger IF EXISTS user_projects ON macrostrat.projects; +CREATE trigger user_projects + AFTER INSERT ON macrostrat.projects + FOR EACH ROW + EXECUTE PROCEDURE auth.user_project_insert(); + +CREATE OR REPLACE FUNCTION +macrostrat_api.current_user_projects() +RETURNS TABLE (project integer, role text) AS $$ +DECLARE + username_ text; +BEGIN + SELECT macrostrat_api.get_username() INTO username_; + RETURN QUERY + SELECT up.project, adr.role FROM auth.user_projects up + JOIN auth.users u + on u.id = up.user_ + JOIN auth.data_roles adr + ON adr.id = up.role_id + WHERE u.username = username_; +END +$$ language plpgsql SECURITY DEFINER; + +/* users table */ +ALTER TABLE auth.users ENABLE ROW LEVEL SECURITY; + +CREATE POLICY secure_users ON auth.users +USING (username = macrostrat_api.get_username()) +WITH CHECK (username = macrostrat_api.get_username()); + +/* user_projects mapping tables */ +ALTER TABLE auth.user_projects ENABLE ROW LEVEL SECURITY; + +-- Only project managers can view and manipulate project privileges +CREATE POLICY manager_projects ON auth.user_projects +USING (project IN ( + SELECT project from macrostrat_api.current_user_projects() + WHERE role = 'manager')) +WITH CHECK (project IN ( + SELECT project from macrostrat_api.current_user_projects() + WHERE role = 'manager')); + + +/* projects */ +ALTER TABLE macrostrat.projects ENABLE ROW LEVEL SECURITY; + +CREATE POLICY projects_ ON macrostrat.projects FOR SELECT +USING (id IN ( + SELECT project FROM macrostrat_api.current_user_projects() + WHERE role IN ('reader','writer','deleter','manager'))); + +-- anyone can insert a new project +CREATE POLICY projects_insert ON macrostrat.projects FOR INSERT +WITH CHECK(TRUE); + +-- Updates only allowable for writer, deleter or manager +CREATE POLICY projects_update ON macrostrat.projects FOR UPDATE +USING(id IN ( + SELECT project from macrostrat_api.current_user_projects() + WHERE role IN ('writer','deleter', 'manager') +)) +WITH CHECK (id IN ( + SELECT project from macrostrat_api.current_user_projects() + WHERE role IN ('writer','deleter', 'manager') +)); + +/* col-groups */ +ALTER TABLE macrostrat.col_groups ENABLE ROW LEVEL SECURITY; + +CREATE POLICY col_groups_select ON macrostrat.col_groups FOR SELECT +USING (project_id IN ( + SELECT project FROM macrostrat_api.current_user_projects() + WHERE role IN ('reader','writer','deleter','manager'))); + + +CREATE POLICY col_group_update ON macrostrat.col_groups FOR UPDATE +USING(project_id IN ( + SELECT project FROM macrostrat_api.current_user_projects() + WHERE role IN ('writer', 'deleter', 'manager'))); + +CREATE POLICY col_group_insert ON macrostrat.col_groups FOR INSERT +WITH CHECK(project_id IN ( + SELECT project FROM macrostrat_api.current_user_projects() + WHERE role IN ('writer', 'deleter', 'manager'))); + +/* cols */ +ALTER TABLE macrostrat.cols ENABLE ROW LEVEL SECURITY; + +CREATE POLICY cols_select ON macrostrat.cols FOR SELECT +USING (project_id IN (SELECT project FROM macrostrat_api.current_user_projects())); + +CREATE POLICY cols_update ON macrostrat.cols for UPDATE +USING(project_id IN ( + SELECT project FROM macrostrat_api.current_user_projects() + WHERE role IN ('writer', 'deleter', 'manager') +)); + +CREATE POLICY cols_insert ON macrostrat.cols for INSERT +WITH CHECK(project_id IN ( + SELECT project FROM macrostrat_api.current_user_projects() + WHERE role IN ('writer', 'deleter', 'manager') +)); + +/* units */ +ALTER TABLE macrostrat.units ENABLE ROW LEVEL SECURITY; + +CREATE POLICY units_select ON macrostrat.units FOR SELECT +USING (col_id IN ( + SELECT c.id from macrostrat.cols c + WHERE c.project_id IN( + SELECT project FROM macrostrat_api.current_user_projects()))); + +CREATE POLICY units_update ON macrostrat.units FOR UPDATE +USING (col_id IN ( + SELECT c.id from macrostrat.cols c + WHERE c.project_id IN( + SELECT project FROM macrostrat_api.current_user_projects() + WHERE role IN ('writer', 'deleter', 'manager')))); + +CREATE POLICY units_insert ON macrostrat.units FOR INSERT +WITH CHECK (col_id IN ( + SELECT c.id from macrostrat.cols c + WHERE c.project_id IN( + SELECT project FROM macrostrat_api.current_user_projects() + WHERE role IN ('writer', 'deleter', 'manager')))); + +CREATE OR REPLACE VIEW macrostrat_api.users AS +SELECT * FROM auth.users; +ALTER VIEW macrostrat_api.users OWNER TO api_user; + +CREATE OR REPLACE VIEW macrostrat_api.user_projects AS +SELECT * FROM auth.user_projects; +ALTER VIEW macrostrat_api.user_projects OWNER TO api_user; + +CREATE OR REPLACE VIEW macrostrat_api.data_roles AS +SELECT * FROM auth.data_roles; +ALTER VIEW macrostrat_api.data_roles OWNER TO api_user; + +ALTER TABLE auth.data_roles ENABLE ROW LEVEL SECURITY; + +CREATE POLICY data_roles_select ON auth.data_roles FOR SELECT +USING(TRUE); + +CREATE POLICY data_roles_update ON auth.data_roles FOR UPDATE +USING (role NOT IN('reader','writer','deleter', 'manager')); + +CREATE POLICY data_roles_insert ON auth.data_roles FOR INSERT +WITH CHECK(role NOT IN ('reader', 'writer', 'deleter', 'manager')); \ No newline at end of file diff --git a/v2-transition/services/column-builder/backend/requirements.txt b/v2-transition/services/column-builder/backend/requirements.txt new file mode 100644 index 000000000..e59dff5de --- /dev/null +++ b/v2-transition/services/column-builder/backend/requirements.txt @@ -0,0 +1,12 @@ + +python=3.10 +psycopg +psycopg_binary +pydantic +fastapi +geojson_pydantic +requests +uvicorn +pytest +pyjwt +requests_jwt \ No newline at end of file diff --git a/v2-transition/services/column-builder/backend/tests/conftest.py b/v2-transition/services/column-builder/backend/tests/conftest.py new file mode 100644 index 000000000..296a2ff49 --- /dev/null +++ b/v2-transition/services/column-builder/backend/tests/conftest.py @@ -0,0 +1,50 @@ +import pytest +from urvogel.app import app +from urvogel.app.depends import get_db +from urvogel.database import Database +from urvogel.database.fixtures import get_sql +from fastapi.testclient import TestClient + +# for testing the api +## https://fastapi.tiangolo.com/tutorial/testing/ + +testing_db = "postgresql://postgres@localhost:5434/col_test" + +def override_get_db(): + db = Database(testing_db) + return db + +# override db dependency connection +## https://fastapi.tiangolo.com/advanced/testing-database/ +app.dependency_overrides[get_db] = override_get_db + +@pytest.fixture(scope="session") +def db_(): + db = Database(testing_db) + return db + +@pytest.fixture(scope="session") +def setup(db_): + schema = get_sql("schema_dump.sql") + data_inserts = get_sql("test_inserts.sql") + with db_.conn.cursor() as cur: + cur.execute("DROP SCHEMA IF EXISTS macrostrat_api CASCADE;") + cur.execute("DROP SCHEMA IF EXISTS macrostrat CASCADE;") + cur.execute("DROP TYPE IF EXISTS measurement_type CASCADE;") + cur.execute("DROP TYPE IF EXISTS measurement_class CASCADE;") + cur.execute(schema) + cur.execute(data_inserts) + +# @pytest.fixture +# def db(setup, connection): +# with connection.cursor() as cur: +# yield cur +# connection.rollback() + +@pytest.fixture() +def db(setup, db_): + return db_ + +@pytest.fixture +def client(db_): + return TestClient(app) \ No newline at end of file diff --git a/v2-transition/services/column-builder/backend/tests/test_z_auth.py b/v2-transition/services/column-builder/backend/tests/test_z_auth.py new file mode 100644 index 000000000..9496971cf --- /dev/null +++ b/v2-transition/services/column-builder/backend/tests/test_z_auth.py @@ -0,0 +1,175 @@ +from requests import get, post, patch, put +from urvogel.database.fixtures import get_sql +import time + +base= "http://127.0.0.1:3001" + +username = "cidzikowski" +password = "gniessrocks" + +auth = get_sql("02-auth.sql") + +def login(username, password): + res = post(base+"/rpc/login", data={"username": username, "pass": password}) + token = res.json().get('token') + headers = {"Prefer": "return=representation", "Authorization": f'bearer {token}'} + + return headers + +def test_create_auth(db): + with db.conn.cursor() as cur: + cur.execute(auth) + + sql =""" SELECT EXISTS ( + SELECT FROM information_schema.tables + WHERE table_schema = 'auth' + AND table_name = 'users' + ); """ + + res = db.query(sql).fetchone() + assert res.get("exists") == True + + sql = """ + SELECT rolname FROM pg_catalog.pg_roles WHERE rolinherit = FALSE; + """ + res = db.query(sql).fetchall() + + for row in res: + assert row.get('rolname') in ['api_views_owner','anon','authenticator','anon_test','authenticator_test', 'api_user'] + +def test_pg_extensions(db): + sql = """ select extname from pg_extension; """ + res = db.query(sql).fetchall() + extensions = [r.get('extname') for r in res] + assert 'pgcrypto' in extensions + assert 'pgjwt' in extensions + +def test_add_user(db): + time.sleep(10) # if I don't wait it all fails. As if the sql is still being run.... + params = {"firstname": "Casey", "lastname": "Idzikowski", "pass": password, "username": username} + res = post(base+"/rpc/create_user", data=params) + + assert res.status_code == 200 + + sql = """ + SELECT username from auth.users; + """ + res = db.query(sql).fetchone() + assert res.get('username') is not None + +def test_login(db): + + res = post(base+"/rpc/login", data={"username": username, "pass": password}) + + assert res.status_code == 200 + + token = res.json().get('token') + assert token is not None + headers = {"Prefer": "return=representation", "Authorization": f'bearer {token}'} + + res = post(base + "/rpc/get_username", headers=headers) + + assert res.json() == username + + res = get(base + "/projects", headers=headers) + data = res.json() + + assert len(data) == 0 + + # make the user an owner + sql = """ insert into auth.user_projects(user_, project, role_id) + values(1, 1, 4) """ + + with db.conn.cursor() as cur: + cur.execute(sql) + + res = post(base + '/rpc/current_user_projects', headers=headers) + assert len(res.json()) == 1 and res.json()[0].get('project') == 1 + + res = get(base + "/projects", headers={"Prefer": "return=representation", "Authorization": f'bearer {token}'}) + data = res.json() + + assert len(data) == 1 and data[0].get('id') == 1 + +def test_project_create(db): + res = post(base+"/rpc/login", data={"username": username, "pass": password}) + + assert res.status_code == 200 + + token = res.json().get('token') + assert token is not None + headers = {"Prefer": "return=representation", "Authorization": f'bearer {token}'} + + res = post(base + "/projects", headers=headers, data={"project":"CFP1", "descrip":"fake project owned by casey", "timescale_id": 1}) + + assert res.status_code == 201 + res = get(base + "/projects", headers=headers) + data = res.json() + + assert len(data) == 2 + + res = patch(base + "/projects?id=eq.13", headers={"Authorization": f'bearer {token}','Prefer': 'return=minimal'}, data={"project": "CFP2"}) + assert res.status_code != 404 + +def test_child_data(db): + """ add some col-group, col and unit and see that we can access it """ + headers = login(username, password) + + col_group = {"col_group": "CG1", "col_group_long": "Casey's first fake column group", "project_id":13} + res = post(base+"/col_groups", data=col_group, headers=headers) + + assert res.status_code == 201 + + res = get(base + "/col_groups", headers=headers) + assert len(res.json()) == 1 + +def test_rls(db): + """ + create a new user with read only access to casey's project, + As owner I should be able to configure user privileges + """ + username = 'app_user@gmail.com' + password = 'appuser1' + params = {'firstname': 'appuser','lastname':'lastnameApp',"username": username, "pass": password} + + res = post(base+"/rpc/create_user", data=params) + + headers = login('app_user@gmail.com', 'appuser1') + + + res = get(base + "/projects", headers=headers) + data = res.json() + + assert len(data) == 0 + + res = post(base + "/projects", headers=headers, data={"project":"app1", "descrip":"fake project created and owned by app", "timescale_id": 1}) + + assert res.status_code == 201 + res = get(base + "/projects", headers=headers) + data = res.json() + + assert len(data) == 1 + + +def test_user_management(): + """ """ + headers = login(username,password) + + res = get(base + "/user_projects", headers=headers) + + assert len(res.json()) == 2 + + headers_ = login('app_user@gmail.com', 'appuser1') + res = get(base + "/user_projects", headers=headers_) + assert len(res.json()) == 1 + + # make app_user a reader for project 13 + data = {"user_":2, "project":13, "role_id": 1 } + res = post(base + "/user_projects", data=data, headers=headers) + + assert res.status_code == 201 + + res = get(base + "/projects", headers=headers_) + data = res.json() + assert len(data) == 2 + assert data[0].get('id') == 13 \ No newline at end of file diff --git a/v2-transition/services/column-builder/database/bin/dump-burwell b/v2-transition/services/column-builder/database/bin/dump-burwell index 83eea57ca..983dccf9f 100755 --- a/v2-transition/services/column-builder/database/bin/dump-burwell +++ b/v2-transition/services/column-builder/database/bin/dump-burwell @@ -1,15 +1,15 @@ #!/usr/bin/env zsh ## Shell script to dump macrostrat-lite from gunnison into a docker db. -### this is a trash and restart kind of thing. +### this is a trash and restart kind of thing. ########################## functions ################################# help() { - echo + echo echo "Script to dump postgres instance of macrostrat schema from gunnison" echo "WARNING: this will first drop the database specified in -d" - echo + echo echo "Syntax: scriptTemplate [ -p | -c | -d | -U | -h, --help]" echo "options:" echo "-p Port that gunnison is exposed to on your localhost, default 54381" @@ -24,18 +24,18 @@ check() { echo "Gathering arguments" while getopts ":c:d:U:h" opt; do - case $opt in + case $opt in c) container_name=$OPTARG;; d) local_db=$OPTARG;; U) db_user=$OPTARG;; - h) help; exit 1 ;; - \?) help; exit 1 ;; + h) help; exit 1 ;; + \?) help; exit 1 ;; esac done } ############################ variables ################################ -dbname=burwell +dbname=column_data local_db=column_data container_name=db db_user=postgres diff --git a/v2-transition/services/column-builder/database/db-alterations/00-projects.sql b/v2-transition/services/column-builder/database/db-alterations/00-projects.sql new file mode 100644 index 000000000..d3d026de3 --- /dev/null +++ b/v2-transition/services/column-builder/database/db-alterations/00-projects.sql @@ -0,0 +1,20 @@ +CREATE TABLE IF NOT EXISTS macrostrat.projects( + id SERIAL PRIMARY KEY, + project text, + descrip text, + timescale_id integer REFERENCES macrostrat.timescales(id) +); + +INSERT INTO "macrostrat"."projects"("id","project","descrip","timescale_id") +VALUES +(1,E'North America',E'Composite column dataset for the USA and Canada.',1), +(3,E'eODP',E'Comprehensive dataset capturing all offshore drilling sites and holes. Holes at each site are captured as \'section\' column types and meters below sea floor (mbsf) are encoded by \'t_pos\' and \'b_pos\' when \'show_position\' parameter is included. Project led by Andy Fraass, Leah LeVay, Jocelyn Sessa, and Shanan Peters.',1), +(4,E'Deep Sea',E'Offshore drilling sites completely cored from sea floor into or near basement rocks. Most sites in this compilation are composited manually from multiple holes into a single representation for the site. Data compiled from offshore drilling reports by S.E. Peters, D.C. Kelly, and A.Fraass. See project_id=3 (\'eODP\') for complete offshore drilling data and associated measurements.',5), +(5,E'New Zealand',E'Primarily measured section-type columns for Late Cretaceous to Recent.',6), +(6,E'Australia',E'Placeholder for anticipated column entry work.',1), +(7,E'Caribbean',E'Composite column dataset for the Caribbean region, including the eastern Gulf Coast of Mexico and Central America.',1), +(8,E'South America',E'Composite column dataset for South America.',1), +(9,E'Africa',E'Composite column dataset for Africa.',1), +(10,E'North American Ediacaran',E'Composite columns of intermediate scale resolution that are comprehensive for the Ediacaran System of present-day North America and adjacent continental blocks formerly part of North America. Compiled by D. Segessenman as part of his Ph.D.',1), +(11,E'North American Cretaceous',E'Cretaceous-focused intermediate scale resolution section data set compiled by Shan Ye as part of his Ph.D.',1), +(12,E'Indonesia',E'Composite column dataset for Indonesia. Compiled principally by Afiqah Ahmad Rafi as part of her senior thesis at UW-Madison.',1); \ No newline at end of file diff --git a/v2-transition/services/column-builder/database/tests/arc-test_postgrest.py b/v2-transition/services/column-builder/database/tests/arc-test_postgrest.py new file mode 100644 index 000000000..4b5f7b494 --- /dev/null +++ b/v2-transition/services/column-builder/database/tests/arc-test_postgrest.py @@ -0,0 +1,76 @@ +from requests import get, post, patch, put + +""" A testing suite to test some postgrest functionlity """ + + +base= "http://127.0.0.1:3001" + +def test_projects(db): + res = get(base + "/projects") + + data = res.json() + assert len(data) == 3 + +def test_units_query(): + section_id=884 + col_id=112 + + res = get(base + f"/units?col_id=eq.{col_id}§ion_id=eq.{section_id}") + data = res.json() + assert len(data) > 0 + + for col in data: + assert col.get("section_id") == section_id + assert col.get("col_id") == col_id + +def test_units_metadata(): + """ test getting data from 1-many join tables """ + unit_id = 4575 + unit_envs = ["non-marine","fluvial indet."] + res = get(base + f"/units?id=eq.{unit_id}") + unit = res.json() + + assert len(unit) == 1 + unit = unit[0] + + res = get(base + f"/environ_unit?unit_id=eq.{unit['id']}") + + envs = res.json() + assert len(envs) > 0 + + + for env in envs: + assert env.get('unit_id') == unit_id + assert env.get("environ") in unit_envs + +def test_create_environ_add_to_unit(): + unit_id = 4575 + headers={"Prefer": "return=representation"} + + # try inserting directly into the environ_unit + data = dict(environ="test-env",environ_class="marine", environ_color="#669900") + res = post(base + "/environs", data, headers=headers) + environ_id = res.json()[0].get('id') + assert environ_id is not None + + data = {"environ_id": environ_id, "unit_id": unit_id} + res = post(base + "/unit_environs", data, headers=headers) + + data = res.json()[0] + assert data.get('id') is not None + assert data.get('environ_id') == environ_id + assert data.get('unit_id') == unit_id + +def test_edit_unit(): + unit_id = 4575 + headers={"Prefer": "return=representation"} + + data = {"min_thick": 50, "max_thick": 500, "color": "gray light"} + + res = patch(base + f"/units?id=eq.{unit_id}", data, headers=headers) + + unit_res = res.json()[0] + assert unit_res.get('id') == unit_id + assert unit_res.get('min_thick') == data['min_thick'] + assert unit_res.get('max_thick') == data['max_thick'] + diff --git a/v2-transition/services/column-builder/database/tests/bin/dump-auth-schema b/v2-transition/services/column-builder/database/tests/bin/dump-auth-schema new file mode 100755 index 000000000..74ffcc1cf --- /dev/null +++ b/v2-transition/services/column-builder/database/tests/bin/dump-auth-schema @@ -0,0 +1,11 @@ +#!/usr/bin/env zsh + +#### Basically same as dump-schema, but for the db with auth schema + +echo "Removing old schema dump if it exists!!" +rm -f `dirname $0`/../fixtures/auth_schema_dump.sql + +echo "" +echo "" +echo "Dumping the new schema" +docker-compose exec db pg_dump -s -U postgres -d column_data_auth > `dirname $0`/../fixtures/auth_schema_dump.sql \ No newline at end of file diff --git a/v2-transition/services/column-builder/database/tests/bin/dump-data b/v2-transition/services/column-builder/database/tests/bin/dump-data new file mode 100755 index 000000000..d99ff26da --- /dev/null +++ b/v2-transition/services/column-builder/database/tests/bin/dump-data @@ -0,0 +1,9 @@ +#!/usr/bin/env zsh + +echo "Removing old schema dump if it exists!!" +rm -f `dirname $0`/../fixtures/schema_dump.sql + +echo "" +echo "" +echo "Dumping the new schema" +docker-compose exec db pg_dump -U postgres -d column_data > `dirname $0`/../fixtures/data_dump.sql \ No newline at end of file diff --git a/v2-transition/services/column-builder/database/tests/bin/run-tests b/v2-transition/services/column-builder/database/tests/bin/run-tests index 5d0da6449..8b08ed6bd 100755 --- a/v2-transition/services/column-builder/database/tests/bin/run-tests +++ b/v2-transition/services/column-builder/database/tests/bin/run-tests @@ -8,10 +8,10 @@ result=$( docker ps -q -f name=postgrest ) if [[ -n "$result" ]]; then echo "Rebuilding Postgrest Docker container for testing!" - POSTGRES_DB=col_test docker-compose up -d --build postgrest + POSTGRES_DB=col_test PGRST_DB_ANON_ROLE=anon_test AUTH_PGUSER=authenticator_test docker-compose up -d --build postgrest else echo "Starting Docker" - POSTGRES_DB=col_test docker-compose up -d + POSTGRES_DB=col_test PGRST_DB_ANON_ROLE=anon_test AUTH_PGUSER=authenticator_test docker-compose up -d --build postgrest fi pytest --pdb diff --git a/v2-transition/services/column-builder/database/tests/fixtures/02-auth.sql b/v2-transition/services/column-builder/database/tests/fixtures/02-auth.sql new file mode 100644 index 000000000..bd2dbbb9b --- /dev/null +++ b/v2-transition/services/column-builder/database/tests/fixtures/02-auth.sql @@ -0,0 +1,373 @@ +/* Authentication in db using postgrest https://postgrest.org/en/stable/auth.html +Postgrest uses JWT to authenticate incoming requests, but the db can authorize db queries based +on users. + + +authenticator is passed via db-uri +anon: db-anon-role (PGRST_DB_ANON_ROLE) +jwt-secret (PGRST_JWT_SECRET) + + +HOW LOGIN WORKS --> { + take username and password, + get the role and any other info we want tokenized, + if login successful --> return json token +} + +Generate JWT in SQL ---> pgjwt +https://github.com/michelp/pgjwt +https://app.bountysource.com/issues/89971002-example-code-to-show-how-to-install-pgjwt-extension-in-docker + + +How to access info on JWT for the current user --> to be user in policy creation:: +current_setting('request.jwt.claims', true)::json->>'username'; + + +*/ + +/* AUTH schema and functions */ +DROP SCHEMA IF EXISTS auth CASCADE; +CREATE SCHEMA auth; + + +/* necesary extenstions */ +CREATE EXTENSION IF NOT EXISTS pgcrypto; +CREATE EXTENSION IF NOT EXISTS pgjwt; + +/* an auth user table */ +CREATE TABLE IF NOT EXISTS +auth.users( + id serial primary key, + firstname text not null, + lastname text not null, + username text not null, + pass text not null check (length(pass) < 512), + role name not null check (length(role) < 512) +); + +-- data privilege roles +CREATE TABLE IF NOT EXISTS auth.data_roles( + id SERIAL PRIMARY KEY, + role text, + description text +); +-- default data roles +INSERT INTO auth.data_roles(role, description) VALUES + ('reader', 'user can only perform SELECT on data'), + ('writer', 'user can SELECT, INSERT, and UPDATE'), + ('deleter', 'user can SELECT, INSERT, and UPDATE'), + ('manager', 'user encompasses privileges of deleter and can manage user permissions on data'); + +/* Example of a basic data id to role */ +CREATE TABLE IF NOT EXISTS +auth.user_projects( + id serial primary key, + user_ int REFERENCES auth.users(id), + project int REFERENCES macrostrat.projects(id), + role_id integer REFERENCES auth.data_roles(id) +); + +/* make sure the role being added to user table actually exists!! */ +CREATE OR REPLACE FUNCTION +auth.check_role_exists() RETURNS trigger AS $$ +BEGIN + IF NOT EXISTS (SELECT 1 FROM pg_roles AS r WHERE r.rolname = new.role) THEN + raise foreign_key_violation USING message = + 'unknown database role: ' || new.role; + RETURN NULL; + END IF; + RETURN new; +END +$$ LANGUAGE plpgsql; + +DROP trigger IF EXISTS ensure_user_role_exists ON auth.users; +CREATE trigger ensure_user_role_exists + BEFORE INSERT OR UPDATE ON auth.users + FOR EACH ROW + EXECUTE PROCEDURE auth.check_role_exists(); + +/* Encrypt the password so it's not just sitting in the table */ +CREATE OR REPLACE FUNCTION +auth.encrypt_pass() RETURNS trigger AS $$ +BEGIN + IF tg_op = 'INSERT' OR new.pass <> old.pass THEN + new.pass := public.crypt(new.pass, public.gen_salt('md5')); + END IF; + RETURN new; +END +$$ LANGUAGE plpgsql; + +DROP trigger IF EXISTS encrypt_pass ON auth.users; +CREATE trigger encrypt_pass + BEFORE INSERT OR UPDATE ON auth.users + FOR EACH ROW + EXECUTE PROCEDURE auth.encrypt_pass(); + + +/* Access the stored role on a user -- used in login! +*/ +CREATE OR REPLACE FUNCTION +auth.user_role(username TEXT, pass TEXT) RETURNS name + LANGUAGE plpgsql + AS $$ +BEGIN + RETURN ( + SELECT role FROM auth.users + WHERE users.username = user_role.username + AND users.pass = public.crypt(user_role.pass, users.pass) + ); +END; +$$; + +CREATE TYPE auth.jwt_token AS ( + token text +); + +/* +Login function! + */ +CREATE OR REPLACE FUNCTION +macrostrat_api.login(username text, pass text) RETURNS auth.jwt_token AS $$ +DECLARE + _role name; + result auth.jwt_token; +BEGIN + SELECT auth.user_role(username, pass) INTO _role; + IF _role IS NULL THEN + raise invalid_password using message = 'invalid user or password'; + END IF; + -- sign function comes from pgjwt extension. + SELECT sign( + row_to_json(r), 'reallyreallyreallyreallyverysafesafesafesafe' + ) AS token + FROM ( + SELECT 'api_views_owner' as role, login.username as username, + extract(epoch FROM now())::integer + 86400 AS exp --expires in 1 day + ) r + INTO result; + RETURN result; +END +$$ language plpgsql SECURITY DEFINER; + +CREATE OR REPLACE FUNCTION +macrostrat_api.create_user(firstname text, lastname text, pass text, username text) +RETURNS BOOLEAN AS $$ +DECLARE + _role name; +BEGIN + INSERT INTO auth.users(username, firstname, lastname, pass, role) + VALUES (username, firstname, lastname, pass, 'api_views_owner'); + SELECT auth.user_role(username, pass) INTO _role; + + IF _role IS NULL THEN + RETURN FALSE; + END IF; + + RETURN TRUE; +END +$$ language plpgsql SECURITY DEFINER; + +/*####################### BASE DB ROLES ##########################*/ + +-- these are the basic auth roles used by postgrest. +DROP ROLE IF EXISTS anon_test; +CREATE ROLE anon_test NOINHERIT; +DROP ROLE IF EXISTS authenticator_test; +CREATE ROLE authenticator_test NOINHERIT LOGIN; +GRANT anon_test TO authenticator_test; + +GRANT USAGE ON SCHEMA macrostrat_api TO anon_test; +GRANT USAGE ON SCHEMA macrostrat_api TO authenticator_test; + +GRANT EXECUTE ON FUNCTION macrostrat_api.login(text,text) TO anon_test; +GRANT EXECUTE ON FUNCTION macrostrat_api.create_user(text,text,text, text) TO anon_test; +GRANT EXECUTE ON FUNCTION macrostrat_api.login(text,text) TO authenticator_test; +GRANT EXECUTE ON FUNCTION macrostrat_api.create_user(text,text,text, text) TO authenticator_test; + +-- a general api_views_owner, data privileges depend on RLS +GRANT USAGE ON SCHEMA auth TO api_views_owner; +GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA auth TO api_views_owner; +GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA auth TO api_views_owner; + +GRANT api_views_owner to authenticator_test; + +/* ################### Row level policies ################### */ + + +/* function to get username off of jwt claims*/ +CREATE OR REPLACE FUNCTION +macrostrat_api.get_username() returns text AS $$ +DECLARE + username_ text; +BEGIN + SELECT current_setting('request.jwt.claims', true)::json->>'username' INTO username_; +RETURN username_; +END +$$language plpgsql SECURITY DEFINER; + +CREATE OR REPLACE FUNCTION +auth.user_project_insert() RETURNS trigger AS $$ +DECLARE + username_ text; + id_ int; + manager_id int; +BEGIN + IF tg_op = 'INSERT' THEN + select macrostrat_api.get_username() into username_; + select id from auth.users where users.username = username_ INTO id_; + SELECT id FROM auth.data_roles WHERE role = 'manager' INTO manager_id; + INSERT INTO auth.user_projects(user_, project, role_id) + VALUES(id_, new.id, manager_id); + END IF; + RETURN new; +END +$$ LANGUAGE plpgsql SECURITY DEFINER; + +DROP trigger IF EXISTS user_projects ON macrostrat.projects; +CREATE trigger user_projects + AFTER INSERT ON macrostrat.projects + FOR EACH ROW + EXECUTE PROCEDURE auth.user_project_insert(); + +CREATE OR REPLACE FUNCTION +macrostrat_api.current_user_projects() +RETURNS TABLE (project integer, role text) AS $$ +DECLARE + username_ text; +BEGIN + SELECT macrostrat_api.get_username() INTO username_; + RETURN QUERY + SELECT up.project, adr.role FROM auth.user_projects up + JOIN auth.users u + on u.id = up.user_ + JOIN auth.data_roles adr + ON adr.id = up.role_id + WHERE u.username = username_; +END +$$ language plpgsql SECURITY DEFINER; + +/* users table */ +ALTER TABLE auth.users ENABLE ROW LEVEL SECURITY; + +CREATE POLICY secure_users ON auth.users +USING (username = macrostrat_api.get_username()) +WITH CHECK (username = macrostrat_api.get_username()); + +/* user_projects mapping tables */ +ALTER TABLE auth.user_projects ENABLE ROW LEVEL SECURITY; + +-- Only project managers can view and manipulate project privileges +CREATE POLICY manager_projects ON auth.user_projects +USING (project IN ( + SELECT project from macrostrat_api.current_user_projects() + WHERE role = 'manager')) +WITH CHECK (project IN ( + SELECT project from macrostrat_api.current_user_projects() + WHERE role = 'manager')); + + +/* projects */ +ALTER TABLE macrostrat.projects ENABLE ROW LEVEL SECURITY; + +CREATE POLICY projects_ ON macrostrat.projects FOR SELECT +USING (id IN ( + SELECT project FROM macrostrat_api.current_user_projects() + WHERE role IN ('reader','writer','deleter','manager'))); + +-- anyone can insert a new project +CREATE POLICY projects_insert ON macrostrat.projects FOR INSERT +WITH CHECK(TRUE); + +-- Updates only allowable for writer, deleter or manager +CREATE POLICY projects_update ON macrostrat.projects FOR UPDATE +USING(id IN ( + SELECT project from macrostrat_api.current_user_projects() + WHERE role IN ('writer','deleter', 'manager') +)) +WITH CHECK (id IN ( + SELECT project from macrostrat_api.current_user_projects() + WHERE role IN ('writer','deleter', 'manager') +)); + +/* col-groups */ +ALTER TABLE macrostrat.col_groups ENABLE ROW LEVEL SECURITY; + +CREATE POLICY col_groups_select ON macrostrat.col_groups FOR SELECT +USING (project_id IN ( + SELECT project FROM macrostrat_api.current_user_projects() + WHERE role IN ('reader','writer','deleter','manager'))); + + +CREATE POLICY col_group_update ON macrostrat.col_groups FOR UPDATE +USING(project_id IN ( + SELECT project FROM macrostrat_api.current_user_projects() + WHERE role IN ('writer', 'deleter', 'manager'))); + +CREATE POLICY col_group_insert ON macrostrat.col_groups FOR INSERT +WITH CHECK(project_id IN ( + SELECT project FROM macrostrat_api.current_user_projects() + WHERE role IN ('writer', 'deleter', 'manager'))); + +/* cols */ +ALTER TABLE macrostrat.cols ENABLE ROW LEVEL SECURITY; + +CREATE POLICY cols_select ON macrostrat.cols FOR SELECT +USING (project_id IN (SELECT project FROM macrostrat_api.current_user_projects())); + +CREATE POLICY cols_update ON macrostrat.cols for UPDATE +USING(project_id IN ( + SELECT project FROM macrostrat_api.current_user_projects() + WHERE role IN ('writer', 'deleter', 'manager') +)); + +CREATE POLICY cols_insert ON macrostrat.cols for INSERT +WITH CHECK(project_id IN ( + SELECT project FROM macrostrat_api.current_user_projects() + WHERE role IN ('writer', 'deleter', 'manager') +)); + +/* units */ +ALTER TABLE macrostrat.units ENABLE ROW LEVEL SECURITY; + +CREATE POLICY units_select ON macrostrat.units FOR SELECT +USING (col_id IN ( + SELECT c.id from macrostrat.cols c + WHERE c.project_id IN( + SELECT project FROM macrostrat_api.current_user_projects()))); + +CREATE POLICY units_update ON macrostrat.units FOR UPDATE +USING (col_id IN ( + SELECT c.id from macrostrat.cols c + WHERE c.project_id IN( + SELECT project FROM macrostrat_api.current_user_projects() + WHERE role IN ('writer', 'deleter', 'manager')))); + +CREATE POLICY units_insert ON macrostrat.units FOR INSERT +WITH CHECK (col_id IN ( + SELECT c.id from macrostrat.cols c + WHERE c.project_id IN( + SELECT project FROM macrostrat_api.current_user_projects() + WHERE role IN ('writer', 'deleter', 'manager')))); + +CREATE OR REPLACE VIEW macrostrat_api.users AS +SELECT * FROM auth.users; +ALTER VIEW macrostrat_api.users OWNER TO api_views_owner; + +CREATE OR REPLACE VIEW macrostrat_api.user_projects AS +SELECT * FROM auth.user_projects; +ALTER VIEW macrostrat_api.user_projects OWNER TO api_views_owner; + +CREATE OR REPLACE VIEW macrostrat_api.data_roles AS +SELECT * FROM auth.data_roles; +ALTER VIEW macrostrat_api.data_roles OWNER TO api_views_owner; + +ALTER TABLE auth.data_roles ENABLE ROW LEVEL SECURITY; + +CREATE POLICY data_roles_select ON auth.data_roles FOR SELECT +USING(TRUE); + +CREATE POLICY data_roles_update ON auth.data_roles FOR UPDATE +USING (role NOT IN('reader','writer','deleter', 'manager')); + +CREATE POLICY data_roles_insert ON auth.data_roles FOR INSERT +WITH CHECK(role NOT IN ('reader', 'writer', 'deleter', 'manager')); \ No newline at end of file diff --git a/v2-transition/services/column-builder/database/tests/fixtures/auth_schema_dump.sql b/v2-transition/services/column-builder/database/tests/fixtures/auth_schema_dump.sql new file mode 100644 index 000000000..d818ae221 --- /dev/null +++ b/v2-transition/services/column-builder/database/tests/fixtures/auth_schema_dump.sql @@ -0,0 +1,5419 @@ +-- +-- PostgreSQL database dump +-- + +-- Dumped from database version 14.1 (Debian 14.1-1.pgdg110+1) +-- Dumped by pg_dump version 14.1 (Debian 14.1-1.pgdg110+1) + +SET statement_timeout = 0; +SET lock_timeout = 0; +SET idle_in_transaction_session_timeout = 0; +SET client_encoding = 'UTF8'; +SET standard_conforming_strings = on; +SELECT pg_catalog.set_config('search_path', '', false); +SET check_function_bodies = false; +SET xmloption = content; +SET client_min_messages = warning; +SET row_security = off; + +-- +-- Name: auth; Type: SCHEMA; Schema: -; Owner: postgres +-- + +CREATE SCHEMA auth; + + +ALTER SCHEMA auth OWNER TO postgres; + +-- +-- Name: macrostrat; Type: SCHEMA; Schema: -; Owner: postgres +-- + +CREATE SCHEMA macrostrat; + + +ALTER SCHEMA macrostrat OWNER TO postgres; + +-- +-- Name: macrostrat_api; Type: SCHEMA; Schema: -; Owner: postgres +-- + +CREATE SCHEMA macrostrat_api; + + +ALTER SCHEMA macrostrat_api OWNER TO postgres; + +-- +-- Name: pgcrypto; Type: EXTENSION; Schema: -; Owner: - +-- + +CREATE EXTENSION IF NOT EXISTS pgcrypto WITH SCHEMA public; + + +-- +-- Name: EXTENSION pgcrypto; Type: COMMENT; Schema: -; Owner: +-- + +COMMENT ON EXTENSION pgcrypto IS 'cryptographic functions'; + + +-- +-- Name: pgjwt; Type: EXTENSION; Schema: -; Owner: - +-- + +CREATE EXTENSION IF NOT EXISTS pgjwt WITH SCHEMA public; + + +-- +-- Name: EXTENSION pgjwt; Type: COMMENT; Schema: -; Owner: +-- + +COMMENT ON EXTENSION pgjwt IS 'JSON Web Token API for Postgresql'; + + +-- +-- Name: postgis; Type: EXTENSION; Schema: -; Owner: - +-- + +CREATE EXTENSION IF NOT EXISTS postgis WITH SCHEMA public; + + +-- +-- Name: EXTENSION postgis; Type: COMMENT; Schema: -; Owner: +-- + +COMMENT ON EXTENSION postgis IS 'PostGIS geometry and geography spatial types and functions'; + + +-- +-- Name: jwt_token; Type: TYPE; Schema: auth; Owner: postgres +-- + +CREATE TYPE auth.jwt_token AS ( + token text +); + + +ALTER TYPE auth.jwt_token OWNER TO postgres; + +-- +-- Name: measurement_class; Type: TYPE; Schema: public; Owner: postgres +-- + +CREATE TYPE public.measurement_class AS ENUM ( + '', + 'geophysical', + 'geochemical', + 'sedimentological' +); + + +ALTER TYPE public.measurement_class OWNER TO postgres; + +-- +-- Name: measurement_type; Type: TYPE; Schema: public; Owner: postgres +-- + +CREATE TYPE public.measurement_type AS ENUM ( + '', + 'material properties', + 'geochronological', + 'major elements', + 'minor elements', + 'radiogenic isotopes', + 'stable isotopes', + 'petrologic', + 'environmental' +); + + +ALTER TYPE public.measurement_type OWNER TO postgres; + +-- +-- Name: check_role_exists(); Type: FUNCTION; Schema: auth; Owner: postgres +-- + +CREATE FUNCTION auth.check_role_exists() RETURNS trigger + LANGUAGE plpgsql + AS $$ +BEGIN + IF NOT EXISTS (SELECT 1 FROM pg_roles AS r WHERE r.rolname = new.role) THEN + raise foreign_key_violation USING message = + 'unknown database role: ' || new.role; + RETURN NULL; + END IF; + RETURN new; +END +$$; + + +ALTER FUNCTION auth.check_role_exists() OWNER TO postgres; + +-- +-- Name: encrypt_pass(); Type: FUNCTION; Schema: auth; Owner: postgres +-- + +CREATE FUNCTION auth.encrypt_pass() RETURNS trigger + LANGUAGE plpgsql + AS $$ +BEGIN + IF tg_op = 'INSERT' OR new.pass <> old.pass THEN + new.pass := public.crypt(new.pass, public.gen_salt('md5')); + END IF; + RETURN new; +END +$$; + + +ALTER FUNCTION auth.encrypt_pass() OWNER TO postgres; + +-- +-- Name: user_project_insert(); Type: FUNCTION; Schema: auth; Owner: postgres +-- + +CREATE FUNCTION auth.user_project_insert() RETURNS trigger + LANGUAGE plpgsql SECURITY DEFINER + AS $$ +DECLARE + username_ text; + id_ int; + manager_id int; +BEGIN + IF tg_op = 'INSERT' THEN + select macrostrat_api.get_username() into username_; + select id from auth.users where users.username = username_ INTO id_; + SELECT id FROM auth.data_roles WHERE role = 'manager' INTO manager_id; + INSERT INTO auth.user_projects(user_, project, role_id) + VALUES(id_, new.id, manager_id); + END IF; + RETURN new; +END +$$; + + +ALTER FUNCTION auth.user_project_insert() OWNER TO postgres; + +-- +-- Name: user_role(text, text); Type: FUNCTION; Schema: auth; Owner: postgres +-- + +CREATE FUNCTION auth.user_role(username text, pass text) RETURNS name + LANGUAGE plpgsql + AS $$ +BEGIN + RETURN ( + SELECT role FROM auth.users + WHERE users.username = user_role.username + AND users.pass = public.crypt(user_role.pass, users.pass) + ); +END; +$$; + + +ALTER FUNCTION auth.user_role(username text, pass text) OWNER TO postgres; + +-- +-- Name: make_into_serial(text, text); Type: FUNCTION; Schema: macrostrat; Owner: postgres +-- + +CREATE FUNCTION macrostrat.make_into_serial(table_name text, column_name text) RETURNS integer + LANGUAGE plpgsql + AS $$ +DECLARE + start_with INTEGER; + sequence_name TEXT; +BEGIN + sequence_name := table_name || '_' || column_name || '_seq'; + EXECUTE 'SELECT coalesce(max(' || column_name || '), 0) + 1 FROM ' || table_name + INTO start_with; + EXECUTE 'CREATE SEQUENCE IF NOT EXISTS ' || sequence_name || + ' START WITH ' || start_with || + ' OWNED BY ' || table_name || '.' || column_name; + EXECUTE 'SELECT setval(' || quote_literal(sequence_name)|| ',' || start_with || ') FROM ' || table_name; + EXECUTE 'ALTER TABLE ' || table_name || ' ALTER COLUMN ' || column_name || + ' SET DEFAULT nextVal(''' || sequence_name || ''')'; + RETURN start_with; +END; +$$; + + +ALTER FUNCTION macrostrat.make_into_serial(table_name text, column_name text) OWNER TO postgres; + +-- +-- Name: pg_reset_pkey_seq(); Type: PROCEDURE; Schema: macrostrat; Owner: postgres +-- + +CREATE PROCEDURE macrostrat.pg_reset_pkey_seq() + LANGUAGE plpgsql + AS $_$ +DECLARE + sql_reset TEXT; + table_pkeys RECORD; + next_val INT; +BEGIN + +sql_reset := +$sql$ +SELECT macrostrat.make_into_serial('%1$s.%2$s', '%3$s'); +$sql$; + +FOR table_pkeys IN + SELECT kcu.table_schema, kcu.table_name, kcu.column_name + FROM information_schema.key_column_usage kcu + JOIN information_schema.table_constraints tc + ON tc.constraint_name = kcu.constraint_name + WHERE tc.constraint_type='PRIMARY KEY' + AND kcu.table_schema='macrostrat' +LOOP + EXECUTE format(sql_reset, table_pkeys.table_schema,table_pkeys.table_name,table_pkeys.column_name) INTO next_val; + RAISE info 'Resetting Sequence for: %.% (%) to %' + , table_pkeys.table_schema + , table_pkeys.table_name + , table_pkeys.column_name + , next_val + ; +END LOOP; +END +$_$; + + +ALTER PROCEDURE macrostrat.pg_reset_pkey_seq() OWNER TO postgres; + +-- +-- Name: create_user(text, text, text, text); Type: FUNCTION; Schema: macrostrat_api; Owner: postgres +-- + +CREATE FUNCTION macrostrat_api.create_user(firstname text, lastname text, pass text, username text) RETURNS boolean + LANGUAGE plpgsql SECURITY DEFINER + AS $$ +DECLARE + _role name; +BEGIN + INSERT INTO auth.users(username, firstname, lastname, pass, role) + VALUES (username, firstName, lastName, pass, 'api_user'); + SELECT auth.user_role(username, pass) INTO _role; + + IF _role IS NULL THEN + RETURN FALSE; + END IF; + + RETURN TRUE; +END +$$; + + +ALTER FUNCTION macrostrat_api.create_user(firstname text, lastname text, pass text, username text) OWNER TO postgres; + +-- +-- Name: current_user_projects(); Type: FUNCTION; Schema: macrostrat_api; Owner: postgres +-- + +CREATE FUNCTION macrostrat_api.current_user_projects() RETURNS TABLE(project integer, role text) + LANGUAGE plpgsql SECURITY DEFINER + AS $$ +DECLARE + username_ text; +BEGIN + SELECT macrostrat_api.get_username() INTO username_; + RETURN QUERY + SELECT up.project, adr.role FROM auth.user_projects up + JOIN auth.users u + on u.id = up.user_ + JOIN auth.data_roles adr + ON adr.id = up.role_id + WHERE u.username = username_; +END +$$; + + +ALTER FUNCTION macrostrat_api.current_user_projects() OWNER TO postgres; + +-- +-- Name: get_username(); Type: FUNCTION; Schema: macrostrat_api; Owner: postgres +-- + +CREATE FUNCTION macrostrat_api.get_username() RETURNS text + LANGUAGE plpgsql SECURITY DEFINER + AS $$ +DECLARE + username_ text; +BEGIN + SELECT current_setting('request.jwt.claims', true)::json->>'username' INTO username_; +RETURN username_; +END +$$; + + +ALTER FUNCTION macrostrat_api.get_username() OWNER TO postgres; + +-- +-- Name: login(text, text); Type: FUNCTION; Schema: macrostrat_api; Owner: postgres +-- + +CREATE FUNCTION macrostrat_api.login(username text, pass text) RETURNS auth.jwt_token + LANGUAGE plpgsql SECURITY DEFINER + AS $$ +DECLARE + _role name; + result auth.jwt_token; +BEGIN + SELECT auth.user_role(username, pass) INTO _role; + IF _role IS NULL THEN + raise invalid_password using message = 'invalid user or password'; + END IF; + -- sign function comes from pgjwt extension. + SELECT sign( + row_to_json(r), 'reallyreallyreallyreallyverysafesafesafesafe' + ) AS token + FROM ( + SELECT 'api_user' as role, login.username as username, + extract(epoch FROM now())::integer + 86400 AS exp --expires in 1 day + ) r + INTO result; + RETURN result; +END +$$; + + +ALTER FUNCTION macrostrat_api.login(username text, pass text) OWNER TO postgres; + +SET default_tablespace = ''; + +SET default_table_access_method = heap; + +-- +-- Name: data_roles; Type: TABLE; Schema: auth; Owner: postgres +-- + +CREATE TABLE auth.data_roles ( + id integer NOT NULL, + role text, + description text +); + + +ALTER TABLE auth.data_roles OWNER TO postgres; + +-- +-- Name: data_roles_id_seq; Type: SEQUENCE; Schema: auth; Owner: postgres +-- + +CREATE SEQUENCE auth.data_roles_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE auth.data_roles_id_seq OWNER TO postgres; + +-- +-- Name: data_roles_id_seq; Type: SEQUENCE OWNED BY; Schema: auth; Owner: postgres +-- + +ALTER SEQUENCE auth.data_roles_id_seq OWNED BY auth.data_roles.id; + + +-- +-- Name: user_projects; Type: TABLE; Schema: auth; Owner: postgres +-- + +CREATE TABLE auth.user_projects ( + id integer NOT NULL, + user_ integer, + project integer, + role_id integer +); + + +ALTER TABLE auth.user_projects OWNER TO postgres; + +-- +-- Name: user_projects_id_seq; Type: SEQUENCE; Schema: auth; Owner: postgres +-- + +CREATE SEQUENCE auth.user_projects_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE auth.user_projects_id_seq OWNER TO postgres; + +-- +-- Name: user_projects_id_seq; Type: SEQUENCE OWNED BY; Schema: auth; Owner: postgres +-- + +ALTER SEQUENCE auth.user_projects_id_seq OWNED BY auth.user_projects.id; + + +-- +-- Name: users; Type: TABLE; Schema: auth; Owner: postgres +-- + +CREATE TABLE auth.users ( + id integer NOT NULL, + firstname text NOT NULL, + lastname text NOT NULL, + username text NOT NULL, + pass text NOT NULL, + role name NOT NULL, + CONSTRAINT users_pass_check CHECK ((length(pass) < 512)), + CONSTRAINT users_role_check CHECK ((length((role)::text) < 512)) +); + + +ALTER TABLE auth.users OWNER TO postgres; + +-- +-- Name: users_id_seq; Type: SEQUENCE; Schema: auth; Owner: postgres +-- + +CREATE SEQUENCE auth.users_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE auth.users_id_seq OWNER TO postgres; + +-- +-- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: auth; Owner: postgres +-- + +ALTER SEQUENCE auth.users_id_seq OWNED BY auth.users.id; + + +-- +-- Name: autocomplete; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.autocomplete ( + id integer NOT NULL, + name text, + type text, + category text +); + + +ALTER TABLE macrostrat.autocomplete OWNER TO postgres; + +-- +-- Name: TABLE autocomplete; Type: COMMENT; Schema: macrostrat; Owner: postgres +-- + +COMMENT ON TABLE macrostrat.autocomplete IS 'Last updated from MariaDB - 2022-02-25 14:28'; + + +-- +-- Name: col_areas; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.col_areas ( + id integer NOT NULL, + col_id integer, + col_area public.geometry, + wkt text +); + + +ALTER TABLE macrostrat.col_areas OWNER TO postgres; + +-- +-- Name: TABLE col_areas; Type: COMMENT; Schema: macrostrat; Owner: postgres +-- + +COMMENT ON TABLE macrostrat.col_areas IS 'Last updated from MariaDB - 2022-02-25 14:28'; + + +-- +-- Name: col_areas_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.col_areas_id_seq + START WITH 5355 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.col_areas_id_seq OWNER TO postgres; + +-- +-- Name: col_areas_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.col_areas_id_seq OWNED BY macrostrat.col_areas.id; + + +-- +-- Name: col_groups; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.col_groups ( + id integer NOT NULL, + col_group character varying(100), + col_group_long character varying(100), + project_id integer +); + + +ALTER TABLE macrostrat.col_groups OWNER TO postgres; + +-- +-- Name: TABLE col_groups; Type: COMMENT; Schema: macrostrat; Owner: postgres +-- + +COMMENT ON TABLE macrostrat.col_groups IS 'Last updated from MariaDB - 2021-08-30 11:28'; + + +-- +-- Name: col_groups_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.col_groups_id_seq + START WITH 354 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.col_groups_id_seq OWNER TO postgres; + +-- +-- Name: col_groups_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.col_groups_id_seq OWNED BY macrostrat.col_groups.id; + + +-- +-- Name: col_refs; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.col_refs ( + id integer NOT NULL, + col_id integer, + ref_id integer +); + + +ALTER TABLE macrostrat.col_refs OWNER TO postgres; + +-- +-- Name: TABLE col_refs; Type: COMMENT; Schema: macrostrat; Owner: postgres +-- + +COMMENT ON TABLE macrostrat.col_refs IS 'Last updated from MariaDB - 2022-02-25 14:28'; + + +-- +-- Name: col_refs_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.col_refs_id_seq + START WITH 9721 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.col_refs_id_seq OWNER TO postgres; + +-- +-- Name: col_refs_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.col_refs_id_seq OWNED BY macrostrat.col_refs.id; + + +-- +-- Name: cols; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.cols ( + id integer NOT NULL, + col_group_id smallint, + project_id smallint, + col_type text, + status_code character varying(25), + col_position character varying(25), + col numeric, + col_name character varying(100), + lat numeric, + lng numeric, + col_area numeric, + coordinate public.geometry, + wkt text, + created text, + poly_geom public.geometry, + notes text +); + + +ALTER TABLE macrostrat.cols OWNER TO postgres; + +-- +-- Name: TABLE cols; Type: COMMENT; Schema: macrostrat; Owner: postgres +-- + +COMMENT ON TABLE macrostrat.cols IS 'Last updated from MariaDB - 2022-02-25 14:47'; + + +-- +-- Name: cols_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.cols_id_seq + START WITH 5728 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.cols_id_seq OWNER TO postgres; + +-- +-- Name: cols_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.cols_id_seq OWNED BY macrostrat.cols.id; + + +-- +-- Name: concepts_places; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.concepts_places ( + concept_id integer NOT NULL, + place_id integer NOT NULL +); + + +ALTER TABLE macrostrat.concepts_places OWNER TO postgres; + +-- +-- Name: TABLE concepts_places; Type: COMMENT; Schema: macrostrat; Owner: postgres +-- + +COMMENT ON TABLE macrostrat.concepts_places IS 'Last updated from MariaDB - 2022-02-25 14:28'; + + +-- +-- Name: econs; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.econs ( + id integer NOT NULL, + econ text, + econ_type text, + econ_class text, + econ_color text +); + + +ALTER TABLE macrostrat.econs OWNER TO postgres; + +-- +-- Name: TABLE econs; Type: COMMENT; Schema: macrostrat; Owner: postgres +-- + +COMMENT ON TABLE macrostrat.econs IS 'Last updated from MariaDB - 2022-02-25 14:29'; + + +-- +-- Name: econs_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.econs_id_seq + START WITH 24 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.econs_id_seq OWNER TO postgres; + +-- +-- Name: econs_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.econs_id_seq OWNED BY macrostrat.econs.id; + + +-- +-- Name: environs; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.environs ( + id integer NOT NULL, + environ text, + environ_type text, + environ_class text, + environ_color text +); + + +ALTER TABLE macrostrat.environs OWNER TO postgres; + +-- +-- Name: TABLE environs; Type: COMMENT; Schema: macrostrat; Owner: postgres +-- + +COMMENT ON TABLE macrostrat.environs IS 'Last updated from MariaDB - 2021-08-30 11:30'; + + +-- +-- Name: environs_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.environs_id_seq + START WITH 94 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.environs_id_seq OWNER TO postgres; + +-- +-- Name: environs_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.environs_id_seq OWNED BY macrostrat.environs.id; + + +-- +-- Name: grainsize; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.grainsize ( + grain_id integer NOT NULL, + grain_symbol text, + grain_name text, + grain_group text, + soil_group text, + min_size numeric, + max_size numeric, + classification text +); + + +ALTER TABLE macrostrat.grainsize OWNER TO postgres; + +-- +-- Name: grainsize_grain_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.grainsize_grain_id_seq + START WITH 32 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.grainsize_grain_id_seq OWNER TO postgres; + +-- +-- Name: grainsize_grain_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.grainsize_grain_id_seq OWNED BY macrostrat.grainsize.grain_id; + + +-- +-- Name: intervals; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.intervals ( + id integer NOT NULL, + age_bottom numeric, + age_top numeric, + interval_name character varying(200), + interval_abbrev character varying(50), + interval_type character varying(50), + interval_color character varying(20), + rank integer +); + + +ALTER TABLE macrostrat.intervals OWNER TO postgres; + +-- +-- Name: TABLE intervals; Type: COMMENT; Schema: macrostrat; Owner: postgres +-- + +COMMENT ON TABLE macrostrat.intervals IS 'Last updated from MariaDB - 2022-02-25 14:28'; + + +-- +-- Name: intervals_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.intervals_id_seq + START WITH 1596 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.intervals_id_seq OWNER TO postgres; + +-- +-- Name: intervals_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.intervals_id_seq OWNED BY macrostrat.intervals.id; + + +-- +-- Name: intervals_new_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.intervals_new_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.intervals_new_id_seq OWNER TO postgres; + +-- +-- Name: intervals_new_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.intervals_new_id_seq OWNED BY macrostrat.intervals.id; + + +-- +-- Name: lith_atts; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.lith_atts ( + id integer NOT NULL, + lith_att character varying(75), + att_type character varying(25), + lith_att_fill integer +); + + +ALTER TABLE macrostrat.lith_atts OWNER TO postgres; + +-- +-- Name: TABLE lith_atts; Type: COMMENT; Schema: macrostrat; Owner: postgres +-- + +COMMENT ON TABLE macrostrat.lith_atts IS 'Last updated from MariaDB - 2021-08-30 11:26'; + + +-- +-- Name: lith_atts_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.lith_atts_id_seq + START WITH 186 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.lith_atts_id_seq OWNER TO postgres; + +-- +-- Name: lith_atts_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.lith_atts_id_seq OWNED BY macrostrat.lith_atts.id; + + +-- +-- Name: liths; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.liths ( + id integer NOT NULL, + lith character varying(75), + lith_group text, + lith_type character varying(50), + lith_class character varying(50), + lith_equiv integer, + lith_fill integer, + comp_coef numeric, + initial_porosity numeric, + bulk_density numeric, + lith_color character varying(12) +); + + +ALTER TABLE macrostrat.liths OWNER TO postgres; + +-- +-- Name: TABLE liths; Type: COMMENT; Schema: macrostrat; Owner: postgres +-- + +COMMENT ON TABLE macrostrat.liths IS 'Last updated from MariaDB - 2022-02-25 14:28'; + + +-- +-- Name: liths_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.liths_id_seq + START WITH 207 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.liths_id_seq OWNER TO postgres; + +-- +-- Name: liths_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.liths_id_seq OWNED BY macrostrat.liths.id; + + +-- +-- Name: lookup_strat_names; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.lookup_strat_names ( + strat_name_id integer, + strat_name character varying(100), + rank character varying(20), + concept_id integer, + rank_name character varying(200), + bed_id integer, + bed_name character varying(100), + mbr_id integer, + mbr_name character varying(100), + fm_id integer, + fm_name character varying(100), + gp_id integer, + gp_name character varying(100), + sgp_id integer, + sgp_name character varying(100), + early_age numeric, + late_age numeric, + gsc_lexicon character varying(20), + b_period character varying(100), + t_period character varying(100), + c_interval character varying(100), + name_no_lith character varying(100) +); + + +ALTER TABLE macrostrat.lookup_strat_names OWNER TO postgres; + +-- +-- Name: TABLE lookup_strat_names; Type: COMMENT; Schema: macrostrat; Owner: postgres +-- + +COMMENT ON TABLE macrostrat.lookup_strat_names IS 'Last updated from MariaDB - 2021-08-30 11:59'; + + +-- +-- Name: lookup_unit_attrs_api; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.lookup_unit_attrs_api ( + unit_id integer, + lith json, + environ json, + econ json, + measure_short json, + measure_long json +); + + +ALTER TABLE macrostrat.lookup_unit_attrs_api OWNER TO postgres; + +-- +-- Name: TABLE lookup_unit_attrs_api; Type: COMMENT; Schema: macrostrat; Owner: postgres +-- + +COMMENT ON TABLE macrostrat.lookup_unit_attrs_api IS 'Last updated from MariaDB - 2022-02-25 14:29'; + + +-- +-- Name: lookup_unit_intervals; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.lookup_unit_intervals ( + unit_id integer, + fo_age numeric, + b_age numeric, + fo_interval character varying(50), + fo_period character varying(50), + lo_age numeric, + t_age numeric, + lo_interval character varying(50), + lo_period character varying(50), + age character varying(50), + age_id integer, + epoch character varying(50), + epoch_id integer, + period character varying(50), + period_id integer, + era character varying(50), + era_id integer, + eon character varying(50), + eon_id integer, + best_interval_id integer +); + + +ALTER TABLE macrostrat.lookup_unit_intervals OWNER TO postgres; + +-- +-- Name: TABLE lookup_unit_intervals; Type: COMMENT; Schema: macrostrat; Owner: postgres +-- + +COMMENT ON TABLE macrostrat.lookup_unit_intervals IS 'Last updated from MariaDB - 2021-08-30 11:26'; + + +-- +-- Name: lookup_unit_liths; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.lookup_unit_liths ( + unit_id integer, + lith_class character varying(100), + lith_type character varying(100), + lith_short text, + lith_long text, + environ_class character varying(100), + environ_type character varying(100), + environ character varying(255) +); + + +ALTER TABLE macrostrat.lookup_unit_liths OWNER TO postgres; + +-- +-- Name: TABLE lookup_unit_liths; Type: COMMENT; Schema: macrostrat; Owner: postgres +-- + +COMMENT ON TABLE macrostrat.lookup_unit_liths IS 'Last updated from MariaDB - 2022-02-25 14:28'; + + +-- +-- Name: lookup_units; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.lookup_units ( + unit_id integer NOT NULL, + col_area numeric NOT NULL, + project_id integer NOT NULL, + t_int integer, + t_int_name text, + t_int_age numeric, + t_age numeric, + t_prop numeric, + t_plat numeric, + t_plng numeric, + b_int integer, + b_int_name text, + b_int_age numeric, + b_age numeric, + b_prop numeric, + b_plat numeric, + b_plng numeric, + clat numeric, + clng numeric, + color text, + text_color text, + units_above text, + units_below text, + pbdb_collections integer, + pbdb_occurrences integer, + age text, + age_id integer, + epoch text, + epoch_id integer, + period text, + period_id integer, + era text, + era_id integer, + eon text, + eon_id integer +); + + +ALTER TABLE macrostrat.lookup_units OWNER TO postgres; + +-- +-- Name: TABLE lookup_units; Type: COMMENT; Schema: macrostrat; Owner: postgres +-- + +COMMENT ON TABLE macrostrat.lookup_units IS 'Last updated from MariaDB - 2021-08-30 11:29'; + + +-- +-- Name: lookup_units_unit_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.lookup_units_unit_id_seq + START WITH 52383 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.lookup_units_unit_id_seq OWNER TO postgres; + +-- +-- Name: lookup_units_unit_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.lookup_units_unit_id_seq OWNED BY macrostrat.lookup_units.unit_id; + + +-- +-- Name: measurements; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.measurements ( + id integer NOT NULL, + measurement_class public.measurement_class NOT NULL, + measurement_type public.measurement_type NOT NULL, + measurement text NOT NULL +); + + +ALTER TABLE macrostrat.measurements OWNER TO postgres; + +-- +-- Name: TABLE measurements; Type: COMMENT; Schema: macrostrat; Owner: postgres +-- + +COMMENT ON TABLE macrostrat.measurements IS 'Last updated from MariaDB - 2022-02-25 15:08'; + + +-- +-- Name: measurements_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.measurements_id_seq + START WITH 125 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.measurements_id_seq OWNER TO postgres; + +-- +-- Name: measurements_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.measurements_id_seq OWNED BY macrostrat.measurements.id; + + +-- +-- Name: measurements_new_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.measurements_new_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.measurements_new_id_seq OWNER TO postgres; + +-- +-- Name: measurements_new_id_seq1; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.measurements_new_id_seq1 + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.measurements_new_id_seq1 OWNER TO postgres; + +-- +-- Name: measurements_new_id_seq1; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.measurements_new_id_seq1 OWNED BY macrostrat.measurements.id; + + +-- +-- Name: measuremeta; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.measuremeta ( + id integer NOT NULL, + sample_name text NOT NULL, + lat numeric(8,5), + lng numeric(8,5), + sample_geo_unit text NOT NULL, + sample_lith text, + lith_id integer NOT NULL, + lith_att_id bigint NOT NULL, + age text NOT NULL, + early_id bigint NOT NULL, + late_id bigint NOT NULL, + sample_descrip text, + ref text NOT NULL, + ref_id bigint NOT NULL +); + + +ALTER TABLE macrostrat.measuremeta OWNER TO postgres; + +-- +-- Name: TABLE measuremeta; Type: COMMENT; Schema: macrostrat; Owner: postgres +-- + +COMMENT ON TABLE macrostrat.measuremeta IS 'Last updated from MariaDB - 2022-02-25 14:29'; + + +-- +-- Name: measuremeta_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.measuremeta_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.measuremeta_id_seq OWNER TO postgres; + +-- +-- Name: measuremeta_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.measuremeta_id_seq OWNED BY macrostrat.measuremeta.id; + + +-- +-- Name: measuremeta_new_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.measuremeta_new_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.measuremeta_new_id_seq OWNER TO postgres; + +-- +-- Name: measuremeta_new_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.measuremeta_new_id_seq OWNED BY macrostrat.measuremeta.id; + + +-- +-- Name: measures; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.measures ( + id integer NOT NULL, + measuremeta_id integer NOT NULL, + measurement_id integer NOT NULL, + sample_no character varying(50), + measure_phase character varying(100) NOT NULL, + method character varying(100) NOT NULL, + units character varying(25) NOT NULL, + measure_value numeric(10,5), + v_error numeric(10,5), + v_error_units character varying(25), + v_type character varying(100), + v_n integer +); + + +ALTER TABLE macrostrat.measures OWNER TO postgres; + +-- +-- Name: TABLE measures; Type: COMMENT; Schema: macrostrat; Owner: postgres +-- + +COMMENT ON TABLE macrostrat.measures IS 'Last updated from MariaDB - 2021-08-30 11:58'; + + +-- +-- Name: measures_new_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.measures_new_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.measures_new_id_seq OWNER TO postgres; + +-- +-- Name: measures_new_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.measures_new_id_seq OWNED BY macrostrat.measures.id; + + +-- +-- Name: pbdb_collections; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.pbdb_collections ( + collection_no integer NOT NULL, + name text, + early_age numeric, + late_age numeric, + grp text, + grp_clean text, + formation text, + formation_clean text, + member text, + member_clean text, + lithologies text[], + environment text, + reference_no integer, + n_occs integer, + geom public.geometry(Geometry,4326) +); + + +ALTER TABLE macrostrat.pbdb_collections OWNER TO postgres; + +-- +-- Name: TABLE pbdb_collections; Type: COMMENT; Schema: macrostrat; Owner: postgres +-- + +COMMENT ON TABLE macrostrat.pbdb_collections IS 'Last updated from MariaDB - 2021-08-30 12:01'; + + +-- +-- Name: pbdb_collections_strat_names; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.pbdb_collections_strat_names ( + collection_no integer NOT NULL, + strat_name_id integer NOT NULL, + basis_col text +); + + +ALTER TABLE macrostrat.pbdb_collections_strat_names OWNER TO postgres; + +-- +-- Name: places; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.places ( + place_id integer NOT NULL, + name text, + abbrev text, + postal text, + country text, + country_abbrev text, + geom public.geometry +); + + +ALTER TABLE macrostrat.places OWNER TO postgres; + +-- +-- Name: TABLE places; Type: COMMENT; Schema: macrostrat; Owner: postgres +-- + +COMMENT ON TABLE macrostrat.places IS 'Last updated from MariaDB - 2022-02-25 14:29'; + + +-- +-- Name: places_place_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.places_place_id_seq + START WITH 88 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.places_place_id_seq OWNER TO postgres; + +-- +-- Name: places_place_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.places_place_id_seq OWNED BY macrostrat.places.place_id; + + +-- +-- Name: projects; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.projects ( + id integer NOT NULL, + project text, + descrip text, + timescale_id integer +); + + +ALTER TABLE macrostrat.projects OWNER TO postgres; + +-- +-- Name: TABLE projects; Type: COMMENT; Schema: macrostrat; Owner: postgres +-- + +COMMENT ON TABLE macrostrat.projects IS 'Last updated from MariaDB - 2022-02-25 14:40'; + + +-- +-- Name: projects_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.projects_id_seq + START WITH 13 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.projects_id_seq OWNER TO postgres; + +-- +-- Name: projects_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.projects_id_seq OWNED BY macrostrat.projects.id; + + +-- +-- Name: projects_new_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.projects_new_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.projects_new_id_seq OWNER TO postgres; + +-- +-- Name: projects_new_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.projects_new_id_seq OWNED BY macrostrat.projects.id; + + +-- +-- Name: refs; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.refs ( + id integer NOT NULL, + pub_year integer, + author character varying(255), + ref text, + doi character varying(40), + compilation_code character varying(100), + url text, + rgeom public.geometry(Geometry,4326) +); + + +ALTER TABLE macrostrat.refs OWNER TO postgres; + +-- +-- Name: TABLE refs; Type: COMMENT; Schema: macrostrat; Owner: postgres +-- + +COMMENT ON TABLE macrostrat.refs IS 'Last updated from MariaDB - 2021-08-30 11:25'; + + +-- +-- Name: refs_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.refs_id_seq + START WITH 218 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.refs_id_seq OWNER TO postgres; + +-- +-- Name: refs_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.refs_id_seq OWNED BY macrostrat.refs.id; + + +-- +-- Name: sections; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.sections ( + id integer NOT NULL, + col_id integer +); + + +ALTER TABLE macrostrat.sections OWNER TO postgres; + +-- +-- Name: TABLE sections; Type: COMMENT; Schema: macrostrat; Owner: postgres +-- + +COMMENT ON TABLE macrostrat.sections IS 'Last updated from MariaDB - 2022-02-25 14:41'; + + +-- +-- Name: sections_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.sections_id_seq + START WITH 12737 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.sections_id_seq OWNER TO postgres; + +-- +-- Name: sections_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.sections_id_seq OWNED BY macrostrat.sections.id; + + +-- +-- Name: sections_new_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.sections_new_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.sections_new_id_seq OWNER TO postgres; + +-- +-- Name: sections_new_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.sections_new_id_seq OWNED BY macrostrat.sections.id; + + +-- +-- Name: strat_name_footprints; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.strat_name_footprints ( + strat_name_id integer, + name_no_lith character varying(100), + rank_name character varying(200), + concept_id integer, + concept_names integer[], + geom public.geometry(Geometry,4326), + best_t_age numeric, + best_b_age numeric +); + + +ALTER TABLE macrostrat.strat_name_footprints OWNER TO postgres; + +-- +-- Name: strat_names; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.strat_names ( + id integer NOT NULL, + strat_name character varying(100) NOT NULL, + rank character varying(50), + ref_id integer NOT NULL, + concept_id integer +); + + +ALTER TABLE macrostrat.strat_names OWNER TO postgres; + +-- +-- Name: TABLE strat_names; Type: COMMENT; Schema: macrostrat; Owner: postgres +-- + +COMMENT ON TABLE macrostrat.strat_names IS 'Last updated from MariaDB - 2021-08-30 11:31'; + + +-- +-- Name: strat_names_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.strat_names_id_seq + START WITH 108117 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.strat_names_id_seq OWNER TO postgres; + +-- +-- Name: strat_names_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.strat_names_id_seq OWNED BY macrostrat.strat_names.id; + + +-- +-- Name: strat_names_meta; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.strat_names_meta ( + concept_id integer NOT NULL, + orig_id integer NOT NULL, + name character varying(40), + geologic_age text, + interval_id integer NOT NULL, + b_int integer NOT NULL, + t_int integer NOT NULL, + usage_notes text, + other text, + province text, + url character varying(150), + ref_id integer NOT NULL +); + + +ALTER TABLE macrostrat.strat_names_meta OWNER TO postgres; + +-- +-- Name: TABLE strat_names_meta; Type: COMMENT; Schema: macrostrat; Owner: postgres +-- + +COMMENT ON TABLE macrostrat.strat_names_meta IS 'Last updated from MariaDB - 2021-08-30 11:28'; + + +-- +-- Name: strat_names_meta_concept_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.strat_names_meta_concept_id_seq + START WITH 43927 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.strat_names_meta_concept_id_seq OWNER TO postgres; + +-- +-- Name: strat_names_meta_concept_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.strat_names_meta_concept_id_seq OWNED BY macrostrat.strat_names_meta.concept_id; + + +-- +-- Name: strat_names_new_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.strat_names_new_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.strat_names_new_id_seq OWNER TO postgres; + +-- +-- Name: strat_names_new_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.strat_names_new_id_seq OWNED BY macrostrat.strat_names.id; + + +-- +-- Name: strat_names_places; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.strat_names_places ( + strat_name_id integer NOT NULL, + place_id integer NOT NULL +); + + +ALTER TABLE macrostrat.strat_names_places OWNER TO postgres; + +-- +-- Name: TABLE strat_names_places; Type: COMMENT; Schema: macrostrat; Owner: postgres +-- + +COMMENT ON TABLE macrostrat.strat_names_places IS 'Last updated from MariaDB - 2022-02-25 14:29'; + + +-- +-- Name: strat_tree; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.strat_tree ( + id integer NOT NULL, + parent integer, + child integer, + ref_id integer +); + + +ALTER TABLE macrostrat.strat_tree OWNER TO postgres; + +-- +-- Name: TABLE strat_tree; Type: COMMENT; Schema: macrostrat; Owner: postgres +-- + +COMMENT ON TABLE macrostrat.strat_tree IS 'Last updated from MariaDB - 2022-02-25 14:40'; + + +-- +-- Name: strat_tree_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.strat_tree_id_seq + START WITH 29785 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.strat_tree_id_seq OWNER TO postgres; + +-- +-- Name: strat_tree_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.strat_tree_id_seq OWNED BY macrostrat.strat_tree.id; + + +-- +-- Name: strat_tree_new_id_seq1; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.strat_tree_new_id_seq1 + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.strat_tree_new_id_seq1 OWNER TO postgres; + +-- +-- Name: strat_tree_new_id_seq1; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.strat_tree_new_id_seq1 OWNED BY macrostrat.strat_tree.id; + + +-- +-- Name: timescales; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.timescales ( + id integer NOT NULL, + timescale character varying(100), + ref_id integer +); + + +ALTER TABLE macrostrat.timescales OWNER TO postgres; + +-- +-- Name: TABLE timescales; Type: COMMENT; Schema: macrostrat; Owner: postgres +-- + +COMMENT ON TABLE macrostrat.timescales IS 'Last updated from MariaDB - 2021-08-30 11:29'; + + +-- +-- Name: timescales_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.timescales_id_seq + START WITH 29 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.timescales_id_seq OWNER TO postgres; + +-- +-- Name: timescales_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.timescales_id_seq OWNED BY macrostrat.timescales.id; + + +-- +-- Name: timescales_intervals; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.timescales_intervals ( + timescale_id integer, + interval_id integer +); + + +ALTER TABLE macrostrat.timescales_intervals OWNER TO postgres; + +-- +-- Name: TABLE timescales_intervals; Type: COMMENT; Schema: macrostrat; Owner: postgres +-- + +COMMENT ON TABLE macrostrat.timescales_intervals IS 'Last updated from MariaDB - 2022-02-25 14:29'; + + +-- +-- Name: unit_econs; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.unit_econs ( + id integer NOT NULL, + unit_id integer, + econ_id integer, + ref_id integer, + date_mod text +); + + +ALTER TABLE macrostrat.unit_econs OWNER TO postgres; + +-- +-- Name: TABLE unit_econs; Type: COMMENT; Schema: macrostrat; Owner: postgres +-- + +COMMENT ON TABLE macrostrat.unit_econs IS 'Last updated from MariaDB - 2021-08-30 11:25'; + + +-- +-- Name: unit_econs_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.unit_econs_id_seq + START WITH 3158 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.unit_econs_id_seq OWNER TO postgres; + +-- +-- Name: unit_econs_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.unit_econs_id_seq OWNED BY macrostrat.unit_econs.id; + + +-- +-- Name: unit_environs; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.unit_environs ( + id integer NOT NULL, + unit_id integer, + environ_id integer, + ref_id integer, + date_mod text +); + + +ALTER TABLE macrostrat.unit_environs OWNER TO postgres; + +-- +-- Name: TABLE unit_environs; Type: COMMENT; Schema: macrostrat; Owner: postgres +-- + +COMMENT ON TABLE macrostrat.unit_environs IS 'Last updated from MariaDB - 2021-08-30 11:25'; + + +-- +-- Name: unit_environs_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.unit_environs_id_seq + START WITH 85924 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.unit_environs_id_seq OWNER TO postgres; + +-- +-- Name: unit_environs_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.unit_environs_id_seq OWNED BY macrostrat.unit_environs.id; + + +-- +-- Name: unit_lith_atts; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.unit_lith_atts ( + id integer NOT NULL, + unit_lith_id integer, + lith_att_id integer, + ref_id integer, + date_mod text +); + + +ALTER TABLE macrostrat.unit_lith_atts OWNER TO postgres; + +-- +-- Name: TABLE unit_lith_atts; Type: COMMENT; Schema: macrostrat; Owner: postgres +-- + +COMMENT ON TABLE macrostrat.unit_lith_atts IS 'Last updated from MariaDB - 2021-08-30 11:25'; + + +-- +-- Name: unit_lith_atts_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.unit_lith_atts_id_seq + START WITH 60953 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.unit_lith_atts_id_seq OWNER TO postgres; + +-- +-- Name: unit_lith_atts_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.unit_lith_atts_id_seq OWNED BY macrostrat.unit_lith_atts.id; + + +-- +-- Name: unit_liths; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.unit_liths ( + id integer NOT NULL, + lith_id integer, + unit_id integer, + prop text, + dom text, + comp_prop numeric, + mod_prop numeric, + toc numeric, + ref_id integer, + date_mod text +); + + +ALTER TABLE macrostrat.unit_liths OWNER TO postgres; + +-- +-- Name: TABLE unit_liths; Type: COMMENT; Schema: macrostrat; Owner: postgres +-- + +COMMENT ON TABLE macrostrat.unit_liths IS 'Last updated from MariaDB - 2022-02-25 14:28'; + + +-- +-- Name: unit_liths_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.unit_liths_id_seq + START WITH 132637 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.unit_liths_id_seq OWNER TO postgres; + +-- +-- Name: unit_liths_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.unit_liths_id_seq OWNED BY macrostrat.unit_liths.id; + + +-- +-- Name: unit_measures; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.unit_measures ( + id integer NOT NULL, + measuremeta_id integer NOT NULL, + unit_id integer NOT NULL, + strat_name_id integer NOT NULL, + match_basis character varying(10) NOT NULL, + rel_position numeric(6,5) +); + + +ALTER TABLE macrostrat.unit_measures OWNER TO postgres; + +-- +-- Name: TABLE unit_measures; Type: COMMENT; Schema: macrostrat; Owner: postgres +-- + +COMMENT ON TABLE macrostrat.unit_measures IS 'Last updated from MariaDB - 2018-09-25 10:40'; + + +-- +-- Name: unit_measures_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.unit_measures_id_seq + START WITH 105049 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.unit_measures_id_seq OWNER TO postgres; + +-- +-- Name: unit_measures_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.unit_measures_id_seq OWNED BY macrostrat.unit_measures.id; + + +-- +-- Name: unit_measures_new_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.unit_measures_new_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.unit_measures_new_id_seq OWNER TO postgres; + +-- +-- Name: unit_measures_new_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.unit_measures_new_id_seq OWNED BY macrostrat.unit_measures.id; + + +-- +-- Name: unit_strat_names; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.unit_strat_names ( + id integer NOT NULL, + unit_id integer NOT NULL, + strat_name_id integer NOT NULL +); + + +ALTER TABLE macrostrat.unit_strat_names OWNER TO postgres; + +-- +-- Name: TABLE unit_strat_names; Type: COMMENT; Schema: macrostrat; Owner: postgres +-- + +COMMENT ON TABLE macrostrat.unit_strat_names IS 'Last updated from MariaDB - 2022-02-25 14:28'; + + +-- +-- Name: unit_strat_names_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.unit_strat_names_id_seq + START WITH 32147 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.unit_strat_names_id_seq OWNER TO postgres; + +-- +-- Name: unit_strat_names_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.unit_strat_names_id_seq OWNED BY macrostrat.unit_strat_names.id; + + +-- +-- Name: unit_strat_names_new_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.unit_strat_names_new_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.unit_strat_names_new_id_seq OWNER TO postgres; + +-- +-- Name: unit_strat_names_new_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.unit_strat_names_new_id_seq OWNED BY macrostrat.unit_strat_names.id; + + +-- +-- Name: units; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.units ( + id integer NOT NULL, + strat_name character varying(150), + color character varying(20), + outcrop character varying(20), + fo integer, + lo integer, + position_bottom numeric, + position_top numeric, + max_thick numeric, + min_thick numeric, + section_id integer, + col_id integer, + notes text, + strat_name_id integer +); + + +ALTER TABLE macrostrat.units OWNER TO postgres; + +-- +-- Name: TABLE units; Type: COMMENT; Schema: macrostrat; Owner: postgres +-- + +COMMENT ON TABLE macrostrat.units IS 'Last updated from MariaDB - 2022-02-25 14:47'; + + +-- +-- Name: units_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.units_id_seq + START WITH 53232 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.units_id_seq OWNER TO postgres; + +-- +-- Name: units_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.units_id_seq OWNED BY macrostrat.units.id; + + +-- +-- Name: units_sections; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.units_sections ( + id integer NOT NULL, + unit_id integer NOT NULL, + section_id integer NOT NULL, + col_id integer NOT NULL +); + + +ALTER TABLE macrostrat.units_sections OWNER TO postgres; + +-- +-- Name: TABLE units_sections; Type: COMMENT; Schema: macrostrat; Owner: postgres +-- + +COMMENT ON TABLE macrostrat.units_sections IS 'Last updated from MariaDB - 2021-08-30 11:59'; + + +-- +-- Name: units_sections_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.units_sections_id_seq + START WITH 50897 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.units_sections_id_seq OWNER TO postgres; + +-- +-- Name: units_sections_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.units_sections_id_seq OWNED BY macrostrat.units_sections.id; + + +-- +-- Name: units_sections_new_id_seq1; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.units_sections_new_id_seq1 + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.units_sections_new_id_seq1 OWNER TO postgres; + +-- +-- Name: units_sections_new_id_seq1; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.units_sections_new_id_seq1 OWNED BY macrostrat.units_sections.id; + + +-- +-- Name: col_form; Type: VIEW; Schema: macrostrat_api; Owner: api_user +-- + +CREATE VIEW macrostrat_api.col_form AS + SELECT c.id AS col_id, + c.col_name, + c.col AS col_number, + c.notes, + json_build_object('id', r.id, 'pub_year', r.pub_year, 'author', r.author, 'ref', r.ref, 'doi', r.doi, 'url', r.url) AS ref + FROM ((macrostrat.cols c + LEFT JOIN macrostrat.col_refs cr ON ((c.id = cr.col_id))) + LEFT JOIN macrostrat.refs r ON ((cr.ref_id = r.id))); + + +ALTER TABLE macrostrat_api.col_form OWNER TO api_user; + +-- +-- Name: col_group_view; Type: VIEW; Schema: macrostrat_api; Owner: api_user +-- + +CREATE VIEW macrostrat_api.col_group_view AS +SELECT + NULL::integer AS id, + NULL::character varying(100) AS col_group, + NULL::character varying(100) AS col_group_long, + NULL::integer AS project_id, + NULL::json AS cols; + + +ALTER TABLE macrostrat_api.col_group_view OWNER TO api_user; + +-- +-- Name: col_groups; Type: VIEW; Schema: macrostrat_api; Owner: api_user +-- + +CREATE VIEW macrostrat_api.col_groups AS + SELECT col_groups.id, + col_groups.col_group, + col_groups.col_group_long, + col_groups.project_id + FROM macrostrat.col_groups; + + +ALTER TABLE macrostrat_api.col_groups OWNER TO api_user; + +-- +-- Name: col_refs; Type: VIEW; Schema: macrostrat_api; Owner: api_user +-- + +CREATE VIEW macrostrat_api.col_refs AS + SELECT col_refs.id, + col_refs.col_id, + col_refs.ref_id + FROM macrostrat.col_refs; + + +ALTER TABLE macrostrat_api.col_refs OWNER TO api_user; + +-- +-- Name: col_sections; Type: VIEW; Schema: macrostrat_api; Owner: api_user +-- + +CREATE VIEW macrostrat_api.col_sections AS + SELECT c.id AS col_id, + c.col_name, + u.section_id, + u.position_top, + u.position_bottom, + fo.interval_name AS bottom, + lo.interval_name AS top + FROM (((macrostrat.cols c + LEFT JOIN macrostrat.units u ON ((u.col_id = c.id))) + LEFT JOIN macrostrat.intervals fo ON ((u.fo = fo.id))) + LEFT JOIN macrostrat.intervals lo ON ((u.lo = lo.id))); + + +ALTER TABLE macrostrat_api.col_sections OWNER TO api_user; + +-- +-- Name: cols; Type: VIEW; Schema: macrostrat_api; Owner: api_user +-- + +CREATE VIEW macrostrat_api.cols AS + SELECT cols.id, + cols.col_group_id, + cols.project_id, + cols.col_type, + cols.status_code, + cols.col_position, + cols.col, + cols.col_name, + cols.lat, + cols.lng, + cols.col_area, + cols.coordinate, + cols.wkt, + cols.created, + cols.poly_geom, + cols.notes + FROM macrostrat.cols; + + +ALTER TABLE macrostrat_api.cols OWNER TO api_user; + +-- +-- Name: data_roles; Type: VIEW; Schema: macrostrat_api; Owner: api_user +-- + +CREATE VIEW macrostrat_api.data_roles AS + SELECT data_roles.id, + data_roles.role, + data_roles.description + FROM auth.data_roles; + + +ALTER TABLE macrostrat_api.data_roles OWNER TO api_user; + +-- +-- Name: econ_unit; Type: VIEW; Schema: macrostrat_api; Owner: api_user +-- + +CREATE VIEW macrostrat_api.econ_unit AS + SELECT e.id, + e.econ, + e.econ_type, + e.econ_class, + e.econ_color, + ue.unit_id, + ue.ref_id + FROM (macrostrat.econs e + JOIN macrostrat.unit_econs ue ON ((e.id = ue.econ_id))); + + +ALTER TABLE macrostrat_api.econ_unit OWNER TO api_user; + +-- +-- Name: environ_unit; Type: VIEW; Schema: macrostrat_api; Owner: api_user +-- + +CREATE VIEW macrostrat_api.environ_unit AS + SELECT e.id, + e.environ, + e.environ_type, + e.environ_class, + e.environ_color, + ue.unit_id, + ue.ref_id + FROM (macrostrat.environs e + JOIN macrostrat.unit_environs ue ON ((e.id = ue.environ_id))); + + +ALTER TABLE macrostrat_api.environ_unit OWNER TO api_user; + +-- +-- Name: environs; Type: VIEW; Schema: macrostrat_api; Owner: api_user +-- + +CREATE VIEW macrostrat_api.environs AS + SELECT environs.id, + environs.environ, + environs.environ_type, + environs.environ_class, + environs.environ_color + FROM macrostrat.environs; + + +ALTER TABLE macrostrat_api.environs OWNER TO api_user; + +-- +-- Name: intervals; Type: VIEW; Schema: macrostrat_api; Owner: api_user +-- + +CREATE VIEW macrostrat_api.intervals AS + SELECT intervals.id, + intervals.age_bottom, + intervals.age_top, + intervals.interval_name, + intervals.interval_abbrev, + intervals.interval_type, + intervals.interval_color, + intervals.rank + FROM macrostrat.intervals; + + +ALTER TABLE macrostrat_api.intervals OWNER TO api_user; + +-- +-- Name: lith_attr_unit; Type: VIEW; Schema: macrostrat_api; Owner: api_user +-- + +CREATE VIEW macrostrat_api.lith_attr_unit AS + SELECT la.id AS lith_attr_id, + la.lith_att, + la.att_type, + la.lith_att_fill, + l.id, + l.lith, + l.lith_group, + l.lith_type, + l.lith_class, + l.lith_equiv, + l.lith_fill, + l.comp_coef, + l.initial_porosity, + l.bulk_density, + l.lith_color, + ul.unit_id + FROM (((macrostrat.lith_atts la + JOIN macrostrat.unit_lith_atts ula ON ((ula.lith_att_id = la.id))) + JOIN macrostrat.unit_liths ul ON ((ul.id = ula.unit_lith_id))) + JOIN macrostrat.liths l ON ((ul.lith_id = l.id))); + + +ALTER TABLE macrostrat_api.lith_attr_unit OWNER TO api_user; + +-- +-- Name: lith_unit; Type: VIEW; Schema: macrostrat_api; Owner: api_user +-- + +CREATE VIEW macrostrat_api.lith_unit AS + SELECT l.id, + l.lith, + l.lith_group, + l.lith_type, + l.lith_class, + l.lith_color, + ul.prop, + ul.mod_prop, + ul.comp_prop, + ul.ref_id, + ul.unit_id + FROM (macrostrat.unit_liths ul + JOIN macrostrat.liths l ON ((ul.lith_id = l.id))); + + +ALTER TABLE macrostrat_api.lith_unit OWNER TO api_user; + +-- +-- Name: liths; Type: VIEW; Schema: macrostrat_api; Owner: api_user +-- + +CREATE VIEW macrostrat_api.liths AS + SELECT liths.id, + liths.lith, + liths.lith_group, + liths.lith_type, + liths.lith_class, + liths.lith_equiv, + liths.lith_fill, + liths.comp_coef, + liths.initial_porosity, + liths.bulk_density, + liths.lith_color + FROM macrostrat.liths; + + +ALTER TABLE macrostrat_api.liths OWNER TO api_user; + +-- +-- Name: projects; Type: VIEW; Schema: macrostrat_api; Owner: api_user +-- + +CREATE VIEW macrostrat_api.projects AS + SELECT projects.id, + projects.project, + projects.descrip, + projects.timescale_id + FROM macrostrat.projects; + + +ALTER TABLE macrostrat_api.projects OWNER TO api_user; + +-- +-- Name: refs; Type: VIEW; Schema: macrostrat_api; Owner: api_user +-- + +CREATE VIEW macrostrat_api.refs AS + SELECT refs.id, + refs.pub_year, + refs.author, + refs.ref, + refs.doi, + refs.compilation_code, + refs.url, + refs.rgeom + FROM macrostrat.refs; + + +ALTER TABLE macrostrat_api.refs OWNER TO api_user; + +-- +-- Name: sections; Type: VIEW; Schema: macrostrat_api; Owner: api_user +-- + +CREATE VIEW macrostrat_api.sections AS + SELECT sections.id, + sections.col_id + FROM macrostrat.sections; + + +ALTER TABLE macrostrat_api.sections OWNER TO api_user; + +-- +-- Name: strat_names; Type: VIEW; Schema: macrostrat_api; Owner: api_user +-- + +CREATE VIEW macrostrat_api.strat_names AS + SELECT s.id, + s.strat_name, + s.rank, + row_to_json(r.*) AS ref, + row_to_json(sm.*) AS concept + FROM ((macrostrat.strat_names s + LEFT JOIN macrostrat.refs r ON ((r.id = s.ref_id))) + LEFT JOIN macrostrat.strat_names_meta sm ON ((sm.concept_id = s.concept_id))); + + +ALTER TABLE macrostrat_api.strat_names OWNER TO api_user; + +-- +-- Name: strat_tree; Type: VIEW; Schema: macrostrat_api; Owner: api_user +-- + +CREATE VIEW macrostrat_api.strat_tree AS + SELECT strat_tree.id, + strat_tree.parent, + strat_tree.child, + strat_tree.ref_id + FROM macrostrat.strat_tree; + + +ALTER TABLE macrostrat_api.strat_tree OWNER TO api_user; + +-- +-- Name: timescales; Type: VIEW; Schema: macrostrat_api; Owner: api_user +-- + +CREATE VIEW macrostrat_api.timescales AS + SELECT timescales.id, + timescales.timescale, + timescales.ref_id + FROM macrostrat.timescales; + + +ALTER TABLE macrostrat_api.timescales OWNER TO api_user; + +-- +-- Name: unit_environs; Type: VIEW; Schema: macrostrat_api; Owner: postgres +-- + +CREATE VIEW macrostrat_api.unit_environs AS + SELECT unit_environs.id, + unit_environs.unit_id, + unit_environs.environ_id, + unit_environs.ref_id, + unit_environs.date_mod + FROM macrostrat.unit_environs; + + +ALTER TABLE macrostrat_api.unit_environs OWNER TO postgres; + +-- +-- Name: unit_liths; Type: VIEW; Schema: macrostrat_api; Owner: api_user +-- + +CREATE VIEW macrostrat_api.unit_liths AS + SELECT unit_liths.id, + unit_liths.lith_id, + unit_liths.unit_id, + unit_liths.prop, + unit_liths.dom, + unit_liths.comp_prop, + unit_liths.mod_prop, + unit_liths.toc, + unit_liths.ref_id, + unit_liths.date_mod + FROM macrostrat.unit_liths; + + +ALTER TABLE macrostrat_api.unit_liths OWNER TO api_user; + +-- +-- Name: units; Type: VIEW; Schema: macrostrat_api; Owner: api_user +-- + +CREATE VIEW macrostrat_api.units AS + SELECT units.id, + units.strat_name, + units.color, + units.outcrop, + units.fo, + units.lo, + units.position_bottom, + units.position_top, + units.max_thick, + units.min_thick, + units.section_id, + units.col_id, + units.notes, + units.strat_name_id + FROM macrostrat.units; + + +ALTER TABLE macrostrat_api.units OWNER TO api_user; + +-- +-- Name: units_view; Type: VIEW; Schema: macrostrat_api; Owner: api_user +-- + +CREATE VIEW macrostrat_api.units_view AS + SELECT u.id, + u.strat_name AS unit_strat_name, + to_jsonb(s.*) AS strat_name, + u.color, + u.outcrop, + u.fo, + u.lo, + u.position_bottom, + u.position_top, + u.max_thick, + u.min_thick, + u.section_id, + u.col_id, + u.notes, + fo.interval_name AS name_fo, + fo.age_bottom, + lo.interval_name AS name_lo, + lo.age_top + FROM (((macrostrat.units u + LEFT JOIN macrostrat.intervals fo ON ((u.fo = fo.id))) + LEFT JOIN macrostrat.intervals lo ON ((u.lo = lo.id))) + LEFT JOIN macrostrat.strat_names s ON ((u.strat_name_id = s.id))); + + +ALTER TABLE macrostrat_api.units_view OWNER TO api_user; + +-- +-- Name: user_projects; Type: VIEW; Schema: macrostrat_api; Owner: api_user +-- + +CREATE VIEW macrostrat_api.user_projects AS + SELECT user_projects.id, + user_projects.user_, + user_projects.project, + user_projects.role_id + FROM auth.user_projects; + + +ALTER TABLE macrostrat_api.user_projects OWNER TO api_user; + +-- +-- Name: users; Type: VIEW; Schema: macrostrat_api; Owner: api_user +-- + +CREATE VIEW macrostrat_api.users AS + SELECT users.id, + users.firstname, + users.lastname, + users.username, + users.pass, + users.role + FROM auth.users; + + +ALTER TABLE macrostrat_api.users OWNER TO api_user; + +-- +-- Name: data_roles id; Type: DEFAULT; Schema: auth; Owner: postgres +-- + +ALTER TABLE ONLY auth.data_roles ALTER COLUMN id SET DEFAULT nextval('auth.data_roles_id_seq'::regclass); + + +-- +-- Name: user_projects id; Type: DEFAULT; Schema: auth; Owner: postgres +-- + +ALTER TABLE ONLY auth.user_projects ALTER COLUMN id SET DEFAULT nextval('auth.user_projects_id_seq'::regclass); + + +-- +-- Name: users id; Type: DEFAULT; Schema: auth; Owner: postgres +-- + +ALTER TABLE ONLY auth.users ALTER COLUMN id SET DEFAULT nextval('auth.users_id_seq'::regclass); + + +-- +-- Name: col_areas id; Type: DEFAULT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.col_areas ALTER COLUMN id SET DEFAULT nextval('macrostrat.col_areas_id_seq'::regclass); + + +-- +-- Name: col_groups id; Type: DEFAULT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.col_groups ALTER COLUMN id SET DEFAULT nextval('macrostrat.col_groups_id_seq'::regclass); + + +-- +-- Name: col_refs id; Type: DEFAULT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.col_refs ALTER COLUMN id SET DEFAULT nextval('macrostrat.col_refs_id_seq'::regclass); + + +-- +-- Name: cols id; Type: DEFAULT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.cols ALTER COLUMN id SET DEFAULT nextval('macrostrat.cols_id_seq'::regclass); + + +-- +-- Name: econs id; Type: DEFAULT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.econs ALTER COLUMN id SET DEFAULT nextval('macrostrat.econs_id_seq'::regclass); + + +-- +-- Name: environs id; Type: DEFAULT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.environs ALTER COLUMN id SET DEFAULT nextval('macrostrat.environs_id_seq'::regclass); + + +-- +-- Name: grainsize grain_id; Type: DEFAULT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.grainsize ALTER COLUMN grain_id SET DEFAULT nextval('macrostrat.grainsize_grain_id_seq'::regclass); + + +-- +-- Name: intervals id; Type: DEFAULT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.intervals ALTER COLUMN id SET DEFAULT nextval('macrostrat.intervals_id_seq'::regclass); + + +-- +-- Name: lith_atts id; Type: DEFAULT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.lith_atts ALTER COLUMN id SET DEFAULT nextval('macrostrat.lith_atts_id_seq'::regclass); + + +-- +-- Name: liths id; Type: DEFAULT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.liths ALTER COLUMN id SET DEFAULT nextval('macrostrat.liths_id_seq'::regclass); + + +-- +-- Name: lookup_units unit_id; Type: DEFAULT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.lookup_units ALTER COLUMN unit_id SET DEFAULT nextval('macrostrat.lookup_units_unit_id_seq'::regclass); + + +-- +-- Name: measurements id; Type: DEFAULT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.measurements ALTER COLUMN id SET DEFAULT nextval('macrostrat.measurements_id_seq'::regclass); + + +-- +-- Name: measuremeta id; Type: DEFAULT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.measuremeta ALTER COLUMN id SET DEFAULT nextval('macrostrat.measuremeta_id_seq'::regclass); + + +-- +-- Name: measures id; Type: DEFAULT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.measures ALTER COLUMN id SET DEFAULT nextval('macrostrat.measures_new_id_seq'::regclass); + + +-- +-- Name: places place_id; Type: DEFAULT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.places ALTER COLUMN place_id SET DEFAULT nextval('macrostrat.places_place_id_seq'::regclass); + + +-- +-- Name: projects id; Type: DEFAULT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.projects ALTER COLUMN id SET DEFAULT nextval('macrostrat.projects_id_seq'::regclass); + + +-- +-- Name: refs id; Type: DEFAULT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.refs ALTER COLUMN id SET DEFAULT nextval('macrostrat.refs_id_seq'::regclass); + + +-- +-- Name: sections id; Type: DEFAULT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.sections ALTER COLUMN id SET DEFAULT nextval('macrostrat.sections_id_seq'::regclass); + + +-- +-- Name: strat_names id; Type: DEFAULT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.strat_names ALTER COLUMN id SET DEFAULT nextval('macrostrat.strat_names_id_seq'::regclass); + + +-- +-- Name: strat_names_meta concept_id; Type: DEFAULT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.strat_names_meta ALTER COLUMN concept_id SET DEFAULT nextval('macrostrat.strat_names_meta_concept_id_seq'::regclass); + + +-- +-- Name: strat_tree id; Type: DEFAULT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.strat_tree ALTER COLUMN id SET DEFAULT nextval('macrostrat.strat_tree_id_seq'::regclass); + + +-- +-- Name: timescales id; Type: DEFAULT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.timescales ALTER COLUMN id SET DEFAULT nextval('macrostrat.timescales_id_seq'::regclass); + + +-- +-- Name: unit_econs id; Type: DEFAULT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_econs ALTER COLUMN id SET DEFAULT nextval('macrostrat.unit_econs_id_seq'::regclass); + + +-- +-- Name: unit_environs id; Type: DEFAULT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_environs ALTER COLUMN id SET DEFAULT nextval('macrostrat.unit_environs_id_seq'::regclass); + + +-- +-- Name: unit_lith_atts id; Type: DEFAULT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_lith_atts ALTER COLUMN id SET DEFAULT nextval('macrostrat.unit_lith_atts_id_seq'::regclass); + + +-- +-- Name: unit_liths id; Type: DEFAULT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_liths ALTER COLUMN id SET DEFAULT nextval('macrostrat.unit_liths_id_seq'::regclass); + + +-- +-- Name: unit_measures id; Type: DEFAULT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_measures ALTER COLUMN id SET DEFAULT nextval('macrostrat.unit_measures_id_seq'::regclass); + + +-- +-- Name: unit_strat_names id; Type: DEFAULT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_strat_names ALTER COLUMN id SET DEFAULT nextval('macrostrat.unit_strat_names_id_seq'::regclass); + + +-- +-- Name: units id; Type: DEFAULT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.units ALTER COLUMN id SET DEFAULT nextval('macrostrat.units_id_seq'::regclass); + + +-- +-- Name: units_sections id; Type: DEFAULT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.units_sections ALTER COLUMN id SET DEFAULT nextval('macrostrat.units_sections_id_seq'::regclass); + + +-- +-- Name: data_roles data_roles_pkey; Type: CONSTRAINT; Schema: auth; Owner: postgres +-- + +ALTER TABLE ONLY auth.data_roles + ADD CONSTRAINT data_roles_pkey PRIMARY KEY (id); + + +-- +-- Name: user_projects user_projects_pkey; Type: CONSTRAINT; Schema: auth; Owner: postgres +-- + +ALTER TABLE ONLY auth.user_projects + ADD CONSTRAINT user_projects_pkey PRIMARY KEY (id); + + +-- +-- Name: users users_pkey; Type: CONSTRAINT; Schema: auth; Owner: postgres +-- + +ALTER TABLE ONLY auth.users + ADD CONSTRAINT users_pkey PRIMARY KEY (id); + + +-- +-- Name: col_areas col_areas_new_pkey; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.col_areas + ADD CONSTRAINT col_areas_new_pkey PRIMARY KEY (id); + + +-- +-- Name: col_groups col_groups_new_pkey1; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.col_groups + ADD CONSTRAINT col_groups_new_pkey1 PRIMARY KEY (id); + + +-- +-- Name: col_refs col_refs_new_pkey; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.col_refs + ADD CONSTRAINT col_refs_new_pkey PRIMARY KEY (id); + + +-- +-- Name: cols cols_new_pkey1; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.cols + ADD CONSTRAINT cols_new_pkey1 PRIMARY KEY (id); + + +-- +-- Name: econs econs_new_pkey1; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.econs + ADD CONSTRAINT econs_new_pkey1 PRIMARY KEY (id); + + +-- +-- Name: environs environs_new_pkey1; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.environs + ADD CONSTRAINT environs_new_pkey1 PRIMARY KEY (id); + + +-- +-- Name: grainsize grainsize_pkey; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.grainsize + ADD CONSTRAINT grainsize_pkey PRIMARY KEY (grain_id); + + +-- +-- Name: intervals intervals_pkey; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.intervals + ADD CONSTRAINT intervals_pkey PRIMARY KEY (id); + + +-- +-- Name: lith_atts lith_atts_new_pkey1; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.lith_atts + ADD CONSTRAINT lith_atts_new_pkey1 PRIMARY KEY (id); + + +-- +-- Name: liths liths_new_pkey; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.liths + ADD CONSTRAINT liths_new_pkey PRIMARY KEY (id); + + +-- +-- Name: lookup_units lookup_units_new_pkey1; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.lookup_units + ADD CONSTRAINT lookup_units_new_pkey1 PRIMARY KEY (unit_id); + + +-- +-- Name: measurements measurements_new_pkey; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.measurements + ADD CONSTRAINT measurements_new_pkey PRIMARY KEY (id); + + +-- +-- Name: measuremeta measuremeta_new_pkey1; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.measuremeta + ADD CONSTRAINT measuremeta_new_pkey1 PRIMARY KEY (id); + + +-- +-- Name: places places_new_pkey; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.places + ADD CONSTRAINT places_new_pkey PRIMARY KEY (place_id); + + +-- +-- Name: projects projects_new_pkey; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.projects + ADD CONSTRAINT projects_new_pkey PRIMARY KEY (id); + + +-- +-- Name: refs refs_new_pkey1; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.refs + ADD CONSTRAINT refs_new_pkey1 PRIMARY KEY (id); + + +-- +-- Name: sections sections_new_pkey; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.sections + ADD CONSTRAINT sections_new_pkey PRIMARY KEY (id); + + +-- +-- Name: strat_names_meta strat_names_meta_new_pkey1; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.strat_names_meta + ADD CONSTRAINT strat_names_meta_new_pkey1 PRIMARY KEY (concept_id); + + +-- +-- Name: strat_names strat_names_new_pkey; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.strat_names + ADD CONSTRAINT strat_names_new_pkey PRIMARY KEY (id); + + +-- +-- Name: strat_tree strat_tree_new_pkey1; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.strat_tree + ADD CONSTRAINT strat_tree_new_pkey1 PRIMARY KEY (id); + + +-- +-- Name: timescales timescales_new_pkey1; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.timescales + ADD CONSTRAINT timescales_new_pkey1 PRIMARY KEY (id); + + +-- +-- Name: unit_econs unit_econs_new_pkey1; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_econs + ADD CONSTRAINT unit_econs_new_pkey1 PRIMARY KEY (id); + + +-- +-- Name: unit_environs unit_environs_new_pkey1; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_environs + ADD CONSTRAINT unit_environs_new_pkey1 PRIMARY KEY (id); + + +-- +-- Name: unit_lith_atts unit_lith_atts_new_pkey1; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_lith_atts + ADD CONSTRAINT unit_lith_atts_new_pkey1 PRIMARY KEY (id); + + +-- +-- Name: unit_liths unit_liths_new_pkey; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_liths + ADD CONSTRAINT unit_liths_new_pkey PRIMARY KEY (id); + + +-- +-- Name: unit_measures unit_measures_new_pkey; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_measures + ADD CONSTRAINT unit_measures_new_pkey PRIMARY KEY (id); + + +-- +-- Name: unit_strat_names unit_strat_names_new_pkey; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_strat_names + ADD CONSTRAINT unit_strat_names_new_pkey PRIMARY KEY (id); + + +-- +-- Name: units units_new_pkey; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.units + ADD CONSTRAINT units_new_pkey PRIMARY KEY (id); + + +-- +-- Name: units_sections units_sections_new_pkey1; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.units_sections + ADD CONSTRAINT units_sections_new_pkey1 PRIMARY KEY (id); + + +-- +-- Name: autocomplete_new_category_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX autocomplete_new_category_idx ON macrostrat.autocomplete USING btree (category); + + +-- +-- Name: autocomplete_new_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX autocomplete_new_id_idx ON macrostrat.autocomplete USING btree (id); + + +-- +-- Name: autocomplete_new_name_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX autocomplete_new_name_idx ON macrostrat.autocomplete USING btree (name); + + +-- +-- Name: autocomplete_new_type_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX autocomplete_new_type_idx ON macrostrat.autocomplete USING btree (type); + + +-- +-- Name: col_areas_new_col_area_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX col_areas_new_col_area_idx ON macrostrat.col_areas USING gist (col_area); + + +-- +-- Name: col_areas_new_col_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX col_areas_new_col_id_idx ON macrostrat.col_areas USING btree (col_id); + + +-- +-- Name: col_groups_new_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX col_groups_new_id_idx1 ON macrostrat.col_groups USING btree (id); + + +-- +-- Name: col_refs_new_col_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX col_refs_new_col_id_idx ON macrostrat.col_refs USING btree (col_id); + + +-- +-- Name: col_refs_new_ref_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX col_refs_new_ref_id_idx ON macrostrat.col_refs USING btree (ref_id); + + +-- +-- Name: cols_new_col_group_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX cols_new_col_group_id_idx1 ON macrostrat.cols USING btree (col_group_id); + + +-- +-- Name: cols_new_coordinate_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX cols_new_coordinate_idx1 ON macrostrat.cols USING gist (coordinate); + + +-- +-- Name: cols_new_poly_geom_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX cols_new_poly_geom_idx1 ON macrostrat.cols USING gist (poly_geom); + + +-- +-- Name: cols_new_project_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX cols_new_project_id_idx1 ON macrostrat.cols USING btree (project_id); + + +-- +-- Name: cols_new_status_code_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX cols_new_status_code_idx1 ON macrostrat.cols USING btree (status_code); + + +-- +-- Name: concepts_places_new_concept_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX concepts_places_new_concept_id_idx ON macrostrat.concepts_places USING btree (concept_id); + + +-- +-- Name: concepts_places_new_place_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX concepts_places_new_place_id_idx ON macrostrat.concepts_places USING btree (place_id); + + +-- +-- Name: intervals_new_age_bottom_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX intervals_new_age_bottom_idx ON macrostrat.intervals USING btree (age_bottom); + + +-- +-- Name: intervals_new_age_top_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX intervals_new_age_top_idx ON macrostrat.intervals USING btree (age_top); + + +-- +-- Name: intervals_new_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX intervals_new_id_idx ON macrostrat.intervals USING btree (id); + + +-- +-- Name: intervals_new_interval_name_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX intervals_new_interval_name_idx ON macrostrat.intervals USING btree (interval_name); + + +-- +-- Name: intervals_new_interval_type_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX intervals_new_interval_type_idx ON macrostrat.intervals USING btree (interval_type); + + +-- +-- Name: lith_atts_new_att_type_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX lith_atts_new_att_type_idx1 ON macrostrat.lith_atts USING btree (att_type); + + +-- +-- Name: lith_atts_new_lith_att_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX lith_atts_new_lith_att_idx1 ON macrostrat.lith_atts USING btree (lith_att); + + +-- +-- Name: liths_new_lith_class_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX liths_new_lith_class_idx ON macrostrat.liths USING btree (lith_class); + + +-- +-- Name: liths_new_lith_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX liths_new_lith_idx ON macrostrat.liths USING btree (lith); + + +-- +-- Name: liths_new_lith_type_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX liths_new_lith_type_idx ON macrostrat.liths USING btree (lith_type); + + +-- +-- Name: lookup_strat_names_new_bed_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX lookup_strat_names_new_bed_id_idx1 ON macrostrat.lookup_strat_names USING btree (bed_id); + + +-- +-- Name: lookup_strat_names_new_concept_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX lookup_strat_names_new_concept_id_idx1 ON macrostrat.lookup_strat_names USING btree (concept_id); + + +-- +-- Name: lookup_strat_names_new_fm_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX lookup_strat_names_new_fm_id_idx1 ON macrostrat.lookup_strat_names USING btree (fm_id); + + +-- +-- Name: lookup_strat_names_new_gp_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX lookup_strat_names_new_gp_id_idx1 ON macrostrat.lookup_strat_names USING btree (gp_id); + + +-- +-- Name: lookup_strat_names_new_mbr_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX lookup_strat_names_new_mbr_id_idx1 ON macrostrat.lookup_strat_names USING btree (mbr_id); + + +-- +-- Name: lookup_strat_names_new_sgp_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX lookup_strat_names_new_sgp_id_idx1 ON macrostrat.lookup_strat_names USING btree (sgp_id); + + +-- +-- Name: lookup_strat_names_new_strat_name_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX lookup_strat_names_new_strat_name_id_idx1 ON macrostrat.lookup_strat_names USING btree (strat_name_id); + + +-- +-- Name: lookup_strat_names_new_strat_name_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX lookup_strat_names_new_strat_name_idx1 ON macrostrat.lookup_strat_names USING btree (strat_name); + + +-- +-- Name: lookup_unit_attrs_api_new_unit_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX lookup_unit_attrs_api_new_unit_id_idx1 ON macrostrat.lookup_unit_attrs_api USING btree (unit_id); + + +-- +-- Name: lookup_unit_intervals_new_best_interval_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX lookup_unit_intervals_new_best_interval_id_idx ON macrostrat.lookup_unit_intervals USING btree (best_interval_id); + + +-- +-- Name: lookup_unit_intervals_new_unit_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX lookup_unit_intervals_new_unit_id_idx ON macrostrat.lookup_unit_intervals USING btree (unit_id); + + +-- +-- Name: lookup_unit_liths_new_unit_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX lookup_unit_liths_new_unit_id_idx ON macrostrat.lookup_unit_liths USING btree (unit_id); + + +-- +-- Name: lookup_units_new_b_int_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX lookup_units_new_b_int_idx1 ON macrostrat.lookup_units USING btree (b_int); + + +-- +-- Name: lookup_units_new_project_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX lookup_units_new_project_id_idx1 ON macrostrat.lookup_units USING btree (project_id); + + +-- +-- Name: lookup_units_new_t_int_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX lookup_units_new_t_int_idx1 ON macrostrat.lookup_units USING btree (t_int); + + +-- +-- Name: measurements_new_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX measurements_new_id_idx ON macrostrat.measurements USING btree (id); + + +-- +-- Name: measurements_new_measurement_class_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX measurements_new_measurement_class_idx ON macrostrat.measurements USING btree (measurement_class); + + +-- +-- Name: measurements_new_measurement_type_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX measurements_new_measurement_type_idx ON macrostrat.measurements USING btree (measurement_type); + + +-- +-- Name: measuremeta_new_lith_att_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX measuremeta_new_lith_att_id_idx ON macrostrat.measuremeta USING btree (lith_att_id); + + +-- +-- Name: measuremeta_new_lith_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX measuremeta_new_lith_id_idx ON macrostrat.measuremeta USING btree (lith_id); + + +-- +-- Name: measuremeta_new_ref_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX measuremeta_new_ref_id_idx ON macrostrat.measuremeta USING btree (ref_id); + + +-- +-- Name: measures_new_measurement_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX measures_new_measurement_id_idx ON macrostrat.measures USING btree (measurement_id); + + +-- +-- Name: measures_new_measuremeta_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX measures_new_measuremeta_id_idx ON macrostrat.measures USING btree (measuremeta_id); + + +-- +-- Name: pbdb_collections_new_collection_no_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX pbdb_collections_new_collection_no_idx ON macrostrat.pbdb_collections USING btree (collection_no); + + +-- +-- Name: pbdb_collections_new_early_age_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX pbdb_collections_new_early_age_idx ON macrostrat.pbdb_collections USING btree (early_age); + + +-- +-- Name: pbdb_collections_new_geom_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX pbdb_collections_new_geom_idx ON macrostrat.pbdb_collections USING gist (geom); + + +-- +-- Name: pbdb_collections_new_late_age_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX pbdb_collections_new_late_age_idx ON macrostrat.pbdb_collections USING btree (late_age); + + +-- +-- Name: places_new_geom_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX places_new_geom_idx ON macrostrat.places USING gist (geom); + + +-- +-- Name: projects_new_project_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX projects_new_project_idx ON macrostrat.projects USING btree (project); + + +-- +-- Name: projects_new_timescale_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX projects_new_timescale_id_idx ON macrostrat.projects USING btree (timescale_id); + + +-- +-- Name: refs_new_rgeom_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX refs_new_rgeom_idx1 ON macrostrat.refs USING gist (rgeom); + + +-- +-- Name: sections_new_col_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX sections_new_col_id_idx ON macrostrat.sections USING btree (col_id); + + +-- +-- Name: sections_new_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX sections_new_id_idx ON macrostrat.sections USING btree (id); + + +-- +-- Name: strat_name_footprints_new_geom_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX strat_name_footprints_new_geom_idx ON macrostrat.strat_name_footprints USING gist (geom); + + +-- +-- Name: strat_name_footprints_new_strat_name_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX strat_name_footprints_new_strat_name_id_idx ON macrostrat.strat_name_footprints USING btree (strat_name_id); + + +-- +-- Name: strat_names_meta_new_b_int_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX strat_names_meta_new_b_int_idx1 ON macrostrat.strat_names_meta USING btree (b_int); + + +-- +-- Name: strat_names_meta_new_interval_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX strat_names_meta_new_interval_id_idx1 ON macrostrat.strat_names_meta USING btree (interval_id); + + +-- +-- Name: strat_names_meta_new_ref_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX strat_names_meta_new_ref_id_idx1 ON macrostrat.strat_names_meta USING btree (ref_id); + + +-- +-- Name: strat_names_meta_new_t_int_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX strat_names_meta_new_t_int_idx1 ON macrostrat.strat_names_meta USING btree (t_int); + + +-- +-- Name: strat_names_new_concept_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX strat_names_new_concept_id_idx ON macrostrat.strat_names USING btree (concept_id); + + +-- +-- Name: strat_names_new_rank_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX strat_names_new_rank_idx ON macrostrat.strat_names USING btree (rank); + + +-- +-- Name: strat_names_new_ref_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX strat_names_new_ref_id_idx ON macrostrat.strat_names USING btree (ref_id); + + +-- +-- Name: strat_names_new_strat_name_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX strat_names_new_strat_name_idx ON macrostrat.strat_names USING btree (strat_name); + + +-- +-- Name: strat_names_places_new_place_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX strat_names_places_new_place_id_idx ON macrostrat.strat_names_places USING btree (place_id); + + +-- +-- Name: strat_names_places_new_strat_name_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX strat_names_places_new_strat_name_id_idx ON macrostrat.strat_names_places USING btree (strat_name_id); + + +-- +-- Name: strat_tree_new_child_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX strat_tree_new_child_idx1 ON macrostrat.strat_tree USING btree (child); + + +-- +-- Name: strat_tree_new_parent_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX strat_tree_new_parent_idx1 ON macrostrat.strat_tree USING btree (parent); + + +-- +-- Name: strat_tree_new_ref_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX strat_tree_new_ref_id_idx1 ON macrostrat.strat_tree USING btree (ref_id); + + +-- +-- Name: timescales_intervals_new_interval_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX timescales_intervals_new_interval_id_idx ON macrostrat.timescales_intervals USING btree (interval_id); + + +-- +-- Name: timescales_intervals_new_timescale_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX timescales_intervals_new_timescale_id_idx ON macrostrat.timescales_intervals USING btree (timescale_id); + + +-- +-- Name: timescales_new_ref_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX timescales_new_ref_id_idx1 ON macrostrat.timescales USING btree (ref_id); + + +-- +-- Name: timescales_new_timescale_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX timescales_new_timescale_idx1 ON macrostrat.timescales USING btree (timescale); + + +-- +-- Name: unit_econs_new_econ_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX unit_econs_new_econ_id_idx1 ON macrostrat.unit_econs USING btree (econ_id); + + +-- +-- Name: unit_econs_new_ref_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX unit_econs_new_ref_id_idx1 ON macrostrat.unit_econs USING btree (ref_id); + + +-- +-- Name: unit_econs_new_unit_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX unit_econs_new_unit_id_idx1 ON macrostrat.unit_econs USING btree (unit_id); + + +-- +-- Name: unit_environs_new_environ_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX unit_environs_new_environ_id_idx1 ON macrostrat.unit_environs USING btree (environ_id); + + +-- +-- Name: unit_environs_new_ref_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX unit_environs_new_ref_id_idx1 ON macrostrat.unit_environs USING btree (ref_id); + + +-- +-- Name: unit_environs_new_unit_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX unit_environs_new_unit_id_idx1 ON macrostrat.unit_environs USING btree (unit_id); + + +-- +-- Name: unit_lith_atts_new_lith_att_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX unit_lith_atts_new_lith_att_id_idx1 ON macrostrat.unit_lith_atts USING btree (lith_att_id); + + +-- +-- Name: unit_lith_atts_new_ref_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX unit_lith_atts_new_ref_id_idx1 ON macrostrat.unit_lith_atts USING btree (ref_id); + + +-- +-- Name: unit_lith_atts_new_unit_lith_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX unit_lith_atts_new_unit_lith_id_idx1 ON macrostrat.unit_lith_atts USING btree (unit_lith_id); + + +-- +-- Name: unit_liths_new_lith_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX unit_liths_new_lith_id_idx ON macrostrat.unit_liths USING btree (lith_id); + + +-- +-- Name: unit_liths_new_ref_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX unit_liths_new_ref_id_idx ON macrostrat.unit_liths USING btree (ref_id); + + +-- +-- Name: unit_liths_new_unit_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX unit_liths_new_unit_id_idx ON macrostrat.unit_liths USING btree (unit_id); + + +-- +-- Name: unit_measures_new_measuremeta_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX unit_measures_new_measuremeta_id_idx ON macrostrat.unit_measures USING btree (measuremeta_id); + + +-- +-- Name: unit_measures_new_strat_name_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX unit_measures_new_strat_name_id_idx ON macrostrat.unit_measures USING btree (strat_name_id); + + +-- +-- Name: unit_measures_new_unit_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX unit_measures_new_unit_id_idx ON macrostrat.unit_measures USING btree (unit_id); + + +-- +-- Name: unit_strat_names_new_strat_name_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX unit_strat_names_new_strat_name_id_idx ON macrostrat.unit_strat_names USING btree (strat_name_id); + + +-- +-- Name: unit_strat_names_new_unit_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX unit_strat_names_new_unit_id_idx ON macrostrat.unit_strat_names USING btree (unit_id); + + +-- +-- Name: units_new_col_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX units_new_col_id_idx ON macrostrat.units USING btree (col_id); + + +-- +-- Name: units_new_color_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX units_new_color_idx ON macrostrat.units USING btree (color); + + +-- +-- Name: units_new_section_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX units_new_section_id_idx ON macrostrat.units USING btree (section_id); + + +-- +-- Name: units_new_strat_name_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX units_new_strat_name_idx ON macrostrat.units USING btree (strat_name); + + +-- +-- Name: units_sections_new_col_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX units_sections_new_col_id_idx1 ON macrostrat.units_sections USING btree (col_id); + + +-- +-- Name: units_sections_new_section_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX units_sections_new_section_id_idx1 ON macrostrat.units_sections USING btree (section_id); + + +-- +-- Name: units_sections_new_unit_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX units_sections_new_unit_id_idx1 ON macrostrat.units_sections USING btree (unit_id); + + +-- +-- Name: col_group_view _RETURN; Type: RULE; Schema: macrostrat_api; Owner: api_user +-- + +CREATE OR REPLACE VIEW macrostrat_api.col_group_view AS + SELECT cg.id, + cg.col_group, + cg.col_group_long, + cg.project_id, + json_agg(json_build_object('col_id', c.id, 'status_code', c.status_code, 'col_number', c.col, 'col_name', c.col_name)) AS cols + FROM (macrostrat.col_groups cg + LEFT JOIN macrostrat.cols c ON ((c.col_group_id = cg.id))) + GROUP BY cg.id, c.project_id; + + +-- +-- Name: users encrypt_pass; Type: TRIGGER; Schema: auth; Owner: postgres +-- + +CREATE TRIGGER encrypt_pass BEFORE INSERT OR UPDATE ON auth.users FOR EACH ROW EXECUTE FUNCTION auth.encrypt_pass(); + + +-- +-- Name: users ensure_user_role_exists; Type: TRIGGER; Schema: auth; Owner: postgres +-- + +CREATE TRIGGER ensure_user_role_exists BEFORE INSERT OR UPDATE ON auth.users FOR EACH ROW EXECUTE FUNCTION auth.check_role_exists(); + + +-- +-- Name: projects user_projects; Type: TRIGGER; Schema: macrostrat; Owner: postgres +-- + +CREATE TRIGGER user_projects AFTER INSERT ON macrostrat.projects FOR EACH ROW EXECUTE FUNCTION auth.user_project_insert(); + + +-- +-- Name: user_projects user_projects_project_fkey; Type: FK CONSTRAINT; Schema: auth; Owner: postgres +-- + +ALTER TABLE ONLY auth.user_projects + ADD CONSTRAINT user_projects_project_fkey FOREIGN KEY (project) REFERENCES macrostrat.projects(id); + + +-- +-- Name: user_projects user_projects_role_id_fkey; Type: FK CONSTRAINT; Schema: auth; Owner: postgres +-- + +ALTER TABLE ONLY auth.user_projects + ADD CONSTRAINT user_projects_role_id_fkey FOREIGN KEY (role_id) REFERENCES auth.data_roles(id); + + +-- +-- Name: user_projects user_projects_user__fkey; Type: FK CONSTRAINT; Schema: auth; Owner: postgres +-- + +ALTER TABLE ONLY auth.user_projects + ADD CONSTRAINT user_projects_user__fkey FOREIGN KEY (user_) REFERENCES auth.users(id); + + +-- +-- Name: col_areas col_areas_col_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.col_areas + ADD CONSTRAINT col_areas_col_id_fkey FOREIGN KEY (col_id) REFERENCES macrostrat.cols(id) ON DELETE CASCADE; + + +-- +-- Name: col_areas col_areas_col_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.col_areas + ADD CONSTRAINT col_areas_col_id_fkey1 FOREIGN KEY (col_id) REFERENCES macrostrat.cols(id) ON DELETE CASCADE; + + +-- +-- Name: col_groups col_groups_project_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.col_groups + ADD CONSTRAINT col_groups_project_id_fkey FOREIGN KEY (project_id) REFERENCES macrostrat.projects(id); + + +-- +-- Name: col_refs col_refs_col_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.col_refs + ADD CONSTRAINT col_refs_col_id_fkey FOREIGN KEY (col_id) REFERENCES macrostrat.cols(id) ON DELETE CASCADE; + + +-- +-- Name: col_refs col_refs_col_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.col_refs + ADD CONSTRAINT col_refs_col_id_fkey1 FOREIGN KEY (col_id) REFERENCES macrostrat.cols(id) ON DELETE CASCADE; + + +-- +-- Name: col_refs col_refs_ref_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.col_refs + ADD CONSTRAINT col_refs_ref_id_fkey FOREIGN KEY (ref_id) REFERENCES macrostrat.refs(id) ON DELETE CASCADE; + + +-- +-- Name: col_refs col_refs_ref_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.col_refs + ADD CONSTRAINT col_refs_ref_id_fkey1 FOREIGN KEY (ref_id) REFERENCES macrostrat.refs(id) ON DELETE CASCADE; + + +-- +-- Name: cols cols_col_group_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.cols + ADD CONSTRAINT cols_col_group_id_fkey FOREIGN KEY (col_group_id) REFERENCES macrostrat.col_groups(id) ON DELETE CASCADE; + + +-- +-- Name: cols cols_col_group_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.cols + ADD CONSTRAINT cols_col_group_id_fkey1 FOREIGN KEY (col_group_id) REFERENCES macrostrat.col_groups(id) ON DELETE CASCADE; + + +-- +-- Name: cols cols_project_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.cols + ADD CONSTRAINT cols_project_id_fkey FOREIGN KEY (project_id) REFERENCES macrostrat.projects(id) ON DELETE CASCADE; + + +-- +-- Name: cols cols_project_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.cols + ADD CONSTRAINT cols_project_id_fkey1 FOREIGN KEY (project_id) REFERENCES macrostrat.projects(id) ON DELETE CASCADE; + + +-- +-- Name: concepts_places concepts_places_place_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.concepts_places + ADD CONSTRAINT concepts_places_place_id_fkey FOREIGN KEY (place_id) REFERENCES macrostrat.places(place_id) ON DELETE CASCADE; + + +-- +-- Name: concepts_places concepts_places_place_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.concepts_places + ADD CONSTRAINT concepts_places_place_id_fkey1 FOREIGN KEY (place_id) REFERENCES macrostrat.places(place_id) ON DELETE CASCADE; + + +-- +-- Name: projects projects_timescale_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.projects + ADD CONSTRAINT projects_timescale_id_fkey FOREIGN KEY (timescale_id) REFERENCES macrostrat.timescales(id) ON DELETE CASCADE; + + +-- +-- Name: projects projects_timescale_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.projects + ADD CONSTRAINT projects_timescale_id_fkey1 FOREIGN KEY (timescale_id) REFERENCES macrostrat.timescales(id) ON DELETE CASCADE; + + +-- +-- Name: sections sections_col_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.sections + ADD CONSTRAINT sections_col_id_fkey FOREIGN KEY (col_id) REFERENCES macrostrat.cols(id) ON DELETE CASCADE; + + +-- +-- Name: sections sections_col_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.sections + ADD CONSTRAINT sections_col_id_fkey1 FOREIGN KEY (col_id) REFERENCES macrostrat.cols(id) ON DELETE CASCADE; + + +-- +-- Name: strat_names_places strat_names_places_place_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.strat_names_places + ADD CONSTRAINT strat_names_places_place_id_fkey FOREIGN KEY (place_id) REFERENCES macrostrat.places(place_id) ON DELETE CASCADE; + + +-- +-- Name: strat_names_places strat_names_places_place_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.strat_names_places + ADD CONSTRAINT strat_names_places_place_id_fkey1 FOREIGN KEY (place_id) REFERENCES macrostrat.places(place_id) ON DELETE CASCADE; + + +-- +-- Name: strat_names_places strat_names_places_strat_name_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.strat_names_places + ADD CONSTRAINT strat_names_places_strat_name_id_fkey FOREIGN KEY (strat_name_id) REFERENCES macrostrat.strat_names(id) ON DELETE CASCADE; + + +-- +-- Name: strat_names_places strat_names_places_strat_name_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.strat_names_places + ADD CONSTRAINT strat_names_places_strat_name_id_fkey1 FOREIGN KEY (strat_name_id) REFERENCES macrostrat.strat_names(id) ON DELETE CASCADE; + + +-- +-- Name: strat_tree strat_tree_child_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.strat_tree + ADD CONSTRAINT strat_tree_child_fkey FOREIGN KEY (child) REFERENCES macrostrat.strat_names(id) ON DELETE CASCADE; + + +-- +-- Name: strat_tree strat_tree_child_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.strat_tree + ADD CONSTRAINT strat_tree_child_fkey1 FOREIGN KEY (child) REFERENCES macrostrat.strat_names(id) ON DELETE CASCADE; + + +-- +-- Name: strat_tree strat_tree_parent_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.strat_tree + ADD CONSTRAINT strat_tree_parent_fkey FOREIGN KEY (parent) REFERENCES macrostrat.strat_names(id) ON DELETE CASCADE; + + +-- +-- Name: strat_tree strat_tree_parent_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.strat_tree + ADD CONSTRAINT strat_tree_parent_fkey1 FOREIGN KEY (parent) REFERENCES macrostrat.strat_names(id) ON DELETE CASCADE; + + +-- +-- Name: strat_tree strat_tree_ref_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.strat_tree + ADD CONSTRAINT strat_tree_ref_id_fkey FOREIGN KEY (ref_id) REFERENCES macrostrat.refs(id) ON DELETE CASCADE; + + +-- +-- Name: strat_tree strat_tree_ref_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.strat_tree + ADD CONSTRAINT strat_tree_ref_id_fkey1 FOREIGN KEY (ref_id) REFERENCES macrostrat.refs(id) ON DELETE CASCADE; + + +-- +-- Name: timescales_intervals timescales_intervals_interval_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.timescales_intervals + ADD CONSTRAINT timescales_intervals_interval_id_fkey FOREIGN KEY (interval_id) REFERENCES macrostrat.intervals(id) ON DELETE CASCADE; + + +-- +-- Name: timescales_intervals timescales_intervals_interval_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.timescales_intervals + ADD CONSTRAINT timescales_intervals_interval_id_fkey1 FOREIGN KEY (interval_id) REFERENCES macrostrat.intervals(id) ON DELETE CASCADE; + + +-- +-- Name: timescales_intervals timescales_intervals_timescale_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.timescales_intervals + ADD CONSTRAINT timescales_intervals_timescale_id_fkey FOREIGN KEY (timescale_id) REFERENCES macrostrat.timescales(id) ON DELETE CASCADE; + + +-- +-- Name: timescales_intervals timescales_intervals_timescale_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.timescales_intervals + ADD CONSTRAINT timescales_intervals_timescale_id_fkey1 FOREIGN KEY (timescale_id) REFERENCES macrostrat.timescales(id) ON DELETE CASCADE; + + +-- +-- Name: unit_econs unit_econs_econ_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_econs + ADD CONSTRAINT unit_econs_econ_id_fkey FOREIGN KEY (econ_id) REFERENCES macrostrat.econs(id) ON DELETE CASCADE; + + +-- +-- Name: unit_econs unit_econs_econ_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_econs + ADD CONSTRAINT unit_econs_econ_id_fkey1 FOREIGN KEY (econ_id) REFERENCES macrostrat.econs(id) ON DELETE CASCADE; + + +-- +-- Name: unit_econs unit_econs_ref_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_econs + ADD CONSTRAINT unit_econs_ref_id_fkey FOREIGN KEY (ref_id) REFERENCES macrostrat.refs(id) ON DELETE CASCADE; + + +-- +-- Name: unit_econs unit_econs_ref_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_econs + ADD CONSTRAINT unit_econs_ref_id_fkey1 FOREIGN KEY (ref_id) REFERENCES macrostrat.refs(id) ON DELETE CASCADE; + + +-- +-- Name: unit_econs unit_econs_unit_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_econs + ADD CONSTRAINT unit_econs_unit_id_fkey FOREIGN KEY (unit_id) REFERENCES macrostrat.units(id) ON DELETE CASCADE; + + +-- +-- Name: unit_econs unit_econs_unit_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_econs + ADD CONSTRAINT unit_econs_unit_id_fkey1 FOREIGN KEY (unit_id) REFERENCES macrostrat.units(id) ON DELETE CASCADE; + + +-- +-- Name: unit_environs unit_environs_environ_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_environs + ADD CONSTRAINT unit_environs_environ_id_fkey FOREIGN KEY (environ_id) REFERENCES macrostrat.environs(id) ON DELETE CASCADE; + + +-- +-- Name: unit_environs unit_environs_environ_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_environs + ADD CONSTRAINT unit_environs_environ_id_fkey1 FOREIGN KEY (environ_id) REFERENCES macrostrat.environs(id) ON DELETE CASCADE; + + +-- +-- Name: unit_environs unit_environs_ref_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_environs + ADD CONSTRAINT unit_environs_ref_id_fkey FOREIGN KEY (ref_id) REFERENCES macrostrat.refs(id) ON DELETE CASCADE; + + +-- +-- Name: unit_environs unit_environs_ref_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_environs + ADD CONSTRAINT unit_environs_ref_id_fkey1 FOREIGN KEY (ref_id) REFERENCES macrostrat.refs(id) ON DELETE CASCADE; + + +-- +-- Name: unit_environs unit_environs_unit_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_environs + ADD CONSTRAINT unit_environs_unit_id_fkey FOREIGN KEY (unit_id) REFERENCES macrostrat.units(id) ON DELETE CASCADE; + + +-- +-- Name: unit_environs unit_environs_unit_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_environs + ADD CONSTRAINT unit_environs_unit_id_fkey1 FOREIGN KEY (unit_id) REFERENCES macrostrat.units(id) ON DELETE CASCADE; + + +-- +-- Name: unit_lith_atts unit_lith_atts_lith_att_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_lith_atts + ADD CONSTRAINT unit_lith_atts_lith_att_id_fkey FOREIGN KEY (lith_att_id) REFERENCES macrostrat.lith_atts(id) ON DELETE CASCADE; + + +-- +-- Name: unit_lith_atts unit_lith_atts_lith_att_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_lith_atts + ADD CONSTRAINT unit_lith_atts_lith_att_id_fkey1 FOREIGN KEY (lith_att_id) REFERENCES macrostrat.lith_atts(id) ON DELETE CASCADE; + + +-- +-- Name: unit_lith_atts unit_lith_atts_unit_lith_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_lith_atts + ADD CONSTRAINT unit_lith_atts_unit_lith_id_fkey FOREIGN KEY (unit_lith_id) REFERENCES macrostrat.unit_liths(id) ON DELETE CASCADE; + + +-- +-- Name: unit_lith_atts unit_lith_atts_unit_lith_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_lith_atts + ADD CONSTRAINT unit_lith_atts_unit_lith_id_fkey1 FOREIGN KEY (unit_lith_id) REFERENCES macrostrat.unit_liths(id) ON DELETE CASCADE; + + +-- +-- Name: unit_liths unit_liths_lith_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_liths + ADD CONSTRAINT unit_liths_lith_id_fkey FOREIGN KEY (lith_id) REFERENCES macrostrat.liths(id) ON DELETE CASCADE; + + +-- +-- Name: unit_liths unit_liths_lith_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_liths + ADD CONSTRAINT unit_liths_lith_id_fkey1 FOREIGN KEY (lith_id) REFERENCES macrostrat.liths(id) ON DELETE CASCADE; + + +-- +-- Name: unit_liths unit_liths_unit_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_liths + ADD CONSTRAINT unit_liths_unit_id_fkey FOREIGN KEY (unit_id) REFERENCES macrostrat.units(id) ON DELETE CASCADE; + + +-- +-- Name: unit_liths unit_liths_unit_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_liths + ADD CONSTRAINT unit_liths_unit_id_fkey1 FOREIGN KEY (unit_id) REFERENCES macrostrat.units(id) ON DELETE CASCADE; + + +-- +-- Name: unit_strat_names unit_strat_names_strat_name_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_strat_names + ADD CONSTRAINT unit_strat_names_strat_name_id_fkey FOREIGN KEY (strat_name_id) REFERENCES macrostrat.strat_names(id) ON DELETE CASCADE; + + +-- +-- Name: unit_strat_names unit_strat_names_strat_name_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_strat_names + ADD CONSTRAINT unit_strat_names_strat_name_id_fkey1 FOREIGN KEY (strat_name_id) REFERENCES macrostrat.strat_names(id) ON DELETE CASCADE; + + +-- +-- Name: unit_strat_names unit_strat_names_unit_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_strat_names + ADD CONSTRAINT unit_strat_names_unit_id_fkey FOREIGN KEY (unit_id) REFERENCES macrostrat.units(id) ON DELETE CASCADE; + + +-- +-- Name: unit_strat_names unit_strat_names_unit_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_strat_names + ADD CONSTRAINT unit_strat_names_unit_id_fkey1 FOREIGN KEY (unit_id) REFERENCES macrostrat.units(id) ON DELETE CASCADE; + + +-- +-- Name: units units_col_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.units + ADD CONSTRAINT units_col_id_fkey FOREIGN KEY (col_id) REFERENCES macrostrat.cols(id) ON DELETE CASCADE; + + +-- +-- Name: units units_col_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.units + ADD CONSTRAINT units_col_id_fkey1 FOREIGN KEY (col_id) REFERENCES macrostrat.cols(id) ON DELETE CASCADE; + + +-- +-- Name: units units_fo_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.units + ADD CONSTRAINT units_fo_fkey FOREIGN KEY (fo) REFERENCES macrostrat.intervals(id) ON DELETE CASCADE; + + +-- +-- Name: units units_fo_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.units + ADD CONSTRAINT units_fo_fkey1 FOREIGN KEY (fo) REFERENCES macrostrat.intervals(id) ON DELETE CASCADE; + + +-- +-- Name: units units_lo_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.units + ADD CONSTRAINT units_lo_fkey FOREIGN KEY (lo) REFERENCES macrostrat.intervals(id) ON DELETE CASCADE; + + +-- +-- Name: units units_lo_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.units + ADD CONSTRAINT units_lo_fkey1 FOREIGN KEY (lo) REFERENCES macrostrat.intervals(id) ON DELETE CASCADE; + + +-- +-- Name: units units_section_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.units + ADD CONSTRAINT units_section_id_fkey FOREIGN KEY (section_id) REFERENCES macrostrat.sections(id) ON DELETE CASCADE; + + +-- +-- Name: units units_section_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.units + ADD CONSTRAINT units_section_id_fkey1 FOREIGN KEY (section_id) REFERENCES macrostrat.sections(id) ON DELETE CASCADE; + + +-- +-- Name: units units_strat_name_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.units + ADD CONSTRAINT units_strat_name_id_fkey FOREIGN KEY (strat_name_id) REFERENCES macrostrat.strat_names(id) ON DELETE CASCADE; + + +-- +-- Name: data_roles; Type: ROW SECURITY; Schema: auth; Owner: postgres +-- + +ALTER TABLE auth.data_roles ENABLE ROW LEVEL SECURITY; + +-- +-- Name: data_roles data_roles_insert; Type: POLICY; Schema: auth; Owner: postgres +-- + +CREATE POLICY data_roles_insert ON auth.data_roles FOR INSERT WITH CHECK ((role <> ALL (ARRAY['reader'::text, 'writer'::text, 'deleter'::text, 'manager'::text]))); + + +-- +-- Name: data_roles data_roles_select; Type: POLICY; Schema: auth; Owner: postgres +-- + +CREATE POLICY data_roles_select ON auth.data_roles FOR SELECT USING (true); + + +-- +-- Name: data_roles data_roles_update; Type: POLICY; Schema: auth; Owner: postgres +-- + +CREATE POLICY data_roles_update ON auth.data_roles FOR UPDATE USING ((role <> ALL (ARRAY['reader'::text, 'writer'::text, 'deleter'::text, 'manager'::text]))); + + +-- +-- Name: user_projects manager_projects; Type: POLICY; Schema: auth; Owner: postgres +-- + +CREATE POLICY manager_projects ON auth.user_projects USING ((project IN ( SELECT current_user_projects.project + FROM macrostrat_api.current_user_projects() current_user_projects(project, role) + WHERE (current_user_projects.role = 'manager'::text)))) WITH CHECK ((project IN ( SELECT current_user_projects.project + FROM macrostrat_api.current_user_projects() current_user_projects(project, role) + WHERE (current_user_projects.role = 'manager'::text)))); + + +-- +-- Name: users secure_users; Type: POLICY; Schema: auth; Owner: postgres +-- + +CREATE POLICY secure_users ON auth.users USING ((username = macrostrat_api.get_username())) WITH CHECK ((username = macrostrat_api.get_username())); + + +-- +-- Name: user_projects; Type: ROW SECURITY; Schema: auth; Owner: postgres +-- + +ALTER TABLE auth.user_projects ENABLE ROW LEVEL SECURITY; + +-- +-- Name: users; Type: ROW SECURITY; Schema: auth; Owner: postgres +-- + +ALTER TABLE auth.users ENABLE ROW LEVEL SECURITY; + +-- +-- Name: col_groups col_group_upsert; Type: POLICY; Schema: macrostrat; Owner: postgres +-- + +CREATE POLICY col_group_upsert ON macrostrat.col_groups WITH CHECK ((project_id IN ( SELECT current_user_projects.project + FROM macrostrat_api.current_user_projects() current_user_projects(project, role) + WHERE (current_user_projects.role = ANY (ARRAY['writer'::text, 'deleter'::text, 'manager'::text]))))); + + +-- +-- Name: col_groups; Type: ROW SECURITY; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE macrostrat.col_groups ENABLE ROW LEVEL SECURITY; + +-- +-- Name: col_groups col_groups_select; Type: POLICY; Schema: macrostrat; Owner: postgres +-- + +CREATE POLICY col_groups_select ON macrostrat.col_groups FOR SELECT USING ((project_id IN ( SELECT current_user_projects.project + FROM macrostrat_api.current_user_projects() current_user_projects(project, role) + WHERE (current_user_projects.role = ANY (ARRAY['reader'::text, 'writer'::text, 'deleter'::text, 'manager'::text]))))); + + +-- +-- Name: cols; Type: ROW SECURITY; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE macrostrat.cols ENABLE ROW LEVEL SECURITY; + +-- +-- Name: cols cols_select; Type: POLICY; Schema: macrostrat; Owner: postgres +-- + +CREATE POLICY cols_select ON macrostrat.cols FOR SELECT USING ((project_id IN ( SELECT current_user_projects.project + FROM macrostrat_api.current_user_projects() current_user_projects(project, role)))); + + +-- +-- Name: cols cols_upsert; Type: POLICY; Schema: macrostrat; Owner: postgres +-- + +CREATE POLICY cols_upsert ON macrostrat.cols WITH CHECK ((project_id IN ( SELECT current_user_projects.project + FROM macrostrat_api.current_user_projects() current_user_projects(project, role) + WHERE (current_user_projects.role = ANY (ARRAY['writer'::text, 'deleter'::text, 'manager'::text]))))); + + +-- +-- Name: projects; Type: ROW SECURITY; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE macrostrat.projects ENABLE ROW LEVEL SECURITY; + +-- +-- Name: projects projects_; Type: POLICY; Schema: macrostrat; Owner: postgres +-- + +CREATE POLICY projects_ ON macrostrat.projects FOR SELECT USING ((id IN ( SELECT current_user_projects.project + FROM macrostrat_api.current_user_projects() current_user_projects(project, role) + WHERE (current_user_projects.role = ANY (ARRAY['reader'::text, 'writer'::text, 'deleter'::text, 'manager'::text]))))); + + +-- +-- Name: projects projects_insert; Type: POLICY; Schema: macrostrat; Owner: postgres +-- + +CREATE POLICY projects_insert ON macrostrat.projects FOR INSERT WITH CHECK (true); + + +-- +-- Name: projects projects_update; Type: POLICY; Schema: macrostrat; Owner: postgres +-- + +CREATE POLICY projects_update ON macrostrat.projects FOR UPDATE WITH CHECK ((id IN ( SELECT current_user_projects.project + FROM macrostrat_api.current_user_projects() current_user_projects(project, role) + WHERE (current_user_projects.role = ANY (ARRAY['writer'::text, 'deleter'::text, 'manager'::text]))))); + + +-- +-- Name: units; Type: ROW SECURITY; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE macrostrat.units ENABLE ROW LEVEL SECURITY; + +-- +-- Name: units units_select; Type: POLICY; Schema: macrostrat; Owner: postgres +-- + +CREATE POLICY units_select ON macrostrat.units FOR SELECT USING ((col_id IN ( SELECT c.id + FROM macrostrat.cols c + WHERE (c.project_id IN ( SELECT current_user_projects.project + FROM macrostrat_api.current_user_projects() current_user_projects(project, role)))))); + + +-- +-- Name: units units_upsert; Type: POLICY; Schema: macrostrat; Owner: postgres +-- + +CREATE POLICY units_upsert ON macrostrat.units WITH CHECK ((col_id IN ( SELECT c.id + FROM macrostrat.cols c + WHERE (c.project_id IN ( SELECT current_user_projects.project + FROM macrostrat_api.current_user_projects() current_user_projects(project, role) + WHERE (current_user_projects.role = ANY (ARRAY['writer'::text, 'deleter'::text, 'manager'::text]))))))); + + +-- +-- Name: SCHEMA auth; Type: ACL; Schema: -; Owner: postgres +-- + +GRANT USAGE ON SCHEMA auth TO api_user; + + +-- +-- Name: SCHEMA macrostrat; Type: ACL; Schema: -; Owner: postgres +-- + +GRANT USAGE ON SCHEMA macrostrat TO api_user; + + +-- +-- Name: SCHEMA macrostrat_api; Type: ACL; Schema: -; Owner: postgres +-- + +GRANT USAGE ON SCHEMA macrostrat_api TO api_user; +GRANT USAGE ON SCHEMA macrostrat_api TO anon; +GRANT USAGE ON SCHEMA macrostrat_api TO authenticator; + + +-- +-- Name: FUNCTION create_user(firstname text, lastname text, pass text, username text); Type: ACL; Schema: macrostrat_api; Owner: postgres +-- + +GRANT ALL ON FUNCTION macrostrat_api.create_user(firstname text, lastname text, pass text, username text) TO authenticator; +GRANT ALL ON FUNCTION macrostrat_api.create_user(firstname text, lastname text, pass text, username text) TO anon; + + +-- +-- Name: FUNCTION login(username text, pass text); Type: ACL; Schema: macrostrat_api; Owner: postgres +-- + +GRANT ALL ON FUNCTION macrostrat_api.login(username text, pass text) TO anon; +GRANT ALL ON FUNCTION macrostrat_api.login(username text, pass text) TO authenticator; + + +-- +-- Name: TABLE data_roles; Type: ACL; Schema: auth; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE auth.data_roles TO api_user; + + +-- +-- Name: SEQUENCE data_roles_id_seq; Type: ACL; Schema: auth; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE auth.data_roles_id_seq TO api_user; + + +-- +-- Name: TABLE user_projects; Type: ACL; Schema: auth; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE auth.user_projects TO api_user; + + +-- +-- Name: SEQUENCE user_projects_id_seq; Type: ACL; Schema: auth; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE auth.user_projects_id_seq TO api_user; + + +-- +-- Name: TABLE users; Type: ACL; Schema: auth; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE auth.users TO api_user; + + +-- +-- Name: SEQUENCE users_id_seq; Type: ACL; Schema: auth; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE auth.users_id_seq TO api_user; + + +-- +-- Name: TABLE autocomplete; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.autocomplete TO api_user; + + +-- +-- Name: TABLE col_areas; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.col_areas TO api_user; + + +-- +-- Name: SEQUENCE col_areas_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.col_areas_id_seq TO api_user; + + +-- +-- Name: TABLE col_groups; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.col_groups TO api_user; + + +-- +-- Name: SEQUENCE col_groups_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.col_groups_id_seq TO api_user; + + +-- +-- Name: TABLE col_refs; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.col_refs TO api_user; + + +-- +-- Name: SEQUENCE col_refs_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.col_refs_id_seq TO api_user; + + +-- +-- Name: TABLE cols; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.cols TO api_user; + + +-- +-- Name: SEQUENCE cols_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.cols_id_seq TO api_user; + + +-- +-- Name: TABLE concepts_places; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.concepts_places TO api_user; + + +-- +-- Name: TABLE econs; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.econs TO api_user; + + +-- +-- Name: SEQUENCE econs_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.econs_id_seq TO api_user; + + +-- +-- Name: TABLE environs; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.environs TO api_user; + + +-- +-- Name: SEQUENCE environs_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.environs_id_seq TO api_user; + + +-- +-- Name: TABLE grainsize; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.grainsize TO api_user; + + +-- +-- Name: SEQUENCE grainsize_grain_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.grainsize_grain_id_seq TO api_user; + + +-- +-- Name: TABLE intervals; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.intervals TO api_user; + + +-- +-- Name: SEQUENCE intervals_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.intervals_id_seq TO api_user; + + +-- +-- Name: SEQUENCE intervals_new_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.intervals_new_id_seq TO api_user; + + +-- +-- Name: TABLE lith_atts; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.lith_atts TO api_user; + + +-- +-- Name: SEQUENCE lith_atts_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.lith_atts_id_seq TO api_user; + + +-- +-- Name: TABLE liths; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.liths TO api_user; + + +-- +-- Name: SEQUENCE liths_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.liths_id_seq TO api_user; + + +-- +-- Name: TABLE lookup_strat_names; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.lookup_strat_names TO api_user; + + +-- +-- Name: TABLE lookup_unit_attrs_api; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.lookup_unit_attrs_api TO api_user; + + +-- +-- Name: TABLE lookup_unit_intervals; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.lookup_unit_intervals TO api_user; + + +-- +-- Name: TABLE lookup_unit_liths; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.lookup_unit_liths TO api_user; + + +-- +-- Name: TABLE lookup_units; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.lookup_units TO api_user; + + +-- +-- Name: SEQUENCE lookup_units_unit_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.lookup_units_unit_id_seq TO api_user; + + +-- +-- Name: TABLE measurements; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.measurements TO api_user; + + +-- +-- Name: SEQUENCE measurements_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.measurements_id_seq TO api_user; + + +-- +-- Name: SEQUENCE measurements_new_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.measurements_new_id_seq TO api_user; + + +-- +-- Name: SEQUENCE measurements_new_id_seq1; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.measurements_new_id_seq1 TO api_user; + + +-- +-- Name: TABLE measuremeta; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.measuremeta TO api_user; + + +-- +-- Name: SEQUENCE measuremeta_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.measuremeta_id_seq TO api_user; + + +-- +-- Name: SEQUENCE measuremeta_new_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.measuremeta_new_id_seq TO api_user; + + +-- +-- Name: TABLE measures; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.measures TO api_user; + + +-- +-- Name: SEQUENCE measures_new_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.measures_new_id_seq TO api_user; + + +-- +-- Name: TABLE pbdb_collections; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.pbdb_collections TO api_user; + + +-- +-- Name: TABLE pbdb_collections_strat_names; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.pbdb_collections_strat_names TO api_user; + + +-- +-- Name: TABLE places; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.places TO api_user; + + +-- +-- Name: SEQUENCE places_place_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.places_place_id_seq TO api_user; + + +-- +-- Name: TABLE projects; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.projects TO api_user; + + +-- +-- Name: SEQUENCE projects_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.projects_id_seq TO api_user; + + +-- +-- Name: SEQUENCE projects_new_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.projects_new_id_seq TO api_user; + + +-- +-- Name: TABLE refs; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.refs TO api_user; + + +-- +-- Name: SEQUENCE refs_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.refs_id_seq TO api_user; + + +-- +-- Name: TABLE sections; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.sections TO api_user; + + +-- +-- Name: SEQUENCE sections_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.sections_id_seq TO api_user; + + +-- +-- Name: SEQUENCE sections_new_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.sections_new_id_seq TO api_user; + + +-- +-- Name: TABLE strat_name_footprints; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.strat_name_footprints TO api_user; + + +-- +-- Name: TABLE strat_names; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.strat_names TO api_user; + + +-- +-- Name: SEQUENCE strat_names_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.strat_names_id_seq TO api_user; + + +-- +-- Name: TABLE strat_names_meta; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.strat_names_meta TO api_user; + + +-- +-- Name: SEQUENCE strat_names_meta_concept_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.strat_names_meta_concept_id_seq TO api_user; + + +-- +-- Name: SEQUENCE strat_names_new_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.strat_names_new_id_seq TO api_user; + + +-- +-- Name: TABLE strat_names_places; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.strat_names_places TO api_user; + + +-- +-- Name: TABLE strat_tree; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.strat_tree TO api_user; + + +-- +-- Name: SEQUENCE strat_tree_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.strat_tree_id_seq TO api_user; + + +-- +-- Name: SEQUENCE strat_tree_new_id_seq1; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.strat_tree_new_id_seq1 TO api_user; + + +-- +-- Name: TABLE timescales; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.timescales TO api_user; + + +-- +-- Name: SEQUENCE timescales_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.timescales_id_seq TO api_user; + + +-- +-- Name: TABLE timescales_intervals; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.timescales_intervals TO api_user; + + +-- +-- Name: TABLE unit_econs; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.unit_econs TO api_user; + + +-- +-- Name: SEQUENCE unit_econs_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.unit_econs_id_seq TO api_user; + + +-- +-- Name: TABLE unit_environs; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.unit_environs TO api_user; + + +-- +-- Name: SEQUENCE unit_environs_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.unit_environs_id_seq TO api_user; + + +-- +-- Name: TABLE unit_lith_atts; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.unit_lith_atts TO api_user; + + +-- +-- Name: SEQUENCE unit_lith_atts_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.unit_lith_atts_id_seq TO api_user; + + +-- +-- Name: TABLE unit_liths; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.unit_liths TO api_user; + + +-- +-- Name: SEQUENCE unit_liths_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.unit_liths_id_seq TO api_user; + + +-- +-- Name: TABLE unit_measures; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.unit_measures TO api_user; + + +-- +-- Name: SEQUENCE unit_measures_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.unit_measures_id_seq TO api_user; + + +-- +-- Name: SEQUENCE unit_measures_new_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.unit_measures_new_id_seq TO api_user; + + +-- +-- Name: TABLE unit_strat_names; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.unit_strat_names TO api_user; + + +-- +-- Name: SEQUENCE unit_strat_names_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.unit_strat_names_id_seq TO api_user; + + +-- +-- Name: SEQUENCE unit_strat_names_new_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.unit_strat_names_new_id_seq TO api_user; + + +-- +-- Name: TABLE units; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.units TO api_user; + + +-- +-- Name: SEQUENCE units_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.units_id_seq TO api_user; + + +-- +-- Name: TABLE units_sections; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.units_sections TO api_user; + + +-- +-- Name: SEQUENCE units_sections_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.units_sections_id_seq TO api_user; + + +-- +-- Name: SEQUENCE units_sections_new_id_seq1; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.units_sections_new_id_seq1 TO api_user; + + +-- +-- PostgreSQL database dump complete +-- + diff --git a/v2-transition/services/column-builder/database/tests/fixtures/schema_dump.sql b/v2-transition/services/column-builder/database/tests/fixtures/schema_dump.sql index af9039a8b..1fd491a5d 100644 --- a/v2-transition/services/column-builder/database/tests/fixtures/schema_dump.sql +++ b/v2-transition/services/column-builder/database/tests/fixtures/schema_dump.sql @@ -48,6 +48,39 @@ CREATE EXTENSION IF NOT EXISTS postgis WITH SCHEMA public; COMMENT ON EXTENSION postgis IS 'PostGIS geometry and geography spatial types and functions'; +-- +-- Name: measurement_class; Type: TYPE; Schema: public; Owner: postgres +-- + +CREATE TYPE public.measurement_class AS ENUM ( + '', + 'geophysical', + 'geochemical', + 'sedimentological' +); + + +ALTER TYPE public.measurement_class OWNER TO postgres; + +-- +-- Name: measurement_type; Type: TYPE; Schema: public; Owner: postgres +-- + +CREATE TYPE public.measurement_type AS ENUM ( + '', + 'material properties', + 'geochronological', + 'major elements', + 'minor elements', + 'radiogenic isotopes', + 'stable isotopes', + 'petrologic', + 'environmental' +); + + +ALTER TYPE public.measurement_type OWNER TO postgres; + -- -- Name: make_into_serial(text, text); Type: FUNCTION; Schema: macrostrat; Owner: postgres -- @@ -115,6 +148,23 @@ $_$; ALTER PROCEDURE macrostrat.pg_reset_pkey_seq() OWNER TO postgres; +-- +-- Name: project_insert(); Type: FUNCTION; Schema: macrostrat_api; Owner: postgres +-- + +CREATE FUNCTION macrostrat_api.project_insert() RETURNS trigger + LANGUAGE plpgsql + AS $$ +BEGIN +INSERT INTO macrostrat.projects(project, descrip, timescale_id)VALUES + (NEW.project, NEW.descrip, NEW.timescale_id); +RETURN NEW; +END +$$; + + +ALTER FUNCTION macrostrat_api.project_insert() OWNER TO postgres; + SET default_tablespace = ''; SET default_table_access_method = heap; @@ -137,7 +187,7 @@ ALTER TABLE macrostrat.autocomplete OWNER TO postgres; -- Name: TABLE autocomplete; Type: COMMENT; Schema: macrostrat; Owner: postgres -- -COMMENT ON TABLE macrostrat.autocomplete IS 'Last updated from MariaDB - 2021-08-30 11:28'; +COMMENT ON TABLE macrostrat.autocomplete IS 'Last updated from MariaDB - 2022-02-25 14:28'; -- @@ -147,7 +197,7 @@ COMMENT ON TABLE macrostrat.autocomplete IS 'Last updated from MariaDB - 2021-08 CREATE TABLE macrostrat.col_areas ( id integer NOT NULL, col_id integer, - col_area public.geometry(Geometry,4326), + col_area public.geometry, wkt text ); @@ -158,7 +208,7 @@ ALTER TABLE macrostrat.col_areas OWNER TO postgres; -- Name: TABLE col_areas; Type: COMMENT; Schema: macrostrat; Owner: postgres -- -COMMENT ON TABLE macrostrat.col_areas IS 'Last updated from MariaDB - 2021-08-30 11:30'; +COMMENT ON TABLE macrostrat.col_areas IS 'Last updated from MariaDB - 2022-02-25 14:28'; -- @@ -241,7 +291,7 @@ ALTER TABLE macrostrat.col_refs OWNER TO postgres; -- Name: TABLE col_refs; Type: COMMENT; Schema: macrostrat; Owner: postgres -- -COMMENT ON TABLE macrostrat.col_refs IS 'Last updated from MariaDB - 2021-08-30 11:25'; +COMMENT ON TABLE macrostrat.col_refs IS 'Last updated from MariaDB - 2022-02-25 14:28'; -- @@ -281,10 +331,11 @@ CREATE TABLE macrostrat.cols ( lat numeric, lng numeric, col_area numeric, - coordinate public.geometry(Geometry,4326), + coordinate public.geometry, wkt text, created text, - poly_geom public.geometry(Geometry,4326) + poly_geom public.geometry, + notes text ); @@ -294,7 +345,7 @@ ALTER TABLE macrostrat.cols OWNER TO postgres; -- Name: TABLE cols; Type: COMMENT; Schema: macrostrat; Owner: postgres -- -COMMENT ON TABLE macrostrat.cols IS 'Last updated from MariaDB - 2021-08-30 12:02'; +COMMENT ON TABLE macrostrat.cols IS 'Last updated from MariaDB - 2022-02-25 14:47'; -- @@ -334,7 +385,7 @@ ALTER TABLE macrostrat.concepts_places OWNER TO postgres; -- Name: TABLE concepts_places; Type: COMMENT; Schema: macrostrat; Owner: postgres -- -COMMENT ON TABLE macrostrat.concepts_places IS 'Last updated from MariaDB - 2021-08-30 11:25'; +COMMENT ON TABLE macrostrat.concepts_places IS 'Last updated from MariaDB - 2022-02-25 14:28'; -- @@ -356,7 +407,7 @@ ALTER TABLE macrostrat.econs OWNER TO postgres; -- Name: TABLE econs; Type: COMMENT; Schema: macrostrat; Owner: postgres -- -COMMENT ON TABLE macrostrat.econs IS 'Last updated from MariaDB - 2021-08-30 11:25'; +COMMENT ON TABLE macrostrat.econs IS 'Last updated from MariaDB - 2022-02-25 14:29'; -- @@ -484,7 +535,7 @@ ALTER TABLE macrostrat.intervals OWNER TO postgres; -- Name: TABLE intervals; Type: COMMENT; Schema: macrostrat; Owner: postgres -- -COMMENT ON TABLE macrostrat.intervals IS 'Last updated from MariaDB - 2021-08-30 11:29'; +COMMENT ON TABLE macrostrat.intervals IS 'Last updated from MariaDB - 2022-02-25 14:28'; -- @@ -509,10 +560,10 @@ ALTER SEQUENCE macrostrat.intervals_id_seq OWNED BY macrostrat.intervals.id; -- --- Name: intervals_new_id_seq1; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- Name: intervals_new_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres -- -CREATE SEQUENCE macrostrat.intervals_new_id_seq1 +CREATE SEQUENCE macrostrat.intervals_new_id_seq AS integer START WITH 1 INCREMENT BY 1 @@ -521,13 +572,13 @@ CREATE SEQUENCE macrostrat.intervals_new_id_seq1 CACHE 1; -ALTER TABLE macrostrat.intervals_new_id_seq1 OWNER TO postgres; +ALTER TABLE macrostrat.intervals_new_id_seq OWNER TO postgres; -- --- Name: intervals_new_id_seq1; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- Name: intervals_new_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres -- -ALTER SEQUENCE macrostrat.intervals_new_id_seq1 OWNED BY macrostrat.intervals.id; +ALTER SEQUENCE macrostrat.intervals_new_id_seq OWNED BY macrostrat.intervals.id; -- @@ -597,7 +648,7 @@ ALTER TABLE macrostrat.liths OWNER TO postgres; -- Name: TABLE liths; Type: COMMENT; Schema: macrostrat; Owner: postgres -- -COMMENT ON TABLE macrostrat.liths IS 'Last updated from MariaDB - 2021-08-30 11:29'; +COMMENT ON TABLE macrostrat.liths IS 'Last updated from MariaDB - 2022-02-25 14:28'; -- @@ -680,7 +731,7 @@ ALTER TABLE macrostrat.lookup_unit_attrs_api OWNER TO postgres; -- Name: TABLE lookup_unit_attrs_api; Type: COMMENT; Schema: macrostrat; Owner: postgres -- -COMMENT ON TABLE macrostrat.lookup_unit_attrs_api IS 'Last updated from MariaDB - 2021-08-30 11:30'; +COMMENT ON TABLE macrostrat.lookup_unit_attrs_api IS 'Last updated from MariaDB - 2022-02-25 14:29'; -- @@ -742,7 +793,7 @@ ALTER TABLE macrostrat.lookup_unit_liths OWNER TO postgres; -- Name: TABLE lookup_unit_liths; Type: COMMENT; Schema: macrostrat; Owner: postgres -- -COMMENT ON TABLE macrostrat.lookup_unit_liths IS 'Last updated from MariaDB - 2021-08-30 11:24'; +COMMENT ON TABLE macrostrat.lookup_unit_liths IS 'Last updated from MariaDB - 2022-02-25 14:28'; -- @@ -818,6 +869,48 @@ ALTER TABLE macrostrat.lookup_units_unit_id_seq OWNER TO postgres; ALTER SEQUENCE macrostrat.lookup_units_unit_id_seq OWNED BY macrostrat.lookup_units.unit_id; +-- +-- Name: measurements; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.measurements ( + id integer NOT NULL, + measurement_class public.measurement_class NOT NULL, + measurement_type public.measurement_type NOT NULL, + measurement text NOT NULL +); + + +ALTER TABLE macrostrat.measurements OWNER TO postgres; + +-- +-- Name: TABLE measurements; Type: COMMENT; Schema: macrostrat; Owner: postgres +-- + +COMMENT ON TABLE macrostrat.measurements IS 'Last updated from MariaDB - 2022-02-25 15:08'; + + +-- +-- Name: measurements_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.measurements_id_seq + START WITH 125 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.measurements_id_seq OWNER TO postgres; + +-- +-- Name: measurements_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.measurements_id_seq OWNED BY macrostrat.measurements.id; + + -- -- Name: measurements_new_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres -- @@ -833,6 +926,28 @@ CREATE SEQUENCE macrostrat.measurements_new_id_seq ALTER TABLE macrostrat.measurements_new_id_seq OWNER TO postgres; +-- +-- Name: measurements_new_id_seq1; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.measurements_new_id_seq1 + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.measurements_new_id_seq1 OWNER TO postgres; + +-- +-- Name: measurements_new_id_seq1; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.measurements_new_id_seq1 OWNED BY macrostrat.measurements.id; + + -- -- Name: measuremeta; Type: TABLE; Schema: macrostrat; Owner: postgres -- @@ -861,7 +976,7 @@ ALTER TABLE macrostrat.measuremeta OWNER TO postgres; -- Name: TABLE measuremeta; Type: COMMENT; Schema: macrostrat; Owner: postgres -- -COMMENT ON TABLE macrostrat.measuremeta IS 'Last updated from MariaDB - 2021-08-30 11:27'; +COMMENT ON TABLE macrostrat.measuremeta IS 'Last updated from MariaDB - 2022-02-25 14:29'; -- @@ -886,10 +1001,10 @@ ALTER SEQUENCE macrostrat.measuremeta_id_seq OWNED BY macrostrat.measuremeta.id; -- --- Name: measuremeta_new_id_seq1; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- Name: measuremeta_new_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres -- -CREATE SEQUENCE macrostrat.measuremeta_new_id_seq1 +CREATE SEQUENCE macrostrat.measuremeta_new_id_seq AS integer START WITH 1 INCREMENT BY 1 @@ -898,13 +1013,13 @@ CREATE SEQUENCE macrostrat.measuremeta_new_id_seq1 CACHE 1; -ALTER TABLE macrostrat.measuremeta_new_id_seq1 OWNER TO postgres; +ALTER TABLE macrostrat.measuremeta_new_id_seq OWNER TO postgres; -- --- Name: measuremeta_new_id_seq1; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- Name: measuremeta_new_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres -- -ALTER SEQUENCE macrostrat.measuremeta_new_id_seq1 OWNED BY macrostrat.measuremeta.id; +ALTER SEQUENCE macrostrat.measuremeta_new_id_seq OWNED BY macrostrat.measuremeta.id; -- @@ -1014,7 +1129,7 @@ CREATE TABLE macrostrat.places ( postal text, country text, country_abbrev text, - geom public.geometry(Geometry,4326) + geom public.geometry ); @@ -1024,7 +1139,7 @@ ALTER TABLE macrostrat.places OWNER TO postgres; -- Name: TABLE places; Type: COMMENT; Schema: macrostrat; Owner: postgres -- -COMMENT ON TABLE macrostrat.places IS 'Last updated from MariaDB - 2021-08-30 11:59'; +COMMENT ON TABLE macrostrat.places IS 'Last updated from MariaDB - 2022-02-25 14:29'; -- @@ -1062,13 +1177,19 @@ CREATE TABLE macrostrat.projects ( ALTER TABLE macrostrat.projects OWNER TO postgres; +-- +-- Name: TABLE projects; Type: COMMENT; Schema: macrostrat; Owner: postgres +-- + +COMMENT ON TABLE macrostrat.projects IS 'Last updated from MariaDB - 2022-02-25 14:40'; + + -- -- Name: projects_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres -- CREATE SEQUENCE macrostrat.projects_id_seq - AS integer - START WITH 1 + START WITH 13 INCREMENT BY 1 NO MINVALUE NO MAXVALUE @@ -1084,6 +1205,28 @@ ALTER TABLE macrostrat.projects_id_seq OWNER TO postgres; ALTER SEQUENCE macrostrat.projects_id_seq OWNED BY macrostrat.projects.id; +-- +-- Name: projects_new_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.projects_new_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.projects_new_id_seq OWNER TO postgres; + +-- +-- Name: projects_new_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.projects_new_id_seq OWNED BY macrostrat.projects.id; + + -- -- Name: refs; Type: TABLE; Schema: macrostrat; Owner: postgres -- @@ -1130,6 +1273,68 @@ ALTER TABLE macrostrat.refs_id_seq OWNER TO postgres; ALTER SEQUENCE macrostrat.refs_id_seq OWNED BY macrostrat.refs.id; +-- +-- Name: sections; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.sections ( + id integer NOT NULL, + col_id integer +); + + +ALTER TABLE macrostrat.sections OWNER TO postgres; + +-- +-- Name: TABLE sections; Type: COMMENT; Schema: macrostrat; Owner: postgres +-- + +COMMENT ON TABLE macrostrat.sections IS 'Last updated from MariaDB - 2022-02-25 14:41'; + + +-- +-- Name: sections_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.sections_id_seq + START WITH 12737 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.sections_id_seq OWNER TO postgres; + +-- +-- Name: sections_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.sections_id_seq OWNED BY macrostrat.sections.id; + + +-- +-- Name: sections_new_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.sections_new_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.sections_new_id_seq OWNER TO postgres; + +-- +-- Name: sections_new_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.sections_new_id_seq OWNED BY macrostrat.sections.id; + + -- -- Name: strat_name_footprints; Type: TABLE; Schema: macrostrat; Owner: postgres -- @@ -1157,8 +1362,7 @@ CREATE TABLE macrostrat.strat_names ( strat_name character varying(100) NOT NULL, rank character varying(50), ref_id integer NOT NULL, - concept_id integer, - parent integer + concept_id integer ); @@ -1280,7 +1484,71 @@ ALTER TABLE macrostrat.strat_names_places OWNER TO postgres; -- Name: TABLE strat_names_places; Type: COMMENT; Schema: macrostrat; Owner: postgres -- -COMMENT ON TABLE macrostrat.strat_names_places IS 'Last updated from MariaDB - 2021-08-30 11:30'; +COMMENT ON TABLE macrostrat.strat_names_places IS 'Last updated from MariaDB - 2022-02-25 14:29'; + + +-- +-- Name: strat_tree; Type: TABLE; Schema: macrostrat; Owner: postgres +-- + +CREATE TABLE macrostrat.strat_tree ( + id integer NOT NULL, + parent integer, + child integer, + ref_id integer +); + + +ALTER TABLE macrostrat.strat_tree OWNER TO postgres; + +-- +-- Name: TABLE strat_tree; Type: COMMENT; Schema: macrostrat; Owner: postgres +-- + +COMMENT ON TABLE macrostrat.strat_tree IS 'Last updated from MariaDB - 2022-02-25 14:40'; + + +-- +-- Name: strat_tree_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.strat_tree_id_seq + START WITH 29785 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.strat_tree_id_seq OWNER TO postgres; + +-- +-- Name: strat_tree_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.strat_tree_id_seq OWNED BY macrostrat.strat_tree.id; + + +-- +-- Name: strat_tree_new_id_seq1; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- + +CREATE SEQUENCE macrostrat.strat_tree_new_id_seq1 + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE macrostrat.strat_tree_new_id_seq1 OWNER TO postgres; + +-- +-- Name: strat_tree_new_id_seq1; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- + +ALTER SEQUENCE macrostrat.strat_tree_new_id_seq1 OWNED BY macrostrat.strat_tree.id; -- @@ -1340,7 +1608,7 @@ ALTER TABLE macrostrat.timescales_intervals OWNER TO postgres; -- Name: TABLE timescales_intervals; Type: COMMENT; Schema: macrostrat; Owner: postgres -- -COMMENT ON TABLE macrostrat.timescales_intervals IS 'Last updated from MariaDB - 2021-08-30 11:30'; +COMMENT ON TABLE macrostrat.timescales_intervals IS 'Last updated from MariaDB - 2022-02-25 14:29'; -- @@ -1413,7 +1681,7 @@ COMMENT ON TABLE macrostrat.unit_environs IS 'Last updated from MariaDB - 2021-0 -- CREATE SEQUENCE macrostrat.unit_environs_id_seq - START WITH 85929 + START WITH 85924 INCREMENT BY 1 NO MINVALUE NO MAXVALUE @@ -1496,7 +1764,7 @@ ALTER TABLE macrostrat.unit_liths OWNER TO postgres; -- Name: TABLE unit_liths; Type: COMMENT; Schema: macrostrat; Owner: postgres -- -COMMENT ON TABLE macrostrat.unit_liths IS 'Last updated from MariaDB - 2021-08-30 11:29'; +COMMENT ON TABLE macrostrat.unit_liths IS 'Last updated from MariaDB - 2022-02-25 14:28'; -- @@ -1504,7 +1772,7 @@ COMMENT ON TABLE macrostrat.unit_liths IS 'Last updated from MariaDB - 2021-08-3 -- CREATE SEQUENCE macrostrat.unit_liths_id_seq - START WITH 130551 + START WITH 132637 INCREMENT BY 1 NO MINVALUE NO MAXVALUE @@ -1603,7 +1871,7 @@ ALTER TABLE macrostrat.unit_strat_names OWNER TO postgres; -- Name: TABLE unit_strat_names; Type: COMMENT; Schema: macrostrat; Owner: postgres -- -COMMENT ON TABLE macrostrat.unit_strat_names IS 'Last updated from MariaDB - 2021-08-30 11:25'; +COMMENT ON TABLE macrostrat.unit_strat_names IS 'Last updated from MariaDB - 2022-02-25 14:28'; -- @@ -1628,10 +1896,10 @@ ALTER SEQUENCE macrostrat.unit_strat_names_id_seq OWNED BY macrostrat.unit_strat -- --- Name: unit_strat_names_new_id_seq1; Type: SEQUENCE; Schema: macrostrat; Owner: postgres +-- Name: unit_strat_names_new_id_seq; Type: SEQUENCE; Schema: macrostrat; Owner: postgres -- -CREATE SEQUENCE macrostrat.unit_strat_names_new_id_seq1 +CREATE SEQUENCE macrostrat.unit_strat_names_new_id_seq AS integer START WITH 1 INCREMENT BY 1 @@ -1640,13 +1908,13 @@ CREATE SEQUENCE macrostrat.unit_strat_names_new_id_seq1 CACHE 1; -ALTER TABLE macrostrat.unit_strat_names_new_id_seq1 OWNER TO postgres; +ALTER TABLE macrostrat.unit_strat_names_new_id_seq OWNER TO postgres; -- --- Name: unit_strat_names_new_id_seq1; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres +-- Name: unit_strat_names_new_id_seq; Type: SEQUENCE OWNED BY; Schema: macrostrat; Owner: postgres -- -ALTER SEQUENCE macrostrat.unit_strat_names_new_id_seq1 OWNED BY macrostrat.unit_strat_names.id; +ALTER SEQUENCE macrostrat.unit_strat_names_new_id_seq OWNED BY macrostrat.unit_strat_names.id; -- @@ -1665,7 +1933,9 @@ CREATE TABLE macrostrat.units ( max_thick numeric, min_thick numeric, section_id integer, - col_id integer + col_id integer, + notes text, + strat_name_id integer ); @@ -1675,7 +1945,7 @@ ALTER TABLE macrostrat.units OWNER TO postgres; -- Name: TABLE units; Type: COMMENT; Schema: macrostrat; Owner: postgres -- -COMMENT ON TABLE macrostrat.units IS 'Last updated from MariaDB - 2021-08-30 11:31'; +COMMENT ON TABLE macrostrat.units IS 'Last updated from MariaDB - 2022-02-25 14:47'; -- @@ -1683,7 +1953,7 @@ COMMENT ON TABLE macrostrat.units IS 'Last updated from MariaDB - 2021-08-30 11: -- CREATE SEQUENCE macrostrat.units_id_seq - START WITH 52384 + START WITH 53232 INCREMENT BY 1 NO MINVALUE NO MAXVALUE @@ -1771,6 +2041,7 @@ CREATE VIEW macrostrat_api.col_ref_expanded AS SELECT c.id AS col_id, c.col_name, c.col AS col_number, + c.notes, json_build_object('id', r.id, 'pub_year', r.pub_year, 'author', r.author, 'ref', r.ref, 'doi', r.doi, 'url', r.url) AS ref FROM ((macrostrat.cols c LEFT JOIN macrostrat.col_refs cr ON ((c.id = cr.col_id))) @@ -1795,7 +2066,7 @@ SELECT ALTER TABLE macrostrat_api.col_group_with_cols OWNER TO postgres; -- --- Name: col_groups; Type: VIEW; Schema: macrostrat_api; Owner: postgres +-- Name: col_groups; Type: VIEW; Schema: macrostrat_api; Owner: api_views_owner -- CREATE VIEW macrostrat_api.col_groups AS @@ -1806,10 +2077,10 @@ CREATE VIEW macrostrat_api.col_groups AS FROM macrostrat.col_groups; -ALTER TABLE macrostrat_api.col_groups OWNER TO postgres; +ALTER TABLE macrostrat_api.col_groups OWNER TO api_views_owner; -- --- Name: col_refs; Type: VIEW; Schema: macrostrat_api; Owner: postgres +-- Name: col_refs; Type: VIEW; Schema: macrostrat_api; Owner: api_views_owner -- CREATE VIEW macrostrat_api.col_refs AS @@ -1819,7 +2090,7 @@ CREATE VIEW macrostrat_api.col_refs AS FROM macrostrat.col_refs; -ALTER TABLE macrostrat_api.col_refs OWNER TO postgres; +ALTER TABLE macrostrat_api.col_refs OWNER TO api_views_owner; -- -- Name: col_sections; Type: VIEW; Schema: macrostrat_api; Owner: postgres @@ -1842,7 +2113,7 @@ CREATE VIEW macrostrat_api.col_sections AS ALTER TABLE macrostrat_api.col_sections OWNER TO postgres; -- --- Name: cols; Type: VIEW; Schema: macrostrat_api; Owner: postgres +-- Name: cols; Type: VIEW; Schema: macrostrat_api; Owner: api_views_owner -- CREATE VIEW macrostrat_api.cols AS @@ -1860,11 +2131,12 @@ CREATE VIEW macrostrat_api.cols AS cols.coordinate, cols.wkt, cols.created, - cols.poly_geom + cols.poly_geom, + cols.notes FROM macrostrat.cols; -ALTER TABLE macrostrat_api.cols OWNER TO postgres; +ALTER TABLE macrostrat_api.cols OWNER TO api_views_owner; -- -- Name: econ_unit; Type: VIEW; Schema: macrostrat_api; Owner: postgres @@ -1903,7 +2175,7 @@ CREATE VIEW macrostrat_api.environ_unit AS ALTER TABLE macrostrat_api.environ_unit OWNER TO postgres; -- --- Name: environs; Type: VIEW; Schema: macrostrat_api; Owner: postgres +-- Name: environs; Type: VIEW; Schema: macrostrat_api; Owner: api_views_owner -- CREATE VIEW macrostrat_api.environs AS @@ -1915,10 +2187,10 @@ CREATE VIEW macrostrat_api.environs AS FROM macrostrat.environs; -ALTER TABLE macrostrat_api.environs OWNER TO postgres; +ALTER TABLE macrostrat_api.environs OWNER TO api_views_owner; -- --- Name: intervals; Type: VIEW; Schema: macrostrat_api; Owner: postgres +-- Name: intervals; Type: VIEW; Schema: macrostrat_api; Owner: api_views_owner -- CREATE VIEW macrostrat_api.intervals AS @@ -1933,7 +2205,7 @@ CREATE VIEW macrostrat_api.intervals AS FROM macrostrat.intervals; -ALTER TABLE macrostrat_api.intervals OWNER TO postgres; +ALTER TABLE macrostrat_api.intervals OWNER TO api_views_owner; -- -- Name: lith_attr_unit; Type: VIEW; Schema: macrostrat_api; Owner: postgres @@ -1987,7 +2259,7 @@ CREATE VIEW macrostrat_api.lith_unit AS ALTER TABLE macrostrat_api.lith_unit OWNER TO postgres; -- --- Name: liths; Type: VIEW; Schema: macrostrat_api; Owner: postgres +-- Name: liths; Type: VIEW; Schema: macrostrat_api; Owner: api_views_owner -- CREATE VIEW macrostrat_api.liths AS @@ -2005,10 +2277,10 @@ CREATE VIEW macrostrat_api.liths AS FROM macrostrat.liths; -ALTER TABLE macrostrat_api.liths OWNER TO postgres; +ALTER TABLE macrostrat_api.liths OWNER TO api_views_owner; -- --- Name: projects; Type: VIEW; Schema: macrostrat_api; Owner: postgres +-- Name: projects; Type: VIEW; Schema: macrostrat_api; Owner: api_views_owner -- CREATE VIEW macrostrat_api.projects AS @@ -2019,10 +2291,10 @@ CREATE VIEW macrostrat_api.projects AS FROM macrostrat.projects; -ALTER TABLE macrostrat_api.projects OWNER TO postgres; +ALTER TABLE macrostrat_api.projects OWNER TO api_views_owner; -- --- Name: refs; Type: VIEW; Schema: macrostrat_api; Owner: postgres +-- Name: refs; Type: VIEW; Schema: macrostrat_api; Owner: api_views_owner -- CREATE VIEW macrostrat_api.refs AS @@ -2037,7 +2309,19 @@ CREATE VIEW macrostrat_api.refs AS FROM macrostrat.refs; -ALTER TABLE macrostrat_api.refs OWNER TO postgres; +ALTER TABLE macrostrat_api.refs OWNER TO api_views_owner; + +-- +-- Name: sections; Type: VIEW; Schema: macrostrat_api; Owner: postgres +-- + +CREATE VIEW macrostrat_api.sections AS + SELECT sections.id, + sections.col_id + FROM macrostrat.sections; + + +ALTER TABLE macrostrat_api.sections OWNER TO postgres; -- -- Name: strat_names; Type: VIEW; Schema: macrostrat_api; Owner: postgres @@ -2048,10 +2332,8 @@ CREATE VIEW macrostrat_api.strat_names AS s.strat_name, s.rank, row_to_json(r.*) AS ref, - row_to_json(sm.*) AS concept, - row_to_json(sn.*) AS parent - FROM (((macrostrat.strat_names s - LEFT JOIN macrostrat.strat_names sn ON ((s.parent = sn.id))) + row_to_json(sm.*) AS concept + FROM ((macrostrat.strat_names s LEFT JOIN macrostrat.refs r ON ((r.id = s.ref_id))) LEFT JOIN macrostrat.strat_names_meta sm ON ((sm.concept_id = s.concept_id))); @@ -2059,7 +2341,21 @@ CREATE VIEW macrostrat_api.strat_names AS ALTER TABLE macrostrat_api.strat_names OWNER TO postgres; -- --- Name: timescales; Type: VIEW; Schema: macrostrat_api; Owner: postgres +-- Name: strat_tree; Type: VIEW; Schema: macrostrat_api; Owner: api_views_owner +-- + +CREATE VIEW macrostrat_api.strat_tree AS + SELECT strat_tree.id, + strat_tree.parent, + strat_tree.child, + strat_tree.ref_id + FROM macrostrat.strat_tree; + + +ALTER TABLE macrostrat_api.strat_tree OWNER TO api_views_owner; + +-- +-- Name: timescales; Type: VIEW; Schema: macrostrat_api; Owner: api_views_owner -- CREATE VIEW macrostrat_api.timescales AS @@ -2069,7 +2365,7 @@ CREATE VIEW macrostrat_api.timescales AS FROM macrostrat.timescales; -ALTER TABLE macrostrat_api.timescales OWNER TO postgres; +ALTER TABLE macrostrat_api.timescales OWNER TO api_views_owner; -- -- Name: unit_environs; Type: VIEW; Schema: macrostrat_api; Owner: postgres @@ -2087,7 +2383,7 @@ CREATE VIEW macrostrat_api.unit_environs AS ALTER TABLE macrostrat_api.unit_environs OWNER TO postgres; -- --- Name: unit_liths; Type: VIEW; Schema: macrostrat_api; Owner: postgres +-- Name: unit_liths; Type: VIEW; Schema: macrostrat_api; Owner: api_views_owner -- CREATE VIEW macrostrat_api.unit_liths AS @@ -2104,10 +2400,10 @@ CREATE VIEW macrostrat_api.unit_liths AS FROM macrostrat.unit_liths; -ALTER TABLE macrostrat_api.unit_liths OWNER TO postgres; +ALTER TABLE macrostrat_api.unit_liths OWNER TO api_views_owner; -- --- Name: units; Type: VIEW; Schema: macrostrat_api; Owner: postgres +-- Name: units; Type: VIEW; Schema: macrostrat_api; Owner: api_views_owner -- CREATE VIEW macrostrat_api.units AS @@ -2122,11 +2418,13 @@ CREATE VIEW macrostrat_api.units AS units.max_thick, units.min_thick, units.section_id, - units.col_id + units.col_id, + units.notes, + units.strat_name_id FROM macrostrat.units; -ALTER TABLE macrostrat_api.units OWNER TO postgres; +ALTER TABLE macrostrat_api.units OWNER TO api_views_owner; -- -- Name: unit_strat_name_expanded; Type: VIEW; Schema: macrostrat_api; Owner: postgres @@ -2135,9 +2433,7 @@ ALTER TABLE macrostrat_api.units OWNER TO postgres; CREATE VIEW macrostrat_api.unit_strat_name_expanded AS SELECT u.id, u.strat_name AS unit_strat_name, - s.strat_name, - s.rank, - s.id AS strat_name_id, + to_jsonb(s.*) AS strat_name, u.color, u.outcrop, u.fo, @@ -2148,15 +2444,15 @@ CREATE VIEW macrostrat_api.unit_strat_name_expanded AS u.min_thick, u.section_id, u.col_id, + u.notes, fo.interval_name AS name_fo, fo.age_bottom, lo.interval_name AS name_lo, lo.age_top - FROM ((((macrostrat.units u + FROM (((macrostrat.units u LEFT JOIN macrostrat.intervals fo ON ((u.fo = fo.id))) LEFT JOIN macrostrat.intervals lo ON ((u.lo = lo.id))) - LEFT JOIN macrostrat.unit_strat_names usn ON ((usn.unit_id = u.id))) - LEFT JOIN macrostrat.strat_names s ON ((usn.strat_name_id = s.id))); + LEFT JOIN macrostrat.strat_names s ON ((u.strat_name_id = s.id))); ALTER TABLE macrostrat_api.unit_strat_name_expanded OWNER TO postgres; @@ -2238,6 +2534,13 @@ ALTER TABLE ONLY macrostrat.liths ALTER COLUMN id SET DEFAULT nextval('macrostra ALTER TABLE ONLY macrostrat.lookup_units ALTER COLUMN unit_id SET DEFAULT nextval('macrostrat.lookup_units_unit_id_seq'::regclass); +-- +-- Name: measurements id; Type: DEFAULT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.measurements ALTER COLUMN id SET DEFAULT nextval('macrostrat.measurements_id_seq'::regclass); + + -- -- Name: measuremeta id; Type: DEFAULT; Schema: macrostrat; Owner: postgres -- @@ -2273,6 +2576,13 @@ ALTER TABLE ONLY macrostrat.projects ALTER COLUMN id SET DEFAULT nextval('macros ALTER TABLE ONLY macrostrat.refs ALTER COLUMN id SET DEFAULT nextval('macrostrat.refs_id_seq'::regclass); +-- +-- Name: sections id; Type: DEFAULT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.sections ALTER COLUMN id SET DEFAULT nextval('macrostrat.sections_id_seq'::regclass); + + -- -- Name: strat_names id; Type: DEFAULT; Schema: macrostrat; Owner: postgres -- @@ -2287,6 +2597,13 @@ ALTER TABLE ONLY macrostrat.strat_names ALTER COLUMN id SET DEFAULT nextval('mac ALTER TABLE ONLY macrostrat.strat_names_meta ALTER COLUMN concept_id SET DEFAULT nextval('macrostrat.strat_names_meta_concept_id_seq'::regclass); +-- +-- Name: strat_tree id; Type: DEFAULT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.strat_tree ALTER COLUMN id SET DEFAULT nextval('macrostrat.strat_tree_id_seq'::regclass); + + -- -- Name: timescales id; Type: DEFAULT; Schema: macrostrat; Owner: postgres -- @@ -2367,11 +2684,11 @@ ALTER TABLE ONLY macrostrat.col_groups -- --- Name: col_refs col_refs_new_pkey1; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres +-- Name: col_refs col_refs_new_pkey; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres -- ALTER TABLE ONLY macrostrat.col_refs - ADD CONSTRAINT col_refs_new_pkey1 PRIMARY KEY (id); + ADD CONSTRAINT col_refs_new_pkey PRIMARY KEY (id); -- @@ -2383,11 +2700,11 @@ ALTER TABLE ONLY macrostrat.cols -- --- Name: econs econs_new_pkey; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres +-- Name: econs econs_new_pkey1; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres -- ALTER TABLE ONLY macrostrat.econs - ADD CONSTRAINT econs_new_pkey PRIMARY KEY (id); + ADD CONSTRAINT econs_new_pkey1 PRIMARY KEY (id); -- @@ -2423,11 +2740,11 @@ ALTER TABLE ONLY macrostrat.lith_atts -- --- Name: liths liths_new_pkey1; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres +-- Name: liths liths_new_pkey; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres -- ALTER TABLE ONLY macrostrat.liths - ADD CONSTRAINT liths_new_pkey1 PRIMARY KEY (id); + ADD CONSTRAINT liths_new_pkey PRIMARY KEY (id); -- @@ -2439,27 +2756,35 @@ ALTER TABLE ONLY macrostrat.lookup_units -- --- Name: measuremeta measuremeta_new_pkey; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres +-- Name: measurements measurements_new_pkey; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.measurements + ADD CONSTRAINT measurements_new_pkey PRIMARY KEY (id); + + +-- +-- Name: measuremeta measuremeta_new_pkey1; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres -- ALTER TABLE ONLY macrostrat.measuremeta - ADD CONSTRAINT measuremeta_new_pkey PRIMARY KEY (id); + ADD CONSTRAINT measuremeta_new_pkey1 PRIMARY KEY (id); -- --- Name: places places_new_pkey1; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres +-- Name: places places_new_pkey; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres -- ALTER TABLE ONLY macrostrat.places - ADD CONSTRAINT places_new_pkey1 PRIMARY KEY (place_id); + ADD CONSTRAINT places_new_pkey PRIMARY KEY (place_id); -- --- Name: projects projects_pkey; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres +-- Name: projects projects_new_pkey; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres -- ALTER TABLE ONLY macrostrat.projects - ADD CONSTRAINT projects_pkey PRIMARY KEY (id); + ADD CONSTRAINT projects_new_pkey PRIMARY KEY (id); -- @@ -2470,6 +2795,14 @@ ALTER TABLE ONLY macrostrat.refs ADD CONSTRAINT refs_new_pkey1 PRIMARY KEY (id); +-- +-- Name: sections sections_new_pkey; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.sections + ADD CONSTRAINT sections_new_pkey PRIMARY KEY (id); + + -- -- Name: strat_names_meta strat_names_meta_new_pkey1; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres -- @@ -2486,6 +2819,14 @@ ALTER TABLE ONLY macrostrat.strat_names ADD CONSTRAINT strat_names_new_pkey PRIMARY KEY (id); +-- +-- Name: strat_tree strat_tree_new_pkey1; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.strat_tree + ADD CONSTRAINT strat_tree_new_pkey1 PRIMARY KEY (id); + + -- -- Name: timescales timescales_new_pkey1; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres -- @@ -2519,11 +2860,11 @@ ALTER TABLE ONLY macrostrat.unit_lith_atts -- --- Name: unit_liths unit_liths_new_pkey1; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres +-- Name: unit_liths unit_liths_new_pkey; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres -- ALTER TABLE ONLY macrostrat.unit_liths - ADD CONSTRAINT unit_liths_new_pkey1 PRIMARY KEY (id); + ADD CONSTRAINT unit_liths_new_pkey PRIMARY KEY (id); -- @@ -2535,11 +2876,11 @@ ALTER TABLE ONLY macrostrat.unit_measures -- --- Name: unit_strat_names unit_strat_names_new_pkey1; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres +-- Name: unit_strat_names unit_strat_names_new_pkey; Type: CONSTRAINT; Schema: macrostrat; Owner: postgres -- ALTER TABLE ONLY macrostrat.unit_strat_names - ADD CONSTRAINT unit_strat_names_new_pkey1 PRIMARY KEY (id); + ADD CONSTRAINT unit_strat_names_new_pkey PRIMARY KEY (id); -- @@ -2559,31 +2900,31 @@ ALTER TABLE ONLY macrostrat.units_sections -- --- Name: autocomplete_new_category_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- Name: autocomplete_new_category_idx; Type: INDEX; Schema: macrostrat; Owner: postgres -- -CREATE INDEX autocomplete_new_category_idx1 ON macrostrat.autocomplete USING btree (category); +CREATE INDEX autocomplete_new_category_idx ON macrostrat.autocomplete USING btree (category); -- --- Name: autocomplete_new_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- Name: autocomplete_new_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres -- -CREATE INDEX autocomplete_new_id_idx1 ON macrostrat.autocomplete USING btree (id); +CREATE INDEX autocomplete_new_id_idx ON macrostrat.autocomplete USING btree (id); -- --- Name: autocomplete_new_name_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- Name: autocomplete_new_name_idx; Type: INDEX; Schema: macrostrat; Owner: postgres -- -CREATE INDEX autocomplete_new_name_idx1 ON macrostrat.autocomplete USING btree (name); +CREATE INDEX autocomplete_new_name_idx ON macrostrat.autocomplete USING btree (name); -- --- Name: autocomplete_new_type_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- Name: autocomplete_new_type_idx; Type: INDEX; Schema: macrostrat; Owner: postgres -- -CREATE INDEX autocomplete_new_type_idx1 ON macrostrat.autocomplete USING btree (type); +CREATE INDEX autocomplete_new_type_idx ON macrostrat.autocomplete USING btree (type); -- @@ -2608,17 +2949,17 @@ CREATE INDEX col_groups_new_id_idx1 ON macrostrat.col_groups USING btree (id); -- --- Name: col_refs_new_col_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- Name: col_refs_new_col_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres -- -CREATE INDEX col_refs_new_col_id_idx1 ON macrostrat.col_refs USING btree (col_id); +CREATE INDEX col_refs_new_col_id_idx ON macrostrat.col_refs USING btree (col_id); -- --- Name: col_refs_new_ref_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- Name: col_refs_new_ref_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres -- -CREATE INDEX col_refs_new_ref_id_idx1 ON macrostrat.col_refs USING btree (ref_id); +CREATE INDEX col_refs_new_ref_id_idx ON macrostrat.col_refs USING btree (ref_id); -- @@ -2671,38 +3012,38 @@ CREATE INDEX concepts_places_new_place_id_idx ON macrostrat.concepts_places USIN -- --- Name: intervals_new_age_bottom_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- Name: intervals_new_age_bottom_idx; Type: INDEX; Schema: macrostrat; Owner: postgres -- -CREATE INDEX intervals_new_age_bottom_idx1 ON macrostrat.intervals USING btree (age_bottom); +CREATE INDEX intervals_new_age_bottom_idx ON macrostrat.intervals USING btree (age_bottom); -- --- Name: intervals_new_age_top_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- Name: intervals_new_age_top_idx; Type: INDEX; Schema: macrostrat; Owner: postgres -- -CREATE INDEX intervals_new_age_top_idx1 ON macrostrat.intervals USING btree (age_top); +CREATE INDEX intervals_new_age_top_idx ON macrostrat.intervals USING btree (age_top); -- --- Name: intervals_new_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- Name: intervals_new_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres -- -CREATE INDEX intervals_new_id_idx1 ON macrostrat.intervals USING btree (id); +CREATE INDEX intervals_new_id_idx ON macrostrat.intervals USING btree (id); -- --- Name: intervals_new_interval_name_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- Name: intervals_new_interval_name_idx; Type: INDEX; Schema: macrostrat; Owner: postgres -- -CREATE INDEX intervals_new_interval_name_idx1 ON macrostrat.intervals USING btree (interval_name); +CREATE INDEX intervals_new_interval_name_idx ON macrostrat.intervals USING btree (interval_name); -- --- Name: intervals_new_interval_type_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- Name: intervals_new_interval_type_idx; Type: INDEX; Schema: macrostrat; Owner: postgres -- -CREATE INDEX intervals_new_interval_type_idx1 ON macrostrat.intervals USING btree (interval_type); +CREATE INDEX intervals_new_interval_type_idx ON macrostrat.intervals USING btree (interval_type); -- @@ -2720,24 +3061,24 @@ CREATE INDEX lith_atts_new_lith_att_idx1 ON macrostrat.lith_atts USING btree (li -- --- Name: liths_new_lith_class_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- Name: liths_new_lith_class_idx; Type: INDEX; Schema: macrostrat; Owner: postgres -- -CREATE INDEX liths_new_lith_class_idx1 ON macrostrat.liths USING btree (lith_class); +CREATE INDEX liths_new_lith_class_idx ON macrostrat.liths USING btree (lith_class); -- --- Name: liths_new_lith_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- Name: liths_new_lith_idx; Type: INDEX; Schema: macrostrat; Owner: postgres -- -CREATE INDEX liths_new_lith_idx1 ON macrostrat.liths USING btree (lith); +CREATE INDEX liths_new_lith_idx ON macrostrat.liths USING btree (lith); -- --- Name: liths_new_lith_type_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- Name: liths_new_lith_type_idx; Type: INDEX; Schema: macrostrat; Owner: postgres -- -CREATE INDEX liths_new_lith_type_idx1 ON macrostrat.liths USING btree (lith_type); +CREATE INDEX liths_new_lith_type_idx ON macrostrat.liths USING btree (lith_type); -- @@ -2846,24 +3187,45 @@ CREATE INDEX lookup_units_new_t_int_idx1 ON macrostrat.lookup_units USING btree -- --- Name: measuremeta_new_lith_att_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- Name: measurements_new_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX measurements_new_id_idx ON macrostrat.measurements USING btree (id); + + +-- +-- Name: measurements_new_measurement_class_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX measurements_new_measurement_class_idx ON macrostrat.measurements USING btree (measurement_class); + + +-- +-- Name: measurements_new_measurement_type_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX measurements_new_measurement_type_idx ON macrostrat.measurements USING btree (measurement_type); + + +-- +-- Name: measuremeta_new_lith_att_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres -- -CREATE INDEX measuremeta_new_lith_att_id_idx1 ON macrostrat.measuremeta USING btree (lith_att_id); +CREATE INDEX measuremeta_new_lith_att_id_idx ON macrostrat.measuremeta USING btree (lith_att_id); -- --- Name: measuremeta_new_lith_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- Name: measuremeta_new_lith_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres -- -CREATE INDEX measuremeta_new_lith_id_idx1 ON macrostrat.measuremeta USING btree (lith_id); +CREATE INDEX measuremeta_new_lith_id_idx ON macrostrat.measuremeta USING btree (lith_id); -- --- Name: measuremeta_new_ref_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- Name: measuremeta_new_ref_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres -- -CREATE INDEX measuremeta_new_ref_id_idx1 ON macrostrat.measuremeta USING btree (ref_id); +CREATE INDEX measuremeta_new_ref_id_idx ON macrostrat.measuremeta USING btree (ref_id); -- @@ -2909,31 +3271,59 @@ CREATE INDEX pbdb_collections_new_late_age_idx ON macrostrat.pbdb_collections US -- --- Name: places_new_geom_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- Name: places_new_geom_idx; Type: INDEX; Schema: macrostrat; Owner: postgres -- -CREATE INDEX places_new_geom_idx1 ON macrostrat.places USING gist (geom); +CREATE INDEX places_new_geom_idx ON macrostrat.places USING gist (geom); -- --- Name: refs_new_rgeom_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- Name: projects_new_project_idx; Type: INDEX; Schema: macrostrat; Owner: postgres -- -CREATE INDEX refs_new_rgeom_idx1 ON macrostrat.refs USING gist (rgeom); +CREATE INDEX projects_new_project_idx ON macrostrat.projects USING btree (project); -- --- Name: strat_name_footprints_new_geom_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- Name: projects_new_timescale_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres -- -CREATE INDEX strat_name_footprints_new_geom_idx ON macrostrat.strat_name_footprints USING gist (geom); +CREATE INDEX projects_new_timescale_id_idx ON macrostrat.projects USING btree (timescale_id); -- --- Name: strat_name_footprints_new_strat_name_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- Name: refs_new_rgeom_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres -- -CREATE INDEX strat_name_footprints_new_strat_name_id_idx ON macrostrat.strat_name_footprints USING btree (strat_name_id); +CREATE INDEX refs_new_rgeom_idx1 ON macrostrat.refs USING gist (rgeom); + + +-- +-- Name: sections_new_col_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX sections_new_col_id_idx ON macrostrat.sections USING btree (col_id); + + +-- +-- Name: sections_new_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX sections_new_id_idx ON macrostrat.sections USING btree (id); + + +-- +-- Name: strat_name_footprints_new_geom_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX strat_name_footprints_new_geom_idx ON macrostrat.strat_name_footprints USING gist (geom); + + +-- +-- Name: strat_name_footprints_new_strat_name_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX strat_name_footprints_new_strat_name_id_idx ON macrostrat.strat_name_footprints USING btree (strat_name_id); -- @@ -2993,31 +3383,52 @@ CREATE INDEX strat_names_new_strat_name_idx ON macrostrat.strat_names USING btre -- --- Name: strat_names_places_new_place_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- Name: strat_names_places_new_place_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX strat_names_places_new_place_id_idx ON macrostrat.strat_names_places USING btree (place_id); + + +-- +-- Name: strat_names_places_new_strat_name_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX strat_names_places_new_strat_name_id_idx ON macrostrat.strat_names_places USING btree (strat_name_id); + + +-- +-- Name: strat_tree_new_child_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- + +CREATE INDEX strat_tree_new_child_idx1 ON macrostrat.strat_tree USING btree (child); + + +-- +-- Name: strat_tree_new_parent_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres -- -CREATE INDEX strat_names_places_new_place_id_idx1 ON macrostrat.strat_names_places USING btree (place_id); +CREATE INDEX strat_tree_new_parent_idx1 ON macrostrat.strat_tree USING btree (parent); -- --- Name: strat_names_places_new_strat_name_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- Name: strat_tree_new_ref_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres -- -CREATE INDEX strat_names_places_new_strat_name_id_idx1 ON macrostrat.strat_names_places USING btree (strat_name_id); +CREATE INDEX strat_tree_new_ref_id_idx1 ON macrostrat.strat_tree USING btree (ref_id); -- --- Name: timescales_intervals_new_interval_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- Name: timescales_intervals_new_interval_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres -- -CREATE INDEX timescales_intervals_new_interval_id_idx1 ON macrostrat.timescales_intervals USING btree (interval_id); +CREATE INDEX timescales_intervals_new_interval_id_idx ON macrostrat.timescales_intervals USING btree (interval_id); -- --- Name: timescales_intervals_new_timescale_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- Name: timescales_intervals_new_timescale_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres -- -CREATE INDEX timescales_intervals_new_timescale_id_idx1 ON macrostrat.timescales_intervals USING btree (timescale_id); +CREATE INDEX timescales_intervals_new_timescale_id_idx ON macrostrat.timescales_intervals USING btree (timescale_id); -- @@ -3098,24 +3509,24 @@ CREATE INDEX unit_lith_atts_new_unit_lith_id_idx1 ON macrostrat.unit_lith_atts U -- --- Name: unit_liths_new_lith_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- Name: unit_liths_new_lith_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres -- -CREATE INDEX unit_liths_new_lith_id_idx1 ON macrostrat.unit_liths USING btree (lith_id); +CREATE INDEX unit_liths_new_lith_id_idx ON macrostrat.unit_liths USING btree (lith_id); -- --- Name: unit_liths_new_ref_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- Name: unit_liths_new_ref_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres -- -CREATE INDEX unit_liths_new_ref_id_idx1 ON macrostrat.unit_liths USING btree (ref_id); +CREATE INDEX unit_liths_new_ref_id_idx ON macrostrat.unit_liths USING btree (ref_id); -- --- Name: unit_liths_new_unit_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- Name: unit_liths_new_unit_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres -- -CREATE INDEX unit_liths_new_unit_id_idx1 ON macrostrat.unit_liths USING btree (unit_id); +CREATE INDEX unit_liths_new_unit_id_idx ON macrostrat.unit_liths USING btree (unit_id); -- @@ -3140,17 +3551,17 @@ CREATE INDEX unit_measures_new_unit_id_idx ON macrostrat.unit_measures USING btr -- --- Name: unit_strat_names_new_strat_name_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- Name: unit_strat_names_new_strat_name_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres -- -CREATE INDEX unit_strat_names_new_strat_name_id_idx1 ON macrostrat.unit_strat_names USING btree (strat_name_id); +CREATE INDEX unit_strat_names_new_strat_name_id_idx ON macrostrat.unit_strat_names USING btree (strat_name_id); -- --- Name: unit_strat_names_new_unit_id_idx1; Type: INDEX; Schema: macrostrat; Owner: postgres +-- Name: unit_strat_names_new_unit_id_idx; Type: INDEX; Schema: macrostrat; Owner: postgres -- -CREATE INDEX unit_strat_names_new_unit_id_idx1 ON macrostrat.unit_strat_names USING btree (unit_id); +CREATE INDEX unit_strat_names_new_unit_id_idx ON macrostrat.unit_strat_names USING btree (unit_id); -- @@ -3217,6 +3628,13 @@ CREATE OR REPLACE VIEW macrostrat_api.col_group_with_cols AS GROUP BY cg.id, c.project_id; +-- +-- Name: projects project_instead_insert; Type: TRIGGER; Schema: macrostrat_api; Owner: api_views_owner +-- + +CREATE TRIGGER project_instead_insert INSTEAD OF INSERT ON macrostrat_api.projects FOR EACH ROW EXECUTE FUNCTION macrostrat_api.project_insert(); + + -- -- Name: col_areas col_areas_col_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres -- @@ -3225,6 +3643,14 @@ ALTER TABLE ONLY macrostrat.col_areas ADD CONSTRAINT col_areas_col_id_fkey FOREIGN KEY (col_id) REFERENCES macrostrat.cols(id) ON DELETE CASCADE; +-- +-- Name: col_areas col_areas_col_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.col_areas + ADD CONSTRAINT col_areas_col_id_fkey1 FOREIGN KEY (col_id) REFERENCES macrostrat.cols(id) ON DELETE CASCADE; + + -- -- Name: col_groups col_groups_project_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres -- @@ -3241,6 +3667,14 @@ ALTER TABLE ONLY macrostrat.col_refs ADD CONSTRAINT col_refs_col_id_fkey FOREIGN KEY (col_id) REFERENCES macrostrat.cols(id) ON DELETE CASCADE; +-- +-- Name: col_refs col_refs_col_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.col_refs + ADD CONSTRAINT col_refs_col_id_fkey1 FOREIGN KEY (col_id) REFERENCES macrostrat.cols(id) ON DELETE CASCADE; + + -- -- Name: col_refs col_refs_ref_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres -- @@ -3249,6 +3683,14 @@ ALTER TABLE ONLY macrostrat.col_refs ADD CONSTRAINT col_refs_ref_id_fkey FOREIGN KEY (ref_id) REFERENCES macrostrat.refs(id) ON DELETE CASCADE; +-- +-- Name: col_refs col_refs_ref_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.col_refs + ADD CONSTRAINT col_refs_ref_id_fkey1 FOREIGN KEY (ref_id) REFERENCES macrostrat.refs(id) ON DELETE CASCADE; + + -- -- Name: cols cols_col_group_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres -- @@ -3257,6 +3699,14 @@ ALTER TABLE ONLY macrostrat.cols ADD CONSTRAINT cols_col_group_id_fkey FOREIGN KEY (col_group_id) REFERENCES macrostrat.col_groups(id) ON DELETE CASCADE; +-- +-- Name: cols cols_col_group_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.cols + ADD CONSTRAINT cols_col_group_id_fkey1 FOREIGN KEY (col_group_id) REFERENCES macrostrat.col_groups(id) ON DELETE CASCADE; + + -- -- Name: cols cols_project_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres -- @@ -3265,6 +3715,14 @@ ALTER TABLE ONLY macrostrat.cols ADD CONSTRAINT cols_project_id_fkey FOREIGN KEY (project_id) REFERENCES macrostrat.projects(id) ON DELETE CASCADE; +-- +-- Name: cols cols_project_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.cols + ADD CONSTRAINT cols_project_id_fkey1 FOREIGN KEY (project_id) REFERENCES macrostrat.projects(id) ON DELETE CASCADE; + + -- -- Name: concepts_places concepts_places_place_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres -- @@ -3273,20 +3731,44 @@ ALTER TABLE ONLY macrostrat.concepts_places ADD CONSTRAINT concepts_places_place_id_fkey FOREIGN KEY (place_id) REFERENCES macrostrat.places(place_id) ON DELETE CASCADE; +-- +-- Name: concepts_places concepts_places_place_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.concepts_places + ADD CONSTRAINT concepts_places_place_id_fkey1 FOREIGN KEY (place_id) REFERENCES macrostrat.places(place_id) ON DELETE CASCADE; + + -- -- Name: projects projects_timescale_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres -- ALTER TABLE ONLY macrostrat.projects - ADD CONSTRAINT projects_timescale_id_fkey FOREIGN KEY (timescale_id) REFERENCES macrostrat.timescales(id); + ADD CONSTRAINT projects_timescale_id_fkey FOREIGN KEY (timescale_id) REFERENCES macrostrat.timescales(id) ON DELETE CASCADE; -- --- Name: strat_names strat_names_parent_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- Name: projects projects_timescale_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres -- -ALTER TABLE ONLY macrostrat.strat_names - ADD CONSTRAINT strat_names_parent_fkey FOREIGN KEY (parent) REFERENCES macrostrat.strat_names(id); +ALTER TABLE ONLY macrostrat.projects + ADD CONSTRAINT projects_timescale_id_fkey1 FOREIGN KEY (timescale_id) REFERENCES macrostrat.timescales(id) ON DELETE CASCADE; + + +-- +-- Name: sections sections_col_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.sections + ADD CONSTRAINT sections_col_id_fkey FOREIGN KEY (col_id) REFERENCES macrostrat.cols(id) ON DELETE CASCADE; + + +-- +-- Name: sections sections_col_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.sections + ADD CONSTRAINT sections_col_id_fkey1 FOREIGN KEY (col_id) REFERENCES macrostrat.cols(id) ON DELETE CASCADE; -- @@ -3297,6 +3779,14 @@ ALTER TABLE ONLY macrostrat.strat_names_places ADD CONSTRAINT strat_names_places_place_id_fkey FOREIGN KEY (place_id) REFERENCES macrostrat.places(place_id) ON DELETE CASCADE; +-- +-- Name: strat_names_places strat_names_places_place_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.strat_names_places + ADD CONSTRAINT strat_names_places_place_id_fkey1 FOREIGN KEY (place_id) REFERENCES macrostrat.places(place_id) ON DELETE CASCADE; + + -- -- Name: strat_names_places strat_names_places_strat_name_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres -- @@ -3305,6 +3795,62 @@ ALTER TABLE ONLY macrostrat.strat_names_places ADD CONSTRAINT strat_names_places_strat_name_id_fkey FOREIGN KEY (strat_name_id) REFERENCES macrostrat.strat_names(id) ON DELETE CASCADE; +-- +-- Name: strat_names_places strat_names_places_strat_name_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.strat_names_places + ADD CONSTRAINT strat_names_places_strat_name_id_fkey1 FOREIGN KEY (strat_name_id) REFERENCES macrostrat.strat_names(id) ON DELETE CASCADE; + + +-- +-- Name: strat_tree strat_tree_child_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.strat_tree + ADD CONSTRAINT strat_tree_child_fkey FOREIGN KEY (child) REFERENCES macrostrat.strat_names(id) ON DELETE CASCADE; + + +-- +-- Name: strat_tree strat_tree_child_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.strat_tree + ADD CONSTRAINT strat_tree_child_fkey1 FOREIGN KEY (child) REFERENCES macrostrat.strat_names(id) ON DELETE CASCADE; + + +-- +-- Name: strat_tree strat_tree_parent_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.strat_tree + ADD CONSTRAINT strat_tree_parent_fkey FOREIGN KEY (parent) REFERENCES macrostrat.strat_names(id) ON DELETE CASCADE; + + +-- +-- Name: strat_tree strat_tree_parent_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.strat_tree + ADD CONSTRAINT strat_tree_parent_fkey1 FOREIGN KEY (parent) REFERENCES macrostrat.strat_names(id) ON DELETE CASCADE; + + +-- +-- Name: strat_tree strat_tree_ref_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.strat_tree + ADD CONSTRAINT strat_tree_ref_id_fkey FOREIGN KEY (ref_id) REFERENCES macrostrat.refs(id) ON DELETE CASCADE; + + +-- +-- Name: strat_tree strat_tree_ref_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.strat_tree + ADD CONSTRAINT strat_tree_ref_id_fkey1 FOREIGN KEY (ref_id) REFERENCES macrostrat.refs(id) ON DELETE CASCADE; + + -- -- Name: timescales_intervals timescales_intervals_interval_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres -- @@ -3313,6 +3859,14 @@ ALTER TABLE ONLY macrostrat.timescales_intervals ADD CONSTRAINT timescales_intervals_interval_id_fkey FOREIGN KEY (interval_id) REFERENCES macrostrat.intervals(id) ON DELETE CASCADE; +-- +-- Name: timescales_intervals timescales_intervals_interval_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.timescales_intervals + ADD CONSTRAINT timescales_intervals_interval_id_fkey1 FOREIGN KEY (interval_id) REFERENCES macrostrat.intervals(id) ON DELETE CASCADE; + + -- -- Name: timescales_intervals timescales_intervals_timescale_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres -- @@ -3321,6 +3875,14 @@ ALTER TABLE ONLY macrostrat.timescales_intervals ADD CONSTRAINT timescales_intervals_timescale_id_fkey FOREIGN KEY (timescale_id) REFERENCES macrostrat.timescales(id) ON DELETE CASCADE; +-- +-- Name: timescales_intervals timescales_intervals_timescale_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.timescales_intervals + ADD CONSTRAINT timescales_intervals_timescale_id_fkey1 FOREIGN KEY (timescale_id) REFERENCES macrostrat.timescales(id) ON DELETE CASCADE; + + -- -- Name: unit_econs unit_econs_econ_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres -- @@ -3329,6 +3891,14 @@ ALTER TABLE ONLY macrostrat.unit_econs ADD CONSTRAINT unit_econs_econ_id_fkey FOREIGN KEY (econ_id) REFERENCES macrostrat.econs(id) ON DELETE CASCADE; +-- +-- Name: unit_econs unit_econs_econ_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_econs + ADD CONSTRAINT unit_econs_econ_id_fkey1 FOREIGN KEY (econ_id) REFERENCES macrostrat.econs(id) ON DELETE CASCADE; + + -- -- Name: unit_econs unit_econs_ref_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres -- @@ -3337,6 +3907,14 @@ ALTER TABLE ONLY macrostrat.unit_econs ADD CONSTRAINT unit_econs_ref_id_fkey FOREIGN KEY (ref_id) REFERENCES macrostrat.refs(id) ON DELETE CASCADE; +-- +-- Name: unit_econs unit_econs_ref_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_econs + ADD CONSTRAINT unit_econs_ref_id_fkey1 FOREIGN KEY (ref_id) REFERENCES macrostrat.refs(id) ON DELETE CASCADE; + + -- -- Name: unit_econs unit_econs_unit_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres -- @@ -3345,6 +3923,14 @@ ALTER TABLE ONLY macrostrat.unit_econs ADD CONSTRAINT unit_econs_unit_id_fkey FOREIGN KEY (unit_id) REFERENCES macrostrat.units(id) ON DELETE CASCADE; +-- +-- Name: unit_econs unit_econs_unit_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_econs + ADD CONSTRAINT unit_econs_unit_id_fkey1 FOREIGN KEY (unit_id) REFERENCES macrostrat.units(id) ON DELETE CASCADE; + + -- -- Name: unit_environs unit_environs_environ_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres -- @@ -3353,6 +3939,14 @@ ALTER TABLE ONLY macrostrat.unit_environs ADD CONSTRAINT unit_environs_environ_id_fkey FOREIGN KEY (environ_id) REFERENCES macrostrat.environs(id) ON DELETE CASCADE; +-- +-- Name: unit_environs unit_environs_environ_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_environs + ADD CONSTRAINT unit_environs_environ_id_fkey1 FOREIGN KEY (environ_id) REFERENCES macrostrat.environs(id) ON DELETE CASCADE; + + -- -- Name: unit_environs unit_environs_ref_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres -- @@ -3361,6 +3955,14 @@ ALTER TABLE ONLY macrostrat.unit_environs ADD CONSTRAINT unit_environs_ref_id_fkey FOREIGN KEY (ref_id) REFERENCES macrostrat.refs(id) ON DELETE CASCADE; +-- +-- Name: unit_environs unit_environs_ref_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_environs + ADD CONSTRAINT unit_environs_ref_id_fkey1 FOREIGN KEY (ref_id) REFERENCES macrostrat.refs(id) ON DELETE CASCADE; + + -- -- Name: unit_environs unit_environs_unit_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres -- @@ -3369,6 +3971,14 @@ ALTER TABLE ONLY macrostrat.unit_environs ADD CONSTRAINT unit_environs_unit_id_fkey FOREIGN KEY (unit_id) REFERENCES macrostrat.units(id) ON DELETE CASCADE; +-- +-- Name: unit_environs unit_environs_unit_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_environs + ADD CONSTRAINT unit_environs_unit_id_fkey1 FOREIGN KEY (unit_id) REFERENCES macrostrat.units(id) ON DELETE CASCADE; + + -- -- Name: unit_lith_atts unit_lith_atts_lith_att_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres -- @@ -3377,6 +3987,14 @@ ALTER TABLE ONLY macrostrat.unit_lith_atts ADD CONSTRAINT unit_lith_atts_lith_att_id_fkey FOREIGN KEY (lith_att_id) REFERENCES macrostrat.lith_atts(id) ON DELETE CASCADE; +-- +-- Name: unit_lith_atts unit_lith_atts_lith_att_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_lith_atts + ADD CONSTRAINT unit_lith_atts_lith_att_id_fkey1 FOREIGN KEY (lith_att_id) REFERENCES macrostrat.lith_atts(id) ON DELETE CASCADE; + + -- -- Name: unit_lith_atts unit_lith_atts_unit_lith_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres -- @@ -3385,6 +4003,14 @@ ALTER TABLE ONLY macrostrat.unit_lith_atts ADD CONSTRAINT unit_lith_atts_unit_lith_id_fkey FOREIGN KEY (unit_lith_id) REFERENCES macrostrat.unit_liths(id) ON DELETE CASCADE; +-- +-- Name: unit_lith_atts unit_lith_atts_unit_lith_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_lith_atts + ADD CONSTRAINT unit_lith_atts_unit_lith_id_fkey1 FOREIGN KEY (unit_lith_id) REFERENCES macrostrat.unit_liths(id) ON DELETE CASCADE; + + -- -- Name: unit_liths unit_liths_lith_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres -- @@ -3393,6 +4019,14 @@ ALTER TABLE ONLY macrostrat.unit_liths ADD CONSTRAINT unit_liths_lith_id_fkey FOREIGN KEY (lith_id) REFERENCES macrostrat.liths(id) ON DELETE CASCADE; +-- +-- Name: unit_liths unit_liths_lith_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_liths + ADD CONSTRAINT unit_liths_lith_id_fkey1 FOREIGN KEY (lith_id) REFERENCES macrostrat.liths(id) ON DELETE CASCADE; + + -- -- Name: unit_liths unit_liths_unit_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres -- @@ -3401,6 +4035,14 @@ ALTER TABLE ONLY macrostrat.unit_liths ADD CONSTRAINT unit_liths_unit_id_fkey FOREIGN KEY (unit_id) REFERENCES macrostrat.units(id) ON DELETE CASCADE; +-- +-- Name: unit_liths unit_liths_unit_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_liths + ADD CONSTRAINT unit_liths_unit_id_fkey1 FOREIGN KEY (unit_id) REFERENCES macrostrat.units(id) ON DELETE CASCADE; + + -- -- Name: unit_strat_names unit_strat_names_strat_name_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres -- @@ -3409,6 +4051,14 @@ ALTER TABLE ONLY macrostrat.unit_strat_names ADD CONSTRAINT unit_strat_names_strat_name_id_fkey FOREIGN KEY (strat_name_id) REFERENCES macrostrat.strat_names(id) ON DELETE CASCADE; +-- +-- Name: unit_strat_names unit_strat_names_strat_name_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_strat_names + ADD CONSTRAINT unit_strat_names_strat_name_id_fkey1 FOREIGN KEY (strat_name_id) REFERENCES macrostrat.strat_names(id) ON DELETE CASCADE; + + -- -- Name: unit_strat_names unit_strat_names_unit_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres -- @@ -3417,6 +4067,14 @@ ALTER TABLE ONLY macrostrat.unit_strat_names ADD CONSTRAINT unit_strat_names_unit_id_fkey FOREIGN KEY (unit_id) REFERENCES macrostrat.units(id) ON DELETE CASCADE; +-- +-- Name: unit_strat_names unit_strat_names_unit_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.unit_strat_names + ADD CONSTRAINT unit_strat_names_unit_id_fkey1 FOREIGN KEY (unit_id) REFERENCES macrostrat.units(id) ON DELETE CASCADE; + + -- -- Name: units units_col_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres -- @@ -3425,6 +4083,14 @@ ALTER TABLE ONLY macrostrat.units ADD CONSTRAINT units_col_id_fkey FOREIGN KEY (col_id) REFERENCES macrostrat.cols(id) ON DELETE CASCADE; +-- +-- Name: units units_col_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.units + ADD CONSTRAINT units_col_id_fkey1 FOREIGN KEY (col_id) REFERENCES macrostrat.cols(id) ON DELETE CASCADE; + + -- -- Name: units units_fo_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres -- @@ -3433,6 +4099,14 @@ ALTER TABLE ONLY macrostrat.units ADD CONSTRAINT units_fo_fkey FOREIGN KEY (fo) REFERENCES macrostrat.intervals(id) ON DELETE CASCADE; +-- +-- Name: units units_fo_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.units + ADD CONSTRAINT units_fo_fkey1 FOREIGN KEY (fo) REFERENCES macrostrat.intervals(id) ON DELETE CASCADE; + + -- -- Name: units units_lo_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres -- @@ -3441,6 +4115,703 @@ ALTER TABLE ONLY macrostrat.units ADD CONSTRAINT units_lo_fkey FOREIGN KEY (lo) REFERENCES macrostrat.intervals(id) ON DELETE CASCADE; +-- +-- Name: units units_lo_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.units + ADD CONSTRAINT units_lo_fkey1 FOREIGN KEY (lo) REFERENCES macrostrat.intervals(id) ON DELETE CASCADE; + + +-- +-- Name: units units_section_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.units + ADD CONSTRAINT units_section_id_fkey FOREIGN KEY (section_id) REFERENCES macrostrat.sections(id) ON DELETE CASCADE; + + +-- +-- Name: units units_section_id_fkey1; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.units + ADD CONSTRAINT units_section_id_fkey1 FOREIGN KEY (section_id) REFERENCES macrostrat.sections(id) ON DELETE CASCADE; + + +-- +-- Name: units units_strat_name_id_fkey; Type: FK CONSTRAINT; Schema: macrostrat; Owner: postgres +-- + +ALTER TABLE ONLY macrostrat.units + ADD CONSTRAINT units_strat_name_id_fkey FOREIGN KEY (strat_name_id) REFERENCES macrostrat.strat_names(id) ON DELETE CASCADE; + + +-- +-- Name: SCHEMA macrostrat; Type: ACL; Schema: -; Owner: postgres +-- + +GRANT USAGE ON SCHEMA macrostrat TO api_views_owner; + + +-- +-- Name: SCHEMA macrostrat_api; Type: ACL; Schema: -; Owner: postgres +-- + +GRANT USAGE ON SCHEMA macrostrat_api TO api_views_owner; + + +-- +-- Name: TABLE autocomplete; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.autocomplete TO api_views_owner; + + +-- +-- Name: TABLE col_areas; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.col_areas TO api_views_owner; + + +-- +-- Name: SEQUENCE col_areas_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.col_areas_id_seq TO api_views_owner; + + +-- +-- Name: TABLE col_groups; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.col_groups TO api_views_owner; + + +-- +-- Name: SEQUENCE col_groups_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.col_groups_id_seq TO api_views_owner; + + +-- +-- Name: TABLE col_refs; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.col_refs TO api_views_owner; + + +-- +-- Name: SEQUENCE col_refs_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.col_refs_id_seq TO api_views_owner; + + +-- +-- Name: TABLE cols; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.cols TO api_views_owner; + + +-- +-- Name: SEQUENCE cols_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.cols_id_seq TO api_views_owner; + + +-- +-- Name: TABLE concepts_places; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.concepts_places TO api_views_owner; + + +-- +-- Name: TABLE econs; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.econs TO api_views_owner; + + +-- +-- Name: SEQUENCE econs_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.econs_id_seq TO api_views_owner; + + +-- +-- Name: TABLE environs; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.environs TO api_views_owner; + + +-- +-- Name: SEQUENCE environs_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.environs_id_seq TO api_views_owner; + + +-- +-- Name: TABLE grainsize; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.grainsize TO api_views_owner; + + +-- +-- Name: SEQUENCE grainsize_grain_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.grainsize_grain_id_seq TO api_views_owner; + + +-- +-- Name: TABLE intervals; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.intervals TO api_views_owner; + + +-- +-- Name: SEQUENCE intervals_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.intervals_id_seq TO api_views_owner; + + +-- +-- Name: SEQUENCE intervals_new_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.intervals_new_id_seq TO api_views_owner; + + +-- +-- Name: TABLE lith_atts; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.lith_atts TO api_views_owner; + + +-- +-- Name: SEQUENCE lith_atts_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.lith_atts_id_seq TO api_views_owner; + + +-- +-- Name: TABLE liths; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.liths TO api_views_owner; + + +-- +-- Name: SEQUENCE liths_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.liths_id_seq TO api_views_owner; + + +-- +-- Name: TABLE lookup_strat_names; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.lookup_strat_names TO api_views_owner; + + +-- +-- Name: TABLE lookup_unit_attrs_api; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.lookup_unit_attrs_api TO api_views_owner; + + +-- +-- Name: TABLE lookup_unit_intervals; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.lookup_unit_intervals TO api_views_owner; + + +-- +-- Name: TABLE lookup_unit_liths; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.lookup_unit_liths TO api_views_owner; + + +-- +-- Name: TABLE lookup_units; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.lookup_units TO api_views_owner; + + +-- +-- Name: SEQUENCE lookup_units_unit_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.lookup_units_unit_id_seq TO api_views_owner; + + +-- +-- Name: TABLE measurements; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.measurements TO api_views_owner; + + +-- +-- Name: SEQUENCE measurements_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.measurements_id_seq TO api_views_owner; + + +-- +-- Name: SEQUENCE measurements_new_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.measurements_new_id_seq TO api_views_owner; + + +-- +-- Name: SEQUENCE measurements_new_id_seq1; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.measurements_new_id_seq1 TO api_views_owner; + + +-- +-- Name: TABLE measuremeta; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.measuremeta TO api_views_owner; + + +-- +-- Name: SEQUENCE measuremeta_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.measuremeta_id_seq TO api_views_owner; + + +-- +-- Name: SEQUENCE measuremeta_new_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.measuremeta_new_id_seq TO api_views_owner; + + +-- +-- Name: TABLE measures; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.measures TO api_views_owner; + + +-- +-- Name: SEQUENCE measures_new_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.measures_new_id_seq TO api_views_owner; + + +-- +-- Name: TABLE pbdb_collections; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.pbdb_collections TO api_views_owner; + + +-- +-- Name: TABLE pbdb_collections_strat_names; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.pbdb_collections_strat_names TO api_views_owner; + + +-- +-- Name: TABLE places; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.places TO api_views_owner; + + +-- +-- Name: SEQUENCE places_place_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.places_place_id_seq TO api_views_owner; + + +-- +-- Name: TABLE projects; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.projects TO api_views_owner; + + +-- +-- Name: SEQUENCE projects_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.projects_id_seq TO api_views_owner; + + +-- +-- Name: SEQUENCE projects_new_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.projects_new_id_seq TO api_views_owner; + + +-- +-- Name: TABLE refs; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.refs TO api_views_owner; + + +-- +-- Name: SEQUENCE refs_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.refs_id_seq TO api_views_owner; + + +-- +-- Name: TABLE sections; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.sections TO api_views_owner; + + +-- +-- Name: SEQUENCE sections_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.sections_id_seq TO api_views_owner; + + +-- +-- Name: SEQUENCE sections_new_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.sections_new_id_seq TO api_views_owner; + + +-- +-- Name: TABLE strat_name_footprints; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.strat_name_footprints TO api_views_owner; + + +-- +-- Name: TABLE strat_names; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.strat_names TO api_views_owner; + + +-- +-- Name: SEQUENCE strat_names_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.strat_names_id_seq TO api_views_owner; + + +-- +-- Name: TABLE strat_names_meta; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.strat_names_meta TO api_views_owner; + + +-- +-- Name: SEQUENCE strat_names_meta_concept_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.strat_names_meta_concept_id_seq TO api_views_owner; + + +-- +-- Name: SEQUENCE strat_names_new_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.strat_names_new_id_seq TO api_views_owner; + + +-- +-- Name: TABLE strat_names_places; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.strat_names_places TO api_views_owner; + + +-- +-- Name: TABLE strat_tree; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.strat_tree TO api_views_owner; + + +-- +-- Name: SEQUENCE strat_tree_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.strat_tree_id_seq TO api_views_owner; + + +-- +-- Name: SEQUENCE strat_tree_new_id_seq1; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.strat_tree_new_id_seq1 TO api_views_owner; + + +-- +-- Name: TABLE timescales; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.timescales TO api_views_owner; + + +-- +-- Name: SEQUENCE timescales_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.timescales_id_seq TO api_views_owner; + + +-- +-- Name: TABLE timescales_intervals; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.timescales_intervals TO api_views_owner; + + +-- +-- Name: TABLE unit_econs; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.unit_econs TO api_views_owner; + + +-- +-- Name: SEQUENCE unit_econs_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.unit_econs_id_seq TO api_views_owner; + + +-- +-- Name: TABLE unit_environs; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.unit_environs TO api_views_owner; + + +-- +-- Name: SEQUENCE unit_environs_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.unit_environs_id_seq TO api_views_owner; + + +-- +-- Name: TABLE unit_lith_atts; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.unit_lith_atts TO api_views_owner; + + +-- +-- Name: SEQUENCE unit_lith_atts_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.unit_lith_atts_id_seq TO api_views_owner; + + +-- +-- Name: TABLE unit_liths; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.unit_liths TO api_views_owner; + + +-- +-- Name: SEQUENCE unit_liths_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.unit_liths_id_seq TO api_views_owner; + + +-- +-- Name: TABLE unit_measures; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.unit_measures TO api_views_owner; + + +-- +-- Name: SEQUENCE unit_measures_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.unit_measures_id_seq TO api_views_owner; + + +-- +-- Name: SEQUENCE unit_measures_new_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.unit_measures_new_id_seq TO api_views_owner; + + +-- +-- Name: TABLE unit_strat_names; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.unit_strat_names TO api_views_owner; + + +-- +-- Name: SEQUENCE unit_strat_names_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.unit_strat_names_id_seq TO api_views_owner; + + +-- +-- Name: SEQUENCE unit_strat_names_new_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.unit_strat_names_new_id_seq TO api_views_owner; + + +-- +-- Name: TABLE units; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.units TO api_views_owner; + + +-- +-- Name: SEQUENCE units_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.units_id_seq TO api_views_owner; + + +-- +-- Name: TABLE units_sections; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat.units_sections TO api_views_owner; + + +-- +-- Name: SEQUENCE units_sections_id_seq; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.units_sections_id_seq TO api_views_owner; + + +-- +-- Name: SEQUENCE units_sections_new_id_seq1; Type: ACL; Schema: macrostrat; Owner: postgres +-- + +GRANT SELECT,USAGE ON SEQUENCE macrostrat.units_sections_new_id_seq1 TO api_views_owner; + + +-- +-- Name: TABLE col_form; Type: ACL; Schema: macrostrat_api; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat_api.col_form TO api_views_owner; + + +-- +-- Name: TABLE col_group_view; Type: ACL; Schema: macrostrat_api; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat_api.col_group_view TO api_views_owner; + + +-- +-- Name: TABLE col_sections; Type: ACL; Schema: macrostrat_api; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat_api.col_sections TO api_views_owner; + + +-- +-- Name: TABLE econ_unit; Type: ACL; Schema: macrostrat_api; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat_api.econ_unit TO api_views_owner; + + +-- +-- Name: TABLE environ_unit; Type: ACL; Schema: macrostrat_api; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat_api.environ_unit TO api_views_owner; + + +-- +-- Name: TABLE lith_attr_unit; Type: ACL; Schema: macrostrat_api; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat_api.lith_attr_unit TO api_views_owner; + + +-- +-- Name: TABLE lith_unit; Type: ACL; Schema: macrostrat_api; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat_api.lith_unit TO api_views_owner; + + +-- +-- Name: TABLE sections; Type: ACL; Schema: macrostrat_api; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat_api.sections TO api_views_owner; + + +-- +-- Name: TABLE strat_names; Type: ACL; Schema: macrostrat_api; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat_api.strat_names TO api_views_owner; + + +-- +-- Name: TABLE unit_environs; Type: ACL; Schema: macrostrat_api; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat_api.unit_environs TO api_views_owner; + + +-- +-- Name: TABLE units_view; Type: ACL; Schema: macrostrat_api; Owner: postgres +-- + +GRANT SELECT,INSERT,DELETE,UPDATE ON TABLE macrostrat_api.units_view TO api_views_owner; + + -- -- PostgreSQL database dump complete -- diff --git a/v2-transition/services/column-builder/database/tests/fixtures/test_auth_inserts.sql b/v2-transition/services/column-builder/database/tests/fixtures/test_auth_inserts.sql index 0969d9f8d..e96e1af6c 100644 --- a/v2-transition/services/column-builder/database/tests/fixtures/test_auth_inserts.sql +++ b/v2-transition/services/column-builder/database/tests/fixtures/test_auth_inserts.sql @@ -1,2 +1,5 @@ -INSERT INTO auth.users(email, pass, projects,role) VALUES - ('fake_man@fake.com', 'fakepassword', '{1}','owner_'); \ No newline at end of file +INSERT INTO auth.users(email, pass) VALUES + ('fake_man@fake.com', 'fakepassword'); + +INSERT INTO auth.user_projects(user_, project, privilege) VALUES + (1, 1, 'owner'); \ No newline at end of file diff --git a/v2-transition/services/column-builder/database/tests/fixtures/test_inserts.sql b/v2-transition/services/column-builder/database/tests/fixtures/test_inserts.sql index 60bf685a0..82cb9c49c 100644 --- a/v2-transition/services/column-builder/database/tests/fixtures/test_inserts.sql +++ b/v2-transition/services/column-builder/database/tests/fixtures/test_inserts.sql @@ -366,6 +366,43 @@ VALUES (141,1,1,E'column',E'active',E'',17,E'Potomac Estuary',38.45,-76.729,4441.5,E'0101000020E61000002DB29DEFA72E53C09A99999999394340',E'POINT(-76.729 38.45)',NULL,E'0103000020E61000000100000006000000E25A101C644853C0A5D8D7D0693343403C110B88123853C01BE801CA366F43404A0E5E4D420A53C010EDCC17715043406FEDAC7DA70453C013BE3F22822C4340178D12EAEC3953C02906359739164340E25A101C644853C0A5D8D7D069334340'), (112,1,1,E'column',E'active',E'',19,E'Northern Coastal Plain',38.766,-77.308,3616.431,E'0101000020E6100000C1CAA145B65353C0355EBA490C624340',E'POINT(-77.308 38.766)',NULL,E'0103000020E61000000100000008000000B60914F84E6553C0F5F79A51536D43404377082BFF6053C0B7E1A9C7828E4340441DFF7B0B4253C046471DBFF390434040088ED8FC3D53C0CBEA7D8F7A8A43403C110B88123853C01BE801CA366F4340E25A101C644853C0A5D8D7D069334340992CBF18DB5453C0EAAEF55E582F4340B60914F84E6553C0F5F79A51536D4340'); +INSERT INTO "macrostrat"."sections"("id","col_id") +VALUES +(871,112), +(872,112), +(873,112), +(874,112), +(875,112), +(876,112), +(877,112), +(878,112), +(879,112), +(880,112), +(881,112), +(883,112), +(884,112), +(1037,125), +(1038,125), +(1039,125), +(1040,125), +(1041,125), +(1042,125), +(1043,125), +(1044,125), +(1045,125), +(1046,125), +(1047,125), +(1048,125), +(1049,125), +(1165,141), +(1166,141), +(1167,141), +(1168,141), +(1169,141), +(1170,141), +(1171,141), +(1172,141), +(1173,141); INSERT INTO "macrostrat"."units"("id","strat_name","color","outcrop","fo","lo","position_bottom","position_top","max_thick","min_thick","section_id","col_id") VALUES diff --git a/v2-transition/services/column-builder/docker-compose.yaml b/v2-transition/services/column-builder/docker-compose.yaml index 6b37ac17d..5fd44ca17 100644 --- a/v2-transition/services/column-builder/docker-compose.yaml +++ b/v2-transition/services/column-builder/docker-compose.yaml @@ -8,9 +8,11 @@ services: ports: - "3001:3000" environment: - PGRST_DB_URI: ${PGRST_DB_URI} + PGRST_DB_URI: postgres://${AUTH_PGUSER}:@db:5432/${POSTGRES_DB} PGRST_DB_SCHEMA: macrostrat_api - PGRST_DB_ANON_ROLE: ${PGUSER} + PGRST_JWT_SECRET: ${PGRST_JWT_SECRET} + PGRST_DB_ANON_ROLE: ${PGRST_DB_ANON_ROLE} + PGRST_OPENAPI_SERVER_PROXY_URI: http://127.0.0.1:3001 depends_on: - db db: @@ -20,6 +22,8 @@ services: - dev environment: - PGUSER + - POSTGRES_DB + # This allows connections without a password, which is expedient but insecure... - POSTGRES_HOST_AUTH_METHOD=trust ports: - ${PG_PORT}:5432