Skip to content

Commit

Permalink
OA: moved DB tables to public schema
Browse files Browse the repository at this point in the history
  • Loading branch information
ErnestaP committed Apr 18, 2024
1 parent 0f6e950 commit 25a121a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
11 changes: 4 additions & 7 deletions dags/migrations/versions/64ac526a078b_my_db_revision.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,19 @@


def upgrade():
op.execute("CREATE SCHEMA IF NOT EXISTS oa")
op.create_table(
"oa.open_access",
"oa_open_access",
sa.Column("year", sa.Integer, primary_key=True),
sa.Column("closed_access", sa.Integer, nullable=False),
sa.Column("bronze_open_access", sa.Integer, nullable=False),
sa.Column("green_open_access", sa.Integer, nullable=False),
sa.Column("gold_open_access", sa.Integer, nullable=False),
sa.Column("created_at", sa.TIMESTAMP(timezone=True), nullable=False),
sa.Column("updated_at", sa.TIMESTAMP(timezone=True), nullable=False),
schema="oa",
)

op.create_table(
"oa.golden_open_access",
"oa_golden_open_access",
sa.Column("year", sa.Integer, primary_key=True),
sa.Column("cern_read_and_publish", sa.Integer, nullable=False),
sa.Column("cern_individual_apcs", sa.Integer, nullable=False),
Expand All @@ -41,10 +39,9 @@ def upgrade():
sa.Column("other_collective_models", sa.Integer, nullable=False),
sa.Column("created_at", sa.TIMESTAMP(timezone=True), nullable=False),
sa.Column("updated_at", sa.TIMESTAMP(timezone=True), nullable=False),
schema="oa",
)


def downgrade():
op.drop_table("oa.golden_open_access", schema="oa")
op.drop_table("oa.open_access", schema="oa")
op.drop_table("oa_golden_open_access")
op.drop_table("oa_open_access")
3 changes: 1 addition & 2 deletions dags/open_access/gold_open_access_mechanisms.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ def join(values, **kwargs):
task_id="populate_golden_open_access",
postgres_conn_id="superset_qa",
sql="""
SET search_path TO oa;
INSERT INTO "oa.golden_open_access" (year, cern_read_and_publish, cern_individual_apcs,
INSERT INTO oa_golden_open_access (year, cern_read_and_publish, cern_individual_apcs,
scoap3, other, other_collective_models, created_at, updated_at)
VALUES (%(years)s, %(cern_read_and_publish)s, %(cern_individual_apcs)s,
%(scoap3)s, %(other)s, %(other_collective_models)s,
Expand Down
3 changes: 1 addition & 2 deletions dags/open_access/open_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ def join(values, **kwargs):
task_id="populate_open_access_table",
postgres_conn_id="superset_qa",
sql="""
SET search_path TO oa;
INSERT INTO "oa.open_access" (year, closed_access, bronze_open_access,
INSERT INTO oa_open_access (year, closed_access, bronze_open_access,
green_open_access, gold_open_access, created_at, updated_at)
VALUES (%(years)s, %(closed)s, %(bronze)s, %(green)s, %(gold)s,
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)
Expand Down

0 comments on commit 25a121a

Please sign in to comment.