@biffo/cli 0.338.0 → 0.340.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +51 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3487,7 +3487,7 @@ var REGISTERED_ADOPTION_PAIRS = [
|
|
|
3487
3487
|
templateFile: "infra/environments/dev/core-api.core.tf",
|
|
3488
3488
|
userFile: "infra/environments/dev/main.tf",
|
|
3489
3489
|
adoptedPattern: new RegExp(NO_CORE_API_MODULE_SOURCE, "m"),
|
|
3490
|
-
remedy: 'Run `biffo core upgrade` to receive `core-api.core.tf` (or equivalent), then delete the `module "core_api" { ... }` block from infra/environments/dev/main.tf (first move
|
|
3490
|
+
remedy: 'Run `biffo core upgrade` to receive `core-api.core.tf` (or equivalent), then delete the `module "core_api" { ... }` block from infra/environments/dev/main.tf (first move instance-only environment variables into `local.core_api_instance_environment` in infra/environments/dev/core-api.instance.tf, and memory/SnapStart/timeout into terraform.tfvars as `core_api_memory_size` / `core_api_enable_warm_capacity` / `core_api_timeout`), then run `terraform plan` and confirm module.core_api shows no changes to destroy/create.'
|
|
3491
3491
|
}
|
|
3492
3492
|
];
|
|
3493
3493
|
function isAdopted(pair, userFileContent) {
|
|
@@ -7262,6 +7262,44 @@ generated = sync_plugin_migrations(migrations / "versions", services_root=servic
|
|
|
7262
7262
|
print(f"bootstrap: generated {len(generated)} plugin migration(s)", flush=True)
|
|
7263
7263
|
cfg = Config(str(Path.cwd() / "alembic.ini"))
|
|
7264
7264
|
cfg.set_main_option("script_location", str(migrations))
|
|
7265
|
+
|
|
7266
|
+
# \`plugin verify\` provisions the plugin's manifest tables before Core boots, so the generated
|
|
7267
|
+
# plugin migration (plain op.create_table) would collide with them. Make table/column/index
|
|
7268
|
+
# creation idempotent for this disposable bootstrap run only.
|
|
7269
|
+
import sqlalchemy as sa # noqa: E402
|
|
7270
|
+
from alembic import op # noqa: E402
|
|
7271
|
+
|
|
7272
|
+
_create_table, _create_index, _add_column = op.create_table, op.create_index, op.add_column
|
|
7273
|
+
_skipped_tables: set = set()
|
|
7274
|
+
|
|
7275
|
+
|
|
7276
|
+
def _insp():
|
|
7277
|
+
return sa.inspect(op.get_bind())
|
|
7278
|
+
|
|
7279
|
+
|
|
7280
|
+
def _create_table_if_absent(name, *args, **kw):
|
|
7281
|
+
if _insp().has_table(name, schema=kw.get("schema")):
|
|
7282
|
+
_skipped_tables.add(name)
|
|
7283
|
+
return None
|
|
7284
|
+
return _create_table(name, *args, **kw)
|
|
7285
|
+
|
|
7286
|
+
|
|
7287
|
+
def _create_index_if_absent(name, table, *args, **kw):
|
|
7288
|
+
if table in _skipped_tables:
|
|
7289
|
+
return None
|
|
7290
|
+
return _create_index(name, table, *args, **kw)
|
|
7291
|
+
|
|
7292
|
+
|
|
7293
|
+
def _add_column_if_absent(table, column, **kw):
|
|
7294
|
+
if any(c["name"] == column.name for c in _insp().get_columns(table, schema=kw.get("schema"))):
|
|
7295
|
+
return None
|
|
7296
|
+
return _add_column(table, column, **kw)
|
|
7297
|
+
|
|
7298
|
+
|
|
7299
|
+
op.create_table = _create_table_if_absent
|
|
7300
|
+
op.create_index = _create_index_if_absent
|
|
7301
|
+
op.add_column = _add_column_if_absent
|
|
7302
|
+
|
|
7265
7303
|
command.upgrade(cfg, "head")
|
|
7266
7304
|
print("bootstrap: alembic upgrade head complete", flush=True)
|
|
7267
7305
|
`;
|
|
@@ -12708,10 +12746,21 @@ from alembic import context
|
|
|
12708
12746
|
from sqlalchemy.ext.asyncio import create_async_engine
|
|
12709
12747
|
|
|
12710
12748
|
|
|
12749
|
+
PLUGIN_VERSION_TABLE = "alembic_version_plugin_manifest"
|
|
12750
|
+
|
|
12751
|
+
|
|
12711
12752
|
async def run() -> None:
|
|
12712
12753
|
engine = create_async_engine(os.environ["BIFFO_DATABASE_URL"])
|
|
12713
12754
|
async with engine.connect() as connection:
|
|
12714
|
-
await connection.run_sync(lambda c: context.configure(
|
|
12755
|
+
await connection.run_sync(lambda c: context.configure(
|
|
12756
|
+
connection=c,
|
|
12757
|
+
target_metadata=None,
|
|
12758
|
+
# Own version table: the default \`alembic_version\` is Core's, and a plugin-only
|
|
12759
|
+
# revision recorded there makes Core's own migrations look applied (or fail on
|
|
12760
|
+
# an unknown head) when Core boots, leaving its tables (users, ...) missing.
|
|
12761
|
+
version_table=PLUGIN_VERSION_TABLE,
|
|
12762
|
+
)
|
|
12763
|
+
)
|
|
12715
12764
|
async with connection.begin():
|
|
12716
12765
|
await connection.run_sync(lambda _: context.run_migrations())
|
|
12717
12766
|
await engine.dispose()
|