Skip to content

Commit 4ff171e

Browse files
committed
Made some migrations production-ready
1 parent 2bdccaa commit 4ff171e

File tree

12 files changed

+31
-71
lines changed

12 files changed

+31
-71
lines changed

.idea/dataSources.xml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/macrostrat.iml

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

py-modules/cli/macrostrat/cli/entrypoint.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22
from pathlib import Path
33

44
import typer
5-
from rich import print
6-
from rich.traceback import install
7-
from typer import Argument, Typer
8-
95
from macrostrat.app_frame import CommandBase
106
from macrostrat.core import app
117
from macrostrat.core.exc import MacrostratError
128
from macrostrat.core.main import env_text, set_app_state
139
from macrostrat.utils.shell import run
10+
from rich import print
11+
from rich.traceback import install
12+
from typer import Argument, Typer
1413

1514
from .database import db_app, db_subsystem
1615
from .schema_management import schema_app
@@ -439,7 +438,6 @@ def state():
439438

440439
# TODO: subsystem dependencies
441440
from .subsystems.core import core_schema
442-
from .subsystems.macrostrat_api import macrostrat_api
443441

444442
# Add basic schema hunks
445443
from .subsystems.xdd import text_vector_schema, xdd_schema
@@ -448,7 +446,6 @@ def state():
448446
db_subsystem.schema_hunks.append(core_schema)
449447
db_subsystem.schema_hunks.append(xdd_schema)
450448
db_subsystem.schema_hunks.append(text_vector_schema)
451-
db_subsystem.schema_hunks.append(macrostrat_api)
452449

453450
# Discover subsystems in third-party packages
454451
# https://packaging.python.org/en/latest/guides/creating-and-discovering-plugins/

py-modules/cli/macrostrat/cli/subsystems/macrostrat_api/__init__.py

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,16 @@
33
primarily in Macrostrat's column-builder application and set of routes.
44
"""
55

6+
from macrostrat.app_frame import compose
67
from pathlib import Path
78

8-
from macrostrat.app_frame import compose
99
from macrostrat.core import MacrostratSubsystem
10-
from macrostrat.core.migrations import Migration, view_exists
11-
12-
from ...database import SubsystemSchemaDefinition, get_db
10+
from ...database import get_db
1311
from ...database.utils import setup_postgrest_access
1412

1513
__here__ = Path(__file__).parent
1614
fixtures_dir = __here__ / "schema"
1715

18-
macrostrat_api = SubsystemSchemaDefinition(
19-
name="macrostrat-api",
20-
fixtures=[fixtures_dir, setup_postgrest_access("macrostrat_api")],
21-
)
22-
23-
# TODO: align schema migrations/fixtures with subsystems
24-
2516

2617
class MacrostratAPISubsystem(MacrostratSubsystem):
2718
name = "macrostrat-api"
@@ -47,13 +38,3 @@ def on_schema_update(self):
4738
# fully reloaded the schema.
4839
if self.app.settings.get("compose_root", None) is not None:
4940
compose("kill -s SIGUSR1 postgrest")
50-
51-
52-
class MacrostratAPIMigration(Migration):
53-
name = "macrostrat-api"
54-
readiness_state = "ga"
55-
postconditions = [view_exists("macrostrat_api", "projects")]
56-
57-
def apply(self, db):
58-
db.run_fixtures(fixtures_dir)
59-
setup_postgrest_access("macrostrat_api")(db)

py-modules/cli/macrostrat/cli/subsystems/sgp/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
Subsystem for SGP matching
33
"""
44

5+
from pathlib import Path
56
from typer import Typer
67

78
from macrostrat.cli.database import get_db
8-
99
from .match import log_matches, match_sgp_data_cmd
10-
from .migrations import *
1110
from .paleogeography import compute_paleo_positions
1211
from .utils import get_sgp_db
1312

py-modules/cli/macrostrat/cli/subsystems/sgp/migrations.py

Lines changed: 0 additions & 31 deletions
This file was deleted.

schema/_migrations/api_v3/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ class BaselineMigration(Migration):
1414
postconditions = [
1515
exists("storage", "object"),
1616
exists("maps_metadata", "ingest_process", "ingest_process_tag"),
17-
exists("macrostrat_auth", "user", "group"),
17+
exists("macrostrat_auth", "user", ),
1818
]

schema/_migrations/composite_projects/__init__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
from pathlib import Path
22

3-
from macrostrat.core.migrations import Migration, _not, exists, has_columns
3+
from macrostrat.core.migrations import (
4+
Migration,
5+
_not,
6+
exists,
7+
has_columns,
8+
ReadinessState,
9+
)
410

511

612
def check_slug_not_nullable(db):
@@ -34,6 +40,7 @@ class CompositeProjects(Migration):
3440
description = "Composite projects support"
3541
preconditions = [_not(a) for a in success]
3642
postconditions = success
43+
readiness_state = ReadinessState.GA
3744
fixtures = [
3845
here / "projects-evolution.sql",
3946
]
@@ -44,6 +51,7 @@ class CompositeProjectFunctions(Migration):
4451
subsystem = "columns"
4552
description = "Composite projects functions"
4653
depends_on = ["composite-projects"]
54+
readiness_state = ReadinessState.GA
4755
always_apply = True
4856
fixtures = [
4957
here / "project-functions.sql",

schema/_migrations/ingest_preprocess_updates/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class IngestPreprocessUpdates(Migration):
1111
subsystem = "maps"
1212
description = "Align maps_metadata.ingest_process table across envs."
1313
depends_on = ["ingest-state-type"]
14+
readiness_state = "ga"
1415

1516
preconditions = [
1617
has_columns("maps_metadata", "ingest_process", "id"),

schema/_migrations/maps_ingest_state_custom_type/__init__.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
from macrostrat.core.migrations import Migration, _not, custom_type_exists
21
from macrostrat.database import Database, Identifier
32

3+
from macrostrat.core.migrations import (
4+
Migration,
5+
_not,
6+
custom_type_exists,
7+
ReadinessState,
8+
)
9+
410

511
def ingest_type_exists_in_wrong_schema(db: Database) -> bool:
612
schemas = ["macrostrat_backup", "macrostrat", "public"]
@@ -18,8 +24,7 @@ class MapsIngestStateCustomTypeMigration(Migration):
1824
- Relocate custom types that drives the map ingestion process.
1925
- Remove duplicate custom types from the public schema.
2026
"""
21-
22-
depends_on = ["baseline", "macrostrat-mariadb"]
27+
readiness_state = ReadinessState.GA
2328

2429
postconditions = [
2530
custom_type_exists("maps", "ingest_state"),

0 commit comments

Comments
 (0)