inspected_tables = mutate_inspected( inspected.tables_and_views, [ { "type": "modified", "filters": (lambda row: row['table_object_id'] == 16488), "column_filters": (lambda col: col['column_name'] == "productline"), "metadata": { "field": "columns.ordinal_position", "new_value": 4, }, }, { "type": "modified", "filters": (lambda row: row['table_object_id'] == 16488), "column_filters": (lambda col: col['column_name'] == "productscale"), "metadata": { "field": "columns.ordinal_position", "new_value": 3, }, }, { "type": "modified", "filters": (lambda row: row['table_object_id'] == 16488), "column_filters": (lambda col: col['column_name'] == "productscale"), "metadata": { "field": "columns.column_name", "new_value": "scale", }, }, # Rename for MySQL would also change the `object_id` value. { "type": "modified", "filters": (lambda row: row['table_object_id'] == 16488), "column_filters": (lambda col: col['column_name'] == "scale"), "metadata": { "field": "columns.column_object_id", "new_value": "16488/scale", }, }, ])
category VARCHAR(40) NOT NULL, dept_name VARCHAR(40) NOT NULL, dept_head INT NOT NULL, PRIMARY KEY (id), UNIQUE (dept_name) ); """ from app.revisioner.tests.e2e import inspected from app.revisioner.tests.test_e2e import mutate_inspected preload_fixtures = ['datastore'] inspected_tables = mutate_inspected(inspected.tables_and_views, [ { "type": "dropped", "filters": (lambda row: row['table_object_id'] == 16522), }, ]) inspected_tables += [{ "schema_object_id": 16441, "table_schema": "app", "table_object_id": 26522, "table_name": "departments", "table_type": "base table", "properties": {},
""" Update the name of an index (`app`.`departments_pkey`). Example SQL: ALTER TABLE `app`.`departments_pkey` RENAME TO `departments_primary_key`; """ from app.revisioner.tests.e2e import inspected from app.revisioner.tests.test_e2e import mutate_inspected preload_fixtures = ['datastore'] inspected_tables = mutate_inspected(inspected.tables_and_views, []) inspected_indexes = mutate_inspected( inspected.indexes, [{ "type": "modified", "filters": (lambda row: row['index_object_id'] == 16528), "metadata": { "field": "index_name", "new_value": "departments_primary_key", } }]) test_cases = [ { "model": "Index", "description":
Example SQL: ALTER SCHEMA `app` RENAME `public`; """ from app.revisioner.tests.e2e import inspected from app.revisioner.tests.test_e2e import mutate_inspected preload_fixtures = ['datastore'] inspected_tables = mutate_inspected(inspected.tables_and_views, [ { "type": "modified", "filters": ( lambda row: row["schema_object_id"] == 16441 ), "metadata": { "field": "table_schema", "new_value": "public", }, }, ]) inspected_indexes = mutate_inspected(inspected.indexes, []) test_cases = [ { "model": "Schema", "description": "Expect the `app` schema to be renamed to `public`.", "filters": { "name": "public", "object_id": "16441",
inspected_tables = mutate_inspected(inspected.tables_and_views, [ # (1) We renamed the table `employee.departments` to `employee.depts`. { "type": "modified", "filters": ( lambda row: row['table_object_id'] == 16392 ), "metadata": { "field": "table_name", "new_value": "depts", }, }, # (2) We dropped the `app`.`productlines` table at some point. { "type": "dropped", "filters": ( lambda row: row['table_object_id'] == 16456 ), }, # (3) We dropped the `app`.`productlines` table at some point. { "type": "dropped", "filters": ( lambda row: row['table_object_id'] == 16488 ), "column_filters": ( lambda col: col['column_object_id'] == "16488/9" ), }, # (4) The column `app`.`customers`.`postalcode` has a `default_value` change. { "type": "modified", "filters": ( lambda row: row['table_object_id'] == 16442 ), "column_filters": ( lambda col: col['column_name'] == "postalcode" ), "metadata": { "field": "columns.default_value", "new_value": "default_sequence()", }, }, # (5) The column `app`.`orders`.`status` has a data type change. { "type": "modified", "filters": ( lambda row: row['table_object_id'] == 16465 ), "column_filters": ( lambda col: col['column_name'] == "status" ), "metadata": { "field": "columns.data_type", "new_value": "integer", }, }, # (6) Comment was added to a resource. { "type": "modified", "filters": ( lambda row: row['table_object_id'] == 16442 ), "column_filters": ( lambda col: col['column_name'] == "postalcode" ), "metadata": { "field": "columns.column_description", "new_value": "5-digit mailing code", }, }, { "type": "modified", "filters": ( lambda row: row['table_object_id'] == 16465 ), "column_filters": ( lambda col: col['column_name'] == "status" ), "metadata": { "field": "columns.max_length", "new_value": 50, }, }, { "type": "modified", "filters": ( lambda row: row['table_object_id'] == 16465 ), "column_filters": ( lambda col: col['column_name'] == "status" ), "metadata": { "field": "columns.numeric_scale", "new_value": 0, }, }, # (6) The column `app`.`orders`.`amount` is changed. { "type": "modified", "filters": ( lambda row: row['table_object_id'] == 16478 ), "column_filters": ( lambda col: col['column_name'] == "amount" ), "metadata": { "field": "columns.is_nullable", "new_value": True, }, }, { "type": "modified", "filters": ( lambda row: row['table_object_id'] == 16478 ), "column_filters": ( lambda col: col['column_name'] == "amount" ), "metadata": { "field": "columns.column_name", "new_value": "dollar_amount", }, }, ])
""" Drop one column from an index (`app`.`orderdetails_pkey`). """ from app.revisioner.tests.e2e import inspected from app.revisioner.tests.test_e2e import mutate_inspected preload_fixtures = ['datastore'] inspected_tables = mutate_inspected(inspected.tables_and_views, [ { "type": "dropped", "filters": (lambda row: row['table_object_id'] == 16501), "column_filters": (lambda col: col['column_name'] == "ordernumber"), }, ]) inspected_indexes = mutate_inspected(inspected.indexes, [ { "type": "dropped", "filters": (lambda row: row['index_object_id'] == 16504), "column_filters": (lambda col: col['column_name'] == "ordernumber"), }, { "type": "modified", "filters": (lambda row: row['index_object_id'] == 16504), "column_filters": (lambda col: col['column_name'] == "productcode"), "metadata": { "field": "columns.ordinal_position", "new_value": 1, } },
""" Tests when a fresh Datastore is added. No other items exist in the workspace. """ from app.revisioner.tests.e2e import inspected from app.revisioner.tests.test_e2e import mutate_inspected preload_fixtures = [] inspected_tables = mutate_inspected(inspected.tables_and_views, []) inspected_indexes = mutate_inspected(inspected.indexes, []) test_cases = [ { "description": "Expect new schemas to be created.", "assertions": [ { "evaluation": lambda datastore, nulled: set( datastore.schemas.values_list("name", flat=True)), "pass_value": { "app", "employees", }, }, { "description": "Expect first time created columns to be dropped from the revision logs.", "evaluation": lambda datastore, nulled: datastore.most_recent_run.revisions.
""" from app.revisioner.tests.e2e import inspected from app.revisioner.tests.test_e2e import mutate_inspected preload_fixtures = ['datastore'] inspected_tables = mutate_inspected(inspected.tables_and_views, [ { "type": "modified", "filters": (lambda row: row['table_object_id'] == 16442), "metadata": { "field": "table_schema", "new_value": "employees", }, }, { "type": "modified", "filters": (lambda row: row['table_object_id'] == 16442), "metadata": { "field": "schema_object_id", "new_value": 16386, }, }, ]) inspected_indexes = mutate_inspected(inspected.indexes, []) test_cases = [ { "model": "Table",
""" Drop an index (`app`.`orderdetails_pkey`) and re-create it with additional columns. """ from app.revisioner.tests.e2e import inspected from app.revisioner.tests.test_e2e import mutate_inspected preload_fixtures = ['datastore'] inspected_tables = mutate_inspected(inspected.tables_and_views, []) inspected_indexes = mutate_inspected(inspected.indexes, [ { "type": "dropped", "filters": (lambda row: row['table_object_id'] == 16392), }, { "type": "dropped", "filters": (lambda row: row['index_object_id'] == 16504), }, { "type": "modified", "filters": (lambda row: row['table_object_id'] == 16478), "column_filters": (lambda col: col['column_name'] == "amount"), "metadata": { "field": "columns.is_nullable", "new_value": True, }, }, { "type": "modified", "filters": (lambda row: row['table_object_id'] == 16478),