diff --git a/.envrc b/.envrc index 32fd448864a..8d890cc823f 100644 --- a/.envrc +++ b/.envrc @@ -100,7 +100,23 @@ export APPLICATION=app # Migration Path export MIGRATION_PATH="file://${MYMOVE_DIR}/migrations/app/schema;file://${MYMOVE_DIR}/migrations/app/secure" -export MIGRATION_MANIFEST="${MYMOVE_DIR}/migrations/app/migrations_manifest.txt" +export MIGRATION_MANIFEST="${MYMOVE_DIR}/migrations/app/migrations_manifest.txt" ##deprecated +export DML_MIGRATION_MANIFEST="${MYMOVE_DIR}/migrations/app/dml_migrations_manifest.txt" + +# DDL Migrations +export DDL_TYPES_MIGRATION_PATH="file://${MYMOVE_DIR}/migrations/app/ddl_migrations/ddl_types" +export DDL_TYPES_MIGRATION_MANIFEST="${MYMOVE_DIR}/migrations/app/ddl_types_manifest.txt" + +export DDL_TABLES_MIGRATION_PATH="file://${MYMOVE_DIR}/migrations/app/ddl_migrations/ddl_tables" +export DDL_TABLES_MIGRATION_MANIFEST="${MYMOVE_DIR}/migrations/app/ddl_tables_manifest.txt" + +export DDL_VIEWS_MIGRATION_PATH="file://${MYMOVE_DIR}/migrations/app/ddl_migrations/ddl_views" +export DDL_VIEWS_MIGRATION_MANIFEST="${MYMOVE_DIR}/migrations/app/ddl_views_manifest.txt" + +export DDL_FUNCTIONS_MIGRATION_PATH="file://${MYMOVE_DIR}/migrations/app/ddl_migrations/ddl_functions" +export DDL_FUNCTIONS_MIGRATION_MANIFEST="${MYMOVE_DIR}/migrations/app/ddl_functions_manifest.txt" + + # Default DB configuration export DB_PASSWORD=mysecretpassword diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f83d084326b..38013700a29 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -220,7 +220,16 @@ stages: export DB_HOST=localhost export DB_PORT=5432 export MIGRATION_MANIFEST='/builds/milmove/mymove/migrations/app/migrations_manifest.txt' + export DML_MIGRATION_MANIFEST='/builds/milmove/mymove/migrations/app/dml_migrations_manifest.txt' + export DDL_TYPES_MIGRATION_MANIFEST='/builds/milmove/mymove/migrations/app/ddl_types_manifest.txt' + export DDL_TABLES_MIGRATION_MANIFEST='/builds/milmove/mymove/migrations/app/ddl_types_manifest.txt' + export DDL_VIEWS_MIGRATION_MANIFEST='/builds/milmove/mymove/migrations/app/ddl_types_manifest.txt' + export DDL_FUNCTIONS_MIGRATION_MANIFEST='/builds/milmove/mymove/migrations/app/ddl_types_manifest.txt' export MIGRATION_PATH='file:///builds/milmove/mymove/migrations/app/schema;file:///builds/milmove/mymove/migrations/app/secure' + export DDL_TYPES_MIGRATION_PATH='file:///builds/milmove/mymove/migrations/app/ddl_migrations/ddl_types' + export DDL_TABLES_MIGRATION_PATH='file:///builds/milmove/mymove/migrations/app/ddl_migrations/ddl_tables' + export DDL_VIEWS_MIGRATION_PATH='file:///builds/milmove/mymove/migrations/app/ddl_migrations/ddl_views' + export DDL_FUNCTIONS_MIGRATION_PATH='file:///builds/milmove/mymove/migrations/app/ddl_migrations/ddl_functions' export EIA_KEY=db2522a43820268a41a802a16ae9fd26 .setup_devseed_env_variables: &setup_devseed_env_variables @@ -789,7 +798,16 @@ server_test: DB_NAME_TEST: test_db DTOD_USE_MOCK: 'true' MIGRATION_MANIFEST: '/builds/milmove/mymove/migrations/app/migrations_manifest.txt' + DML_MIGRATION_MANIFEST: '/builds/milmove/mymove/migrations/app/dml_migrations_manifest.txt' + DDL_TYPES_MIGRATION_MANIFEST: '/builds/milmove/mymove/migrations/app/ddl_types_manifest.txt' + DDL_TABLES_MIGRATION_MANIFEST: '/builds/milmove/mymove/migrations/app/ddl_tables_manifest.txt' + DDL_VIEWS_MIGRATION_MANIFEST: '/builds/milmove/mymove/migrations/app/ddl_views_manifest.txt' + DDL_FUNCTIONS_MIGRATION_MANIFEST: '/builds/milmove/mymove/migrations/app/ddl_functions_manifest.txt' MIGRATION_PATH: 'file:///builds/milmove/mymove/migrations/app/schema;file:///builds/milmove/mymove/migrations/app/secure' + DDL_TYPES_MIGRATION_PATH: 'file:///builds/milmove/mymove/migrations/app/ddl_migrations/ddl_types' + DDL_TABLES_MIGRATION_PATH: 'file:///builds/milmove/mymove/migrations/app/ddl_migrations/ddl_tables' + DDL_VIEWS_MIGRATION_PATH: 'file:///builds/milmove/mymove/migrations/app/ddl_migrations/ddl_views' + DDL_FUNCTIONS_MIGRATION_PATH: 'file:///builds/milmove/mymove/migrations/app/ddl_migrations/ddl_functions' EIA_KEY: db2522a43820268a41a802a16ae9fd26 # dummy key generated with openssl rand -hex 16 ENV: test ENVIRONMENT: test @@ -948,7 +966,16 @@ integration_test_devseed: DB_NAME: dev_db DB_NAME_DEV: dev_db MIGRATION_MANIFEST: '/builds/milmove/mymove/migrations/app/migrations_manifest.txt' + DML_MIGRATION_MANIFEST: '/builds/milmove/mymove/migrations/app/dml_migrations_manifest.txt' + DDL_TYPES_MIGRATION_MANIFEST: '/builds/milmove/mymove/migrations/app/ddl_types_manifest.txt' + DDL_TABLES_MIGRATION_MANIFEST: '/builds/milmove/mymove/migrations/app/ddl_tables_manifest.txt' + DDL_VIEWS_MIGRATION_MANIFEST: '/builds/milmove/mymove/migrations/app/ddl_views_manifest.txt' + DDL_FUNCTIONS_MIGRATION_MANIFEST: '/builds/milmove/mymove/migrations/app/ddl_functions_manifest.txt' MIGRATION_PATH: 'file:///builds/milmove/mymove/migrations/app/schema;file:///builds/milmove/mymove/migrations/app/secure' + DDL_TYPES_MIGRATION_PATH: 'file:///builds/milmove/mymove/migrations/app/ddl_migrations/ddl_types' + DDL_TABLES_MIGRATION_PATH: 'file:///builds/milmove/mymove/migrations/app/ddl_migrations/ddl_tables' + DDL_VIEWS_MIGRATION_PATH: 'file:///builds/milmove/mymove/migrations/app/ddl_migrations/ddl_views' + DDL_FUNCTIONS_MIGRATION_PATH: 'file:///builds/milmove/mymove/migrations/app/ddl_migrations/ddl_functions' EIA_KEY: db2522a43820268a41a802a16ae9fd26 # dummy key generated with openssl rand -hex 16 ENVIRONMENT: development DOD_CA_PACKAGE: /builds/milmove/mymove/config/tls/milmove-cert-bundle.p7b @@ -1023,7 +1050,16 @@ integration_test_mtls: DB_NAME: dev_db DB_NAME_DEV: dev_db MIGRATION_MANIFEST: '/builds/milmove/mymove/migrations/app/migrations_manifest.txt' + DML_MIGRATION_MANIFEST: '/builds/milmove/mymove/migrations/app/dml_migrations_manifest.txt' + DDL_TYPES_MIGRATION_MANIFEST: '/builds/milmove/mymove/migrations/app/ddl_types_manifest.txt' + DDL_TABLES_MIGRATION_MANIFEST: '/builds/milmove/mymove/migrations/app/ddl_tables_manifest.txt' + DDL_VIEWS_MIGRATION_MANIFEST: '/builds/milmove/mymove/migrations/app/ddl_views_manifest.txt' + DDL_FUNCTIONS_MIGRATION_MANIFEST: '/builds/milmove/mymove/migrations/app/ddl_functions_manifest.txt' MIGRATION_PATH: 'file:///builds/milmove/mymove/migrations/app/schema;file:///builds/milmove/mymove/migrations/app/secure' + DDL_TYPES_MIGRATION_PATH: 'file:///builds/milmove/mymove/migrations/app/ddl_migrations/ddl_types' + DDL_TABLES_MIGRATION_PATH: 'file:///builds/milmove/mymove/migrations/app/ddl_migrations/ddl_tables' + DDL_VIEWS_MIGRATION_PATH: 'file:///builds/milmove/mymove/migrations/app/ddl_migrations/ddl_views' + DDL_FUNCTIONS_MIGRATION_PATH: 'file:///builds/milmove/mymove/migrations/app/ddl_migrations/ddl_functions' EIA_KEY: db2522a43820268a41a802a16ae9fd26 # dummy key generated with openssl rand -hex 16 ENVIRONMENT: development DOD_CA_PACKAGE: /builds/milmove/mymove/config/tls/milmove-cert-bundle.p7b @@ -1076,7 +1112,16 @@ integration_test_admin: DB_NAME: dev_db DB_NAME_DEV: dev_db MIGRATION_MANIFEST: '/builds/milmove/mymove/migrations/app/migrations_manifest.txt' + DML_MIGRATION_MANIFEST: '/builds/milmove/mymove/migrations/app/dml_migrations_manifest.txt' + DDL_TYPES_MIGRATION_MANIFEST: '/builds/milmove/mymove/migrations/app/ddl_types_manifest.txt' + DDL_TABLES_MIGRATION_MANIFEST: '/builds/milmove/mymove/migrations/app/ddl_tables_manifest.txt' + DDL_VIEWS_MIGRATION_MANIFEST: '/builds/milmove/mymove/migrations/app/ddl_views_manifest.txt' + DDL_FUNCTIONS_MIGRATION_MANIFEST: '/builds/milmove/mymove/migrations/app/ddl_functions_manifest.txt' MIGRATION_PATH: 'file:///builds/milmove/mymove/migrations/app/schema;file:///builds/milmove/mymove/migrations/app/secure' + DDL_TYPES_MIGRATION_PATH: 'file:///builds/milmove/mymove/migrations/app/ddl_migrations/ddl_types' + DDL_TABLES_MIGRATION_PATH: 'file:///builds/milmove/mymove/migrations/app/ddl_migrations/ddl_tables' + DDL_VIEWS_MIGRATION_PATH: 'file:///builds/milmove/mymove/migrations/app/ddl_migrations/ddl_views' + DDL_FUNCTIONS_MIGRATION_PATH: 'file:///builds/milmove/mymove/migrations/app/ddl_migrations/ddl_functions' EIA_KEY: db2522a43820268a41a802a16ae9fd26 # dummy key generated with openssl rand -hex 16 ENVIRONMENT: development DOD_CA_PACKAGE: /builds/milmove/mymove/config/tls/milmove-cert-bundle.p7b @@ -1134,7 +1179,16 @@ integration_test_my: DB_NAME: dev_db DB_NAME_DEV: dev_db MIGRATION_MANIFEST: '/builds/milmove/mymove/migrations/app/migrations_manifest.txt' + DML_MIGRATION_MANIFEST: '/builds/milmove/mymove/migrations/app/dml_migrations_manifest.txt' + DDL_TYPES_MIGRATION_MANIFEST: '/builds/milmove/mymove/migrations/app/ddl_types_manifest.txt' + DDL_TABLES_MIGRATION_MANIFEST: '/builds/milmove/mymove/migrations/app/ddl_tables_manifest.txt' + DDL_VIEWS_MIGRATION_MANIFEST: '/builds/milmove/mymove/migrations/app/ddl_views_manifest.txt' + DDL_FUNCTIONS_MIGRATION_MANIFEST: '/builds/milmove/mymove/migrations/app/ddl_functions_manifest.txt' MIGRATION_PATH: 'file:///builds/milmove/mymove/migrations/app/schema;file:///builds/milmove/mymove/migrations/app/secure' + DDL_TYPES_MIGRATION_PATH: 'file:///builds/milmove/mymove/migrations/app/ddl_migrations/ddl_types' + DDL_TABLES_MIGRATION_PATH: 'file:///builds/milmove/mymove/migrations/app/ddl_migrations/ddl_tables' + DDL_VIEWS_MIGRATION_PATH: 'file:///builds/milmove/mymove/migrations/app/ddl_migrations/ddl_views' + DDL_FUNCTIONS_MIGRATION_PATH: 'file:///builds/milmove/mymove/migrations/app/ddl_migrations/ddl_functions' EIA_KEY: db2522a43820268a41a802a16ae9fd26 # dummy key generated with openssl rand -hex 16 ENVIRONMENT: development DOD_CA_PACKAGE: /builds/milmove/mymove/config/tls/milmove-cert-bundle.p7b @@ -1193,7 +1247,16 @@ integration_test_office: DB_NAME: dev_db DB_NAME_DEV: dev_db MIGRATION_MANIFEST: '/builds/milmove/mymove/migrations/app/migrations_manifest.txt' + DML_MIGRATION_MANIFEST: '/builds/milmove/mymove/migrations/app/dml_migrations_manifest.txt' + DDL_TYPES_MIGRATION_MANIFEST: '/builds/milmove/mymove/migrations/app/ddl_types_manifest.txt' + DDL_TABLES_MIGRATION_MANIFEST: '/builds/milmove/mymove/migrations/app/ddl_tables_manifest.txt' + DDL_VIEWS_MIGRATION_MANIFEST: '/builds/milmove/mymove/migrations/app/ddl_views_manifest.txt' + DDL_FUNCTIONS_MIGRATION_MANIFEST: '/builds/milmove/mymove/migrations/app/ddl_functions_manifest.txt' MIGRATION_PATH: 'file:///builds/milmove/mymove/migrations/app/schema;file:///builds/milmove/mymove/migrations/app/secure' + DDL_TYPES_MIGRATION_PATH: 'file:///builds/milmove/mymove/migrations/app/ddl_migrations/ddl_types' + DDL_TABLES_MIGRATION_PATH: 'file:///builds/milmove/mymove/migrations/app/ddl_migrations/ddl_tables' + DDL_VIEWS_MIGRATION_PATH: 'file:///builds/milmove/mymove/migrations/app/ddl_migrations/ddl_views' + DDL_FUNCTIONS_MIGRATION_PATH: 'file:///builds/milmove/mymove/migrations/app/ddl_migrations/ddl_functions' EIA_KEY: db2522a43820268a41a802a16ae9fd26 # dummy key generated with openssl rand -hex 16 ENVIRONMENT: development DOD_CA_PACKAGE: /builds/milmove/mymove/config/tls/milmove-cert-bundle.p7b diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a3a309e7285..50e4b31b0ec 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -159,18 +159,10 @@ repos: rev: v1.1.1 hooks: - id: gen-docs - args: ['docs/adr'] + args: ["docs/adr"] - id: markdown-toc - id: hadolint - - repo: local - hooks: - - id: migrations-manifest - name: migrations manifest - entry: scripts/update-migrations-manifest - language: script - pass_filenames: false - - repo: local hooks: - id: scripts-docs diff --git a/Dockerfile.migrations b/Dockerfile.migrations index 021428de322..f6d81bfd325 100644 --- a/Dockerfile.migrations +++ b/Dockerfile.migrations @@ -20,6 +20,15 @@ COPY bin/rds-ca-2019-root.pem /bin/rds-ca-2019-root.pem COPY bin/milmove /bin/milmove COPY migrations/app/schema /migrate/schema +COPY migrations/app/ddl_migrations/ddl_types /migrate/ddl_migrations/ddl_types +COPY migrations/app/ddl_migrations/ddl_tables /migrate/ddl_migrations/ddl_tables +COPY migrations/app/ddl_migrations/ddl_views /migrate/ddl_migrations/ddl_views +COPY migrations/app/ddl_migrations/ddl_functions /migrate/ddl_migrations/ddl_functions COPY migrations/app/migrations_manifest.txt /migrate/migrations_manifest.txt - -ENTRYPOINT ["/bin/milmove", "migrate", "-p", "file:///migrate/migrations", "-m", "/migrate/migrations_manifest.txt"] \ No newline at end of file +COPY migrations/app/dml_migrations_manifest.txt /migrate/dml_migrations_manifest.txt +COPY migrations/app/ddl_types_manifest.txt /migrate/ddl_types_manifest.txt +COPY migrations/app/ddl_tables_manifest.txt /migrate/ddl_tables_manifest.txt +COPY migrations/app/ddl_views_manifest.txt /migrate/ddl_views_manifest.txt +COPY migrations/app/ddl_functions_manifest.txt /migrate/ddl_functions_manifest.txt +# hadolint ignore=DL3025 +ENTRYPOINT ["/bin/milmove", "migrate", "-p", "file:///migrate/migrations", "-m", "/migrate/migrations_manifest.txt", '-d', '/migrate/dml_migrations_manifest.txt', '-t', '/migrate/ddl_types_manifest.txt', '-T', '/migrate/ddl_tables_manifest.txt', '-V', '/migrate/ddl_views_manifest.txt', '-F', '/migrate/ddl_functions_manifest.txt'] \ No newline at end of file diff --git a/cmd/milmove/gen_migration.go b/cmd/milmove/gen_migration.go index a3df776d8ce..9fb3f48a279 100644 --- a/cmd/milmove/gen_migration.go +++ b/cmd/milmove/gen_migration.go @@ -69,7 +69,7 @@ func genMigrationFunction(cmd *cobra.Command, args []string) error { } migrationPath := v.GetString(cli.MigrationGenPathFlag) - migrationManifest := v.GetString(cli.MigrationManifestFlag) + migrationManifest := v.GetString(cli.DMLMigrationManifestFlag) migrationVersion := v.GetString(cli.MigrationVersionFlag) migrationName := v.GetString(cli.MigrationNameFlag) migrationType := v.GetString(cli.MigrationTypeFlag) diff --git a/cmd/milmove/migrate.go b/cmd/milmove/migrate.go index 507c747bf00..8e3abb98e78 100644 --- a/cmd/milmove/migrate.go +++ b/cmd/milmove/migrate.go @@ -174,7 +174,6 @@ func migrateFunction(cmd *cobra.Command, args []string) error { // Remove any extra quotes around path trimmedMigrationPaths := strings.Trim(v.GetString(cli.MigrationPathFlag), "\"") migrationPaths := expandPaths(strings.Split(trimmedMigrationPaths, ";")) - logger.Info(fmt.Sprintf("using migration paths %q", migrationPaths)) logger.Info("migration Path from s3") @@ -308,5 +307,136 @@ func migrateFunction(cmd *cobra.Command, args []string) error { return errors.Wrap(errUp, "error running migrations") } + // Begin DDL migrations + ddlTypesManifest := expandPath(v.GetString(cli.DDLTypesMigrationManifestFlag)) + ddlTypesManifestPath := expandPath(v.GetString(cli.DDLTypesMigrationPathFlag)) + + ddlTablesManifest := expandPath(v.GetString(cli.DDLTablesMigrationManifestFlag)) + ddlTablesPath := expandPath(v.GetString(cli.DDLTablesMigrationPathFlag)) + + ddlViewsManifest := expandPath(v.GetString(cli.DDLViewsMigrationManifestFlag)) + ddlViewsPath := expandPath(v.GetString(cli.DDLViewsMigrationPathFlag)) + + ddlFunctionsManifest := expandPath(v.GetString(cli.DDLFunctionsMigrationManifestFlag)) + ddlFunctionsPath := expandPath(v.GetString(cli.DDLFunctionsMigrationPathFlag)) + + ddlObjects := []struct { + name string + manifest string + path string + }{ + {"DDL Types", ddlTypesManifest, ddlTypesManifestPath}, + {"DDL Tables", ddlTablesManifest, ddlTablesPath}, + {"DDL Views", ddlViewsManifest, ddlViewsPath}, + {"DDL Functions", ddlFunctionsManifest, ddlFunctionsPath}, + } + + for _, ddlObj := range ddlObjects { + logger.Info(fmt.Sprintf("=== Processing %s ===", ddlObj.name)) + logger.Info(fmt.Sprintf("Using manifest %q", ddlObj.manifest)) + filenames, errListFiles := fileHelper.ListFiles(ddlObj.path, s3Client) + if errListFiles != nil { + logger.Fatal(fmt.Sprintf("Error listing %s directory %s", ddlObj.name, ddlObj.path), zap.Error(errListFiles)) + } + + ddlMigrationFiles := map[string][]string{ + ddlObj.path: filenames, + } + + manifest, err := os.Open(ddlObj.manifest[len("file://"):]) + if err != nil { + return errors.Wrap(err, fmt.Sprintf("error reading %s manifest", ddlObj.name)) + } + + scanner := bufio.NewScanner(manifest) + for scanner.Scan() { + target := scanner.Text() + if strings.HasPrefix(target, "#") { + continue + } + + uri := "" + for dir, files := range ddlMigrationFiles { + for _, filename := range files { + if target == filename { + uri = fmt.Sprintf("%s/%s", dir, filename) + break + } + } + } + + if len(uri) == 0 { + return errors.Errorf("Error finding %s migration for filename %q", ddlObj.name, target) + } + + m, err := pop.ParseMigrationFilename(target) + if err != nil { + return errors.Wrapf(err, "error parsing %s migration filename %q", ddlObj.name, uri) + } + + b := &migrate.Builder{Match: m, Path: uri} + migration, errCompile := b.Compile(s3Client, wait, logger) + if errCompile != nil { + return errors.Wrap(errCompile, fmt.Sprintf("Error compiling %s migration", ddlObj.name)) + } + + if err := migration.Run(dbConnection); err != nil { + return errors.Wrap(err, fmt.Sprintf("error executing %s migration", ddlObj.name)) + } + + logger.Info(fmt.Sprintf("Successfully executed %s: %s", ddlObj.name, target)) + } + manifest.Close() + } + + // After DDL migrations, process DML migrations + dmlManifest := expandPath(v.GetString(cli.DMLMigrationManifestFlag)) + logger.Info(fmt.Sprintf("using DML migration manifest %q", dmlManifest)) + + // Create a new migrator for DML migrations + dmlMigrator := pop.NewMigrator(dbConnection) + + manifest, err = os.Open(dmlManifest[len("file://"):]) + if err != nil { + return errors.Wrap(err, "error reading DML manifest") + } + + scanner = bufio.NewScanner(manifest) + for scanner.Scan() { + target := scanner.Text() + if strings.HasPrefix(target, "#") { + continue + } + uri := "" + for dir, filenames := range migrationFiles { + for _, filename := range filenames { + if target == filename { + uri = fmt.Sprintf("%s/%s", dir, filename) + break + } + } + } + if len(uri) == 0 { + return errors.Errorf("Error finding DML migration for filename %q", target) + } + m, err := pop.ParseMigrationFilename(target) + if err != nil { + return errors.Wrapf(err, "error parsing DML migration filename %q", uri) + } + b := &migrate.Builder{Match: m, Path: uri} + migration, errCompile := b.Compile(s3Client, wait, logger) + if errCompile != nil { + return errors.Wrap(errCompile, "Error compiling DML migration") + } + + dmlMigrator.UpMigrations.Migrations = append(dmlMigrator.UpMigrations.Migrations, *migration) + } + + // Run DML migrations and track versions + errUp = dmlMigrator.Up() + if errUp != nil { + return errors.Wrap(errUp, "error running DML migrations") + } + return nil } diff --git a/config/env/demo.migrations.env b/config/env/demo.migrations.env index 346e85f8d21..b407f1c498c 100644 --- a/config/env/demo.migrations.env +++ b/config/env/demo.migrations.env @@ -6,3 +6,8 @@ DB_SSL_MODE=verify-full DB_SSL_ROOT_CERT=/bin/rds-ca-rsa4096-g1.pem DB_USER=ecs_user MIGRATION_MANIFEST=/migrate/migrations_manifest.txt +DML_MIGRATION_MANIFEST=/migrate/dml_migrations_manifest.txt +DDL_TYPES_MIGRATION_MANIFEST=/migrate/ddl_types_manifest.txt +DDL_TABLES_MIGRATION_MANIFEST=/migrate/ddl_tables_manifest.txt +DDL_VIEWS_MIGRATION_MANIFEST=/migrate/ddl_views_manifest.txt +DDL_FUNCTIONS_MIGRATION_MANIFEST=/migrate/ddl_functions_manifest.txt \ No newline at end of file diff --git a/config/env/exp.migrations.env b/config/env/exp.migrations.env index 346e85f8d21..d215d9e7797 100644 --- a/config/env/exp.migrations.env +++ b/config/env/exp.migrations.env @@ -6,3 +6,8 @@ DB_SSL_MODE=verify-full DB_SSL_ROOT_CERT=/bin/rds-ca-rsa4096-g1.pem DB_USER=ecs_user MIGRATION_MANIFEST=/migrate/migrations_manifest.txt +DML_MIGRATION_MANIFEST=/migrate/dml_migrations_manifest.txt +DDL_TYPES_MIGRATION_MANIFEST=/migrate/ddl_types_manifest.txt +DDL_TABLES_MIGRATION_MANIFEST=/migrate/ddl_tables_manifest.txt +DDL_VIEWS_MIGRATION_MANIFEST=/migrate/ddl_views_manifest.txt +DDL_FUNCTIONS_MIGRATION_MANIFEST=/migrate/ddl_functions_manifest.txt diff --git a/config/env/loadtest.migrations.env b/config/env/loadtest.migrations.env index 346e85f8d21..b407f1c498c 100644 --- a/config/env/loadtest.migrations.env +++ b/config/env/loadtest.migrations.env @@ -6,3 +6,8 @@ DB_SSL_MODE=verify-full DB_SSL_ROOT_CERT=/bin/rds-ca-rsa4096-g1.pem DB_USER=ecs_user MIGRATION_MANIFEST=/migrate/migrations_manifest.txt +DML_MIGRATION_MANIFEST=/migrate/dml_migrations_manifest.txt +DDL_TYPES_MIGRATION_MANIFEST=/migrate/ddl_types_manifest.txt +DDL_TABLES_MIGRATION_MANIFEST=/migrate/ddl_tables_manifest.txt +DDL_VIEWS_MIGRATION_MANIFEST=/migrate/ddl_views_manifest.txt +DDL_FUNCTIONS_MIGRATION_MANIFEST=/migrate/ddl_functions_manifest.txt \ No newline at end of file diff --git a/config/env/prd.migrations.env b/config/env/prd.migrations.env index 346e85f8d21..b407f1c498c 100644 --- a/config/env/prd.migrations.env +++ b/config/env/prd.migrations.env @@ -6,3 +6,8 @@ DB_SSL_MODE=verify-full DB_SSL_ROOT_CERT=/bin/rds-ca-rsa4096-g1.pem DB_USER=ecs_user MIGRATION_MANIFEST=/migrate/migrations_manifest.txt +DML_MIGRATION_MANIFEST=/migrate/dml_migrations_manifest.txt +DDL_TYPES_MIGRATION_MANIFEST=/migrate/ddl_types_manifest.txt +DDL_TABLES_MIGRATION_MANIFEST=/migrate/ddl_tables_manifest.txt +DDL_VIEWS_MIGRATION_MANIFEST=/migrate/ddl_views_manifest.txt +DDL_FUNCTIONS_MIGRATION_MANIFEST=/migrate/ddl_functions_manifest.txt \ No newline at end of file diff --git a/config/env/stg.migrations.env b/config/env/stg.migrations.env index 346e85f8d21..b407f1c498c 100644 --- a/config/env/stg.migrations.env +++ b/config/env/stg.migrations.env @@ -6,3 +6,8 @@ DB_SSL_MODE=verify-full DB_SSL_ROOT_CERT=/bin/rds-ca-rsa4096-g1.pem DB_USER=ecs_user MIGRATION_MANIFEST=/migrate/migrations_manifest.txt +DML_MIGRATION_MANIFEST=/migrate/dml_migrations_manifest.txt +DDL_TYPES_MIGRATION_MANIFEST=/migrate/ddl_types_manifest.txt +DDL_TABLES_MIGRATION_MANIFEST=/migrate/ddl_tables_manifest.txt +DDL_VIEWS_MIGRATION_MANIFEST=/migrate/ddl_views_manifest.txt +DDL_FUNCTIONS_MIGRATION_MANIFEST=/migrate/ddl_functions_manifest.txt \ No newline at end of file diff --git a/migrations/app/ddl_functions_manifest.txt b/migrations/app/ddl_functions_manifest.txt new file mode 100644 index 00000000000..237796e829e --- /dev/null +++ b/migrations/app/ddl_functions_manifest.txt @@ -0,0 +1,3 @@ +# This is the functions(procedures) migrations manifest. +# If a migration is not recorded here, then it will error. +# Naming convention: fn_some_function.up.sql running will create this file. diff --git a/migrations/app/ddl_migrations/ddl_functions/README.md b/migrations/app/ddl_migrations/ddl_functions/README.md new file mode 100644 index 00000000000..e69de29bb2d diff --git a/migrations/app/ddl_migrations/ddl_tables/README.md b/migrations/app/ddl_migrations/ddl_tables/README.md new file mode 100644 index 00000000000..e69de29bb2d diff --git a/migrations/app/ddl_migrations/ddl_types/README.md b/migrations/app/ddl_migrations/ddl_types/README.md new file mode 100644 index 00000000000..e69de29bb2d diff --git a/migrations/app/ddl_migrations/ddl_views/README.md b/migrations/app/ddl_migrations/ddl_views/README.md new file mode 100644 index 00000000000..e69de29bb2d diff --git a/migrations/app/ddl_tables_manifest.txt b/migrations/app/ddl_tables_manifest.txt new file mode 100644 index 00000000000..8fd6841c337 --- /dev/null +++ b/migrations/app/ddl_tables_manifest.txt @@ -0,0 +1,3 @@ +# This is the tables migrations manifest. +# If a migration is not recorded here, then it will error. +# Naming convention: tbl_some_table.up.sql running will create this file. diff --git a/migrations/app/ddl_types_manifest.txt b/migrations/app/ddl_types_manifest.txt new file mode 100644 index 00000000000..9229c96f599 --- /dev/null +++ b/migrations/app/ddl_types_manifest.txt @@ -0,0 +1,3 @@ +# This is the types migrations manifest. +# If a migration is not recorded here, then it will error. +# Naming convention: ty_some_type.up.sql running will create this file. diff --git a/migrations/app/ddl_views_manifest.txt b/migrations/app/ddl_views_manifest.txt new file mode 100644 index 00000000000..939945b6618 --- /dev/null +++ b/migrations/app/ddl_views_manifest.txt @@ -0,0 +1,3 @@ +# This is the views migrations manifest. +# If a migration is not recorded here, then it will error. +# Naming convention: vw_some_view.up.sql running will create this file. diff --git a/migrations/app/dml_migrations_manifest.txt b/migrations/app/dml_migrations_manifest.txt new file mode 100644 index 00000000000..570749e1cfa --- /dev/null +++ b/migrations/app/dml_migrations_manifest.txt @@ -0,0 +1,3 @@ +# This is the migrations manifest. +# If a migration is not recorded here, then it will error. +# Naming convention: 202502201325_B-123456_update_some_table.up.sql running will create this file. diff --git a/migrations/app/migrations_manifest.txt b/migrations/app/migrations_manifest.txt index eb8aa1d8fa8..85d12df5c23 100644 --- a/migrations/app/migrations_manifest.txt +++ b/migrations/app/migrations_manifest.txt @@ -1094,3 +1094,4 @@ 20250204162411_updating_create_accessorial_service_item_proc_for_crating.up.sql 20250206173204_add_hawaii_data.up.sql 20250210175754_B22451_update_dest_queue_to_consider_sit_extensions.up.sql +# nothing should be added below this line this file is archived and only needed for rebuilding db Locally to be run prior to new migrations process to keep the current state diff --git a/migrations/app/schema/20250106202424_update_duty_locs.up.sql b/migrations/app/schema/20250106202424_update_duty_locs.up.sql index d3bc09560e5..2ecfaf6a399 100644 --- a/migrations/app/schema/20250106202424_update_duty_locs.up.sql +++ b/migrations/app/schema/20250106202424_update_duty_locs.up.sql @@ -24,11 +24,11 @@ BEGIN SELECT '8d613f71-b80e-4ad4-95e7-00781b084c7c'::uuid, 'n/a', NULL, 'NAS NORTH ISLAND', 'CA', '39125', now(), now(), NULL, 'SAN DIEGO', false, '791899e6-cd77-46f2-981b-176ecb8d7098'::uuid, '191165db-d30a-414d-862b-54afdfc7aeb9'::uuid WHERE NOT EXISTS (select * from addresses where id = '8d613f71-b80e-4ad4-95e7-00781b084c7c'); - INSERT INTO duty_locations (id,"name",affiliation,address_id,created_at,updated_at,transportation_office_id,provides_services_counseling) + INSERT INTO duty_locations (id,"name",affiliation,address_id,created_at,updated_at,transportation_office_id,provides_services_counseling) SELECT '56255626-bbbe-4834-8324-1c08f011f2f6'::uuid,'NAS N Island, CA 92135',NULL,'3d617fab-bf6f-4f07-8ab5-f7652b8e7f3e'::uuid,now(),now(),null,true WHERE NOT EXISTS (select * from duty_locations where id = '56255626-bbbe-4834-8324-1c08f011f2f6'); - - INSERT INTO duty_locations (id,"name",affiliation,address_id,created_at,updated_at,transportation_office_id,provides_services_counseling) + + INSERT INTO duty_locations (id,"name",affiliation,address_id,created_at,updated_at,transportation_office_id,provides_services_counseling) SELECT '7156098f-13cf-4455-bcd5-eb829d57c714'::uuid,'NAS North Island, CA 92135',NULL,'8d613f71-b80e-4ad4-95e7-00781b084c7c'::uuid,now(),now(),null,true WHERE NOT EXISTS (select * from duty_locations where id = '7156098f-13cf-4455-bcd5-eb829d57c714'); END $$; @@ -42,7 +42,7 @@ BEGIN SELECT 'fb90a7df-6494-4974-a0ce-4bdbcaff80c0'::uuid, 'n/a', NULL, 'CANNON AFB', 'NM', '88101', now(), now(), NULL, 'CURRY', false, '791899e6-cd77-46f2-981b-176ecb8d7098'::uuid, '68393e10-1aed-4a51-85a0-559a0a5b0e3f'::uuid WHERE NOT EXISTS (select * from addresses where id = 'fb90a7df-6494-4974-a0ce-4bdbcaff80c0'); - INSERT INTO duty_locations (id,"name",affiliation,address_id,created_at,updated_at,transportation_office_id,provides_services_counseling) + INSERT INTO duty_locations (id,"name",affiliation,address_id,created_at,updated_at,transportation_office_id,provides_services_counseling) SELECT '98beab3c-f8ce-4e3c-b78e-8db614721621'::uuid, 'Cannon AFB, NM 88101',null, 'fb90a7df-6494-4974-a0ce-4bdbcaff80c0'::uuid,now(),now(),'80796bc4-e494-4b19-bb16-cdcdba187829',true WHERE NOT EXISTS (select * from duty_locations where id = '98beab3c-f8ce-4e3c-b78e-8db614721621'); END $$; diff --git a/migrations/app/schema/20250121184450_upd_duty_loc_B-22242.up.sql b/migrations/app/schema/20250121184450_upd_duty_loc_B-22242.up.sql index c21c04f6a81..70928fff219 100644 --- a/migrations/app/schema/20250121184450_upd_duty_loc_B-22242.up.sql +++ b/migrations/app/schema/20250121184450_upd_duty_loc_B-22242.up.sql @@ -1,30 +1,30 @@ DO $$ BEGIN - + --remove duty loc Johnston City, TN 37602 IF EXISTS (SELECT 1 FROM duty_locations WHERE id = 'd3a1be10-dcd7-4720-bcbe-7ba76d243687') THEN - - + + update orders set origin_duty_location_id = 'cd0c7325-15bb-45c7-a690-26c56c903ed7' where origin_duty_location_id = 'd3a1be10-dcd7-4720-bcbe-7ba76d243687'; update orders set new_duty_location_id = 'cd0c7325-15bb-45c7-a690-26c56c903ed7' where new_duty_location_id = 'd3a1be10-dcd7-4720-bcbe-7ba76d243687'; - + delete from duty_locations where id = 'd3a1be10-dcd7-4720-bcbe-7ba76d243687'; - + END IF; END $$; DO $$ BEGIN - + --remove duty loc Oceanside, CA 92052 IF EXISTS (SELECT 1 FROM duty_locations WHERE id = '54ca99b7-3c2a-42b0-aa1a-ad071ac580de') THEN - + update orders set origin_duty_location_id = 'a6993e7b-4600-44b9-b288-04ca011143f0' where origin_duty_location_id = '54ca99b7-3c2a-42b0-aa1a-ad071ac580de'; update orders set new_duty_location_id = 'a6993e7b-4600-44b9-b288-04ca011143f0' where new_duty_location_id = '54ca99b7-3c2a-42b0-aa1a-ad071ac580de'; - + delete from duty_locations where id = '54ca99b7-3c2a-42b0-aa1a-ad071ac580de'; - + END IF; END $$; @@ -34,9 +34,9 @@ BEGIN --remove duty loc Albuquerque, NM 87103 IF EXISTS (SELECT 1 FROM duty_locations WHERE id = '2cc57072-19fa-438b-a44b-e349dff11763') THEN - + update orders set new_duty_location_id = '54acfb0e-222b-49eb-b94b-ccb00c6f529c' where new_duty_location_id = '2cc57072-19fa-438b-a44b-e349dff11763'; - + delete from duty_locations where id = '2cc57072-19fa-438b-a44b-e349dff11763'; END IF; @@ -45,45 +45,45 @@ END $$; DO $$ BEGIN - + --remove duty loc August, GA 30917 IF EXISTS (SELECT 1 FROM duty_locations WHERE id = '109ac405-47fb-4e1e-9efb-58290453ac09') THEN - + update orders set origin_duty_location_id = '595363c2-14ee-48e0-b318-e76ab0016453' where origin_duty_location_id = '109ac405-47fb-4e1e-9efb-58290453ac09'; update orders set new_duty_location_id = '595363c2-14ee-48e0-b318-e76ab0016453' where new_duty_location_id = '109ac405-47fb-4e1e-9efb-58290453ac09'; - + delete from duty_locations where id = '109ac405-47fb-4e1e-9efb-58290453ac09'; - + END IF; END $$; DO $$ BEGIN - + --remove duty loc Frankfort, KY 40602 IF EXISTS (SELECT 1 FROM duty_locations WHERE id = 'c7fadaa2-902f-4302-a7cd-108c525b96d4') THEN - + update orders set origin_duty_location_id = '1a973257-cd15-42a9-86be-a14796c014bc' where origin_duty_location_id = 'c7fadaa2-902f-4302-a7cd-108c525b96d4'; update orders set new_duty_location_id = '1a973257-cd15-42a9-86be-a14796c014bc' where new_duty_location_id = 'c7fadaa2-902f-4302-a7cd-108c525b96d4'; - + delete from duty_locations where id = 'c7fadaa2-902f-4302-a7cd-108c525b96d4'; - + END IF; END $$; DO $$ BEGIN - + --remove duty loc Seattle, WA 98111 IF EXISTS (SELECT 1 FROM duty_locations WHERE id = '2fb3e898-d6de-4be7-8576-7c7b10c2a706') THEN - + update orders set origin_duty_location_id = 'e7fdae4f-6be7-4264-99f8-03ee8541499c' where origin_duty_location_id = '2fb3e898-d6de-4be7-8576-7c7b10c2a706'; update orders set new_duty_location_id = 'e7fdae4f-6be7-4264-99f8-03ee8541499c' where new_duty_location_id = '2fb3e898-d6de-4be7-8576-7c7b10c2a706'; - + delete from duty_locations where id = '2fb3e898-d6de-4be7-8576-7c7b10c2a706'; - + END IF; END $$; diff --git a/pkg/cli/migration.go b/pkg/cli/migration.go index b540516beb0..bf54e72ab55 100644 --- a/pkg/cli/migration.go +++ b/pkg/cli/migration.go @@ -10,9 +10,22 @@ import ( const ( // MigrationManifestFlag is the migration manifest flag - MigrationManifestFlag string = "migration-manifest" + MigrationManifestFlag string = "migration-manifest" //deprecated + DMLMigrationManifestFlag string = "dml-migration-manifest" // MigrationWaitFlag is the migration wait flag MigrationWaitFlag string = "migration-wait" + + DDLTablesMigrationPathFlag = "ddl-tables-migration-path" + DDLTablesMigrationManifestFlag = "ddl-tables-migration-manifest" + + DDLTypesMigrationPathFlag = "ddl-types-migration-path" + DDLTypesMigrationManifestFlag = "ddl-types-migration-manifest" + + DDLViewsMigrationPathFlag = "ddl-views-migration-path" + DDLViewsMigrationManifestFlag = "ddl-views-migration-manifest" + + DDLFunctionsMigrationPathFlag = "ddl-functions-migration-path" + DDLFunctionsMigrationManifestFlag = "ddl-functions-migration-manifest" ) var ( @@ -22,7 +35,17 @@ var ( // InitMigrationFlags initializes the Migration command line flags func InitMigrationFlags(flag *pflag.FlagSet) { flag.StringP(MigrationManifestFlag, "m", "migrations/app/migrations_manifest.txt", "Path to the manifest") + flag.StringP(DMLMigrationManifestFlag, "d", "migrations/app/dml_migrations_manifest.txt", "Path to the manifest") flag.DurationP(MigrationWaitFlag, "w", time.Millisecond*10, "duration to wait when polling for new data from migration file") + flag.String(DDLTablesMigrationPathFlag, "", "Path to DDL tables migrations directory") + flag.String(DDLTablesMigrationManifestFlag, "", "Path to DDL tables migrations manifest") + flag.String(DDLTypesMigrationPathFlag, "", "Path to DDL types migrations directory") + flag.String(DDLTypesMigrationManifestFlag, "", "Path to DDL types migrations manifest") + flag.String(DDLViewsMigrationPathFlag, "", "Path to DDL views migrations directory") + flag.String(DDLViewsMigrationManifestFlag, "", "Path to DDL views migrations manifest") + flag.String(DDLFunctionsMigrationPathFlag, "", "Path to DDL functions migrations directory") + flag.String(DDLFunctionsMigrationManifestFlag, "", "Path to DDL functions migrations manifest") + } // CheckMigration validates migration command line flags @@ -34,5 +57,20 @@ func CheckMigration(v *viper.Viper) error { if len(MigrationManifestFlag) == 0 { return errMissingMigrationManifest } + if len(DMLMigrationManifestFlag) == 0 { + return errMissingMigrationManifest + } + if len(DDLTypesMigrationManifestFlag) == 0 { + return errMissingMigrationManifest + } + if len(DDLTablesMigrationManifestFlag) == 0 { + return errMissingMigrationManifest + } + if len(DDLViewsMigrationManifestFlag) == 0 { + return errMissingMigrationManifest + } + if len(DDLFunctionsMigrationManifestFlag) == 0 { + return errMissingMigrationManifest + } return nil } diff --git a/pkg/testdatagen/testharness/make_move.go b/pkg/testdatagen/testharness/make_move.go index 0039c984493..5c8909b983b 100644 --- a/pkg/testdatagen/testharness/make_move.go +++ b/pkg/testdatagen/testharness/make_move.go @@ -9107,6 +9107,7 @@ func MakeBasicInternationalHHGMoveWithServiceItemsandPaymentRequestsForTIO(appCt ihpkCost := unit.Cents(298800) ihupkCost := unit.Cents(33280) poefscCost := unit.Cents(25000) + idshutCost := unit.Cents(623) // Create Customer userInfo := newUserInfo("customer") @@ -9441,6 +9442,47 @@ func MakeBasicInternationalHHGMoveWithServiceItemsandPaymentRequestsForTIO(appCt }, }, nil) + // Shuttling service item + approvedAtTime := time.Now() + idshut := factory.BuildMTOServiceItem(appCtx.DB(), []factory.Customization{ + { + Model: models.MTOServiceItem{ + Status: models.MTOServiceItemStatusApproved, + ApprovedAt: &approvedAtTime, + EstimatedWeight: &estimatedWeight, + ActualWeight: &actualWeight, + }, + }, + { + Model: mto, + LinkOnly: true, + }, + { + Model: mtoShipmentHHG, + LinkOnly: true, + }, + { + Model: models.ReService{ + ID: uuid.FromStringOrNil("22fc07ed-be15-4f50-b941-cbd38153b378"), // IDSHUT - International Destination Shuttle + }, + }, + }, nil) + + factory.BuildPaymentServiceItemWithParams(appCtx.DB(), models.ReServiceCodeIDSHUT, + basicPaymentServiceItemParams, []factory.Customization{ + { + Model: models.PaymentServiceItem{ + PriceCents: &idshutCost, + }, + }, { + Model: paymentRequestHHG, + LinkOnly: true, + }, { + Model: idshut, + LinkOnly: true, + }, + }, nil) + basicPortFuelSurchargePaymentServiceItemParams := []factory.CreatePaymentServiceItemParams{ { Key: models.ServiceItemParamNameContractCode, diff --git a/playwright/tests/office/txo/tioFlowsInternational.spec.js b/playwright/tests/office/txo/tioFlowsInternational.spec.js index 30f4c0b0dac..cf8ed39c541 100644 --- a/playwright/tests/office/txo/tioFlowsInternational.spec.js +++ b/playwright/tests/office/txo/tioFlowsInternational.spec.js @@ -143,6 +143,17 @@ test.describe('TIO user', () => { await page.getByText('Next').click(); await tioFlowPage.slowDown(); + await expect(page.getByText('International destination shuttle service')).toBeVisible(); + await page.getByText('Show calculations').click(); + await expect(page.locator('[data-testid="ServiceItemCalculations"]')).toContainText('Calculations'); + await expect(page.locator('[data-testid="ServiceItemCalculations"]')).toContainText('Billable weight (cwt)'); + await expect(page.locator('[data-testid="ServiceItemCalculations"]')).toContainText('Destination price'); + await expect(page.locator('[data-testid="ServiceItemCalculations"]')).toContainText('Price escalation factor'); + // approve + await tioFlowPage.approveServiceItem(); + await page.getByText('Next').click(); + await tioFlowPage.slowDown(); + await expect(page.getByText('International POE Fuel Surcharge')).toBeVisible(); await page.getByText('Show calculations').click(); await expect(page.locator('[data-testid="ServiceItemCalculations"]')).toContainText('Calculations'); @@ -159,8 +170,8 @@ test.describe('TIO user', () => { await expect(page.getByText('needs your review')).toHaveCount(0, { timeout: 10000 }); await page.getByText('Complete request').click(); - await expect(page.locator('[data-testid="requested"]')).toContainText('$4,281.48'); - await expect(page.locator('[data-testid="accepted"]')).toContainText('$4,281.48'); + await expect(page.locator('[data-testid="requested"]')).toContainText('$4,287.71'); + await expect(page.locator('[data-testid="accepted"]')).toContainText('$4,287.71'); await expect(page.locator('[data-testid="rejected"]')).toContainText('$0.00'); await page.getByText('Authorize payment').click(); diff --git a/scripts/README.md b/scripts/README.md index 46aa61a74c1..d010b67b7fe 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -170,6 +170,7 @@ migrations. | `download-secure-migration` | A script to download secure migrations from all environments | | `generate-secure-migration` | A script to help manage the creation of secure migrations | | `upload-secure-migration` | A script to upload secure migrations to all environments in both commercial and GovCloud AWS | +| `generate-ddl-migration` | A script to help manage the creation of DDL migrations | ### Database Scripts diff --git a/scripts/generate-ddl-migration b/scripts/generate-ddl-migration new file mode 100755 index 00000000000..345d712c2cc --- /dev/null +++ b/scripts/generate-ddl-migration @@ -0,0 +1,22 @@ +#!/bin/bash + +dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +version=$(date +"%Y%m%d%H%M%S") +filename=$1 +type=$2 + +if [ "$type" == "functions" ]; then + echo "${version}_fn_${filename}.up.sql" >> "${dir}/../migrations/app/ddl_functions_manifest.txt" + touch "${dir}/../migrations/app/ddl_migrations/ddl_functions/${version}_fn_${filename}.up.sql" +elif [ "$type" == "tables" ]; then + echo "${version}_tbl_${filename}.up.sql" >> "${dir}/../migrations/app/ddl_tables_manifest.txt" + touch "${dir}/../migrations/app/ddl_migrations/ddl_tables/${version}_tbl_${filename}.up.sql" +elif [ "$type" == "types" ]; then + echo "${version}_ty_${filename}.up.sql" >> "${dir}/../migrations/app/ddl_types_manifest.txt" + touch "${dir}/../migrations/app/ddl_migrations/ddl_types/${version}_ty_${filename}.up.sql" + elif [ "$type" == "views" ]; then + echo "${version}_vw_${filename}.up.sql" >> "${dir}/../migrations/app/ddl_views_manifest.txt" + touch "${dir}/../migrations/app/ddl_migrations/ddl_views/${version}_vw_${filename}.up.sql" +else + echo "Invalid type" +fi diff --git a/scripts/generate-secure-migration b/scripts/generate-secure-migration index f8053049d66..82a3adba869 100755 --- a/scripts/generate-secure-migration +++ b/scripts/generate-secure-migration @@ -83,5 +83,9 @@ EOM # # Update the migrations manifest # +# Add migration to DML manifest +readonly manifest_file="${dir}/../migrations/app/dml_migrations_manifest.txt" +echo "${secure_migration_name}" >> "$manifest_file" -./scripts/update-migrations-manifest + +##./scripts/update-migrations-manifest diff --git a/src/components/Office/ServiceItemCalculations/helpers.js b/src/components/Office/ServiceItemCalculations/helpers.js index d555fe17733..ca185d5c87f 100644 --- a/src/components/Office/ServiceItemCalculations/helpers.js +++ b/src/components/Office/ServiceItemCalculations/helpers.js @@ -380,6 +380,20 @@ const shuttleOriginPriceDomestic = (params) => { ); }; +const shuttleOriginPriceInternational = (params) => { + const value = getPriceRateOrFactor(params); + const label = SERVICE_ITEM_CALCULATION_LABELS.OriginPrice; + + const pickupDate = `${SERVICE_ITEM_CALCULATION_LABELS.PickupDate}: ${formatDateWithUTC( + getParamValue(SERVICE_ITEM_PARAM_KEYS.ReferenceDate, params), + 'DD MMM YYYY', + )}`; + + const market = getParamValue(SERVICE_ITEM_PARAM_KEYS.MarketDest, params) === 'O' ? 'Oconus' : 'Conus'; + + return calculation(value, label, formatDetail(pickupDate), formatDetail(market)); +}; + // There is no param representing the destination price as available in the re_domestic_service_area_prices table // A param to return the service schedule is also not being created const destinationPrice = (params, shipmentType) => { @@ -418,6 +432,20 @@ const shuttleDestinationPriceDomestic = (params) => { ); }; +const shuttleDestinationPriceInternational = (params) => { + const value = getPriceRateOrFactor(params); + const label = SERVICE_ITEM_CALCULATION_LABELS.DestinationPrice; + + const deliveryDate = `${SERVICE_ITEM_CALCULATION_LABELS.DeliveryDate}: ${formatDateWithUTC( + getParamValue(SERVICE_ITEM_PARAM_KEYS.ReferenceDate, params), + 'DD MMM YYYY', + )}`; + + const market = getParamValue(SERVICE_ITEM_PARAM_KEYS.MarketDest, params) === 'O' ? 'OCONUS' : 'CONUS'; + + return calculation(value, label, formatDetail(deliveryDate), formatDetail(market)); +}; + const priceEscalationFactor = (params) => { const value = getParamValue(SERVICE_ITEM_PARAM_KEYS.EscalationCompounded, params) ? getParamValue(SERVICE_ITEM_PARAM_KEYS.EscalationCompounded, params) @@ -922,6 +950,15 @@ export default function makeCalculations(itemCode, totalAmount, params, mtoParam totalAmountRequested(totalAmount), ]; break; + // International origin shuttle service + case SERVICE_ITEM_CODES.IOSHUT: + result = [ + shuttleBillableWeight(params), + shuttleOriginPriceInternational(params), + priceEscalationFactorWithoutContractYear(params), + totalAmountRequested(totalAmount), + ]; + break; // Domestic Destination Additional Days SIT case SERVICE_ITEM_CODES.DDASIT: result = [ @@ -950,6 +987,15 @@ export default function makeCalculations(itemCode, totalAmount, params, mtoParam totalAmountRequested(totalAmount), ]; break; + // International destination shuttle service + case SERVICE_ITEM_CODES.IDSHUT: + result = [ + shuttleBillableWeight(params), + shuttleDestinationPriceInternational(params), + priceEscalationFactorWithoutContractYear(params), + totalAmountRequested(totalAmount), + ]; + break; // Domestic crating case SERVICE_ITEM_CODES.DCRT: result = [ diff --git a/src/constants/serviceItems.js b/src/constants/serviceItems.js index 16f2dd60b62..a5b7e850b3c 100644 --- a/src/constants/serviceItems.js +++ b/src/constants/serviceItems.js @@ -228,12 +228,14 @@ const allowedServiceItemCalculations = [ SERVICE_ITEM_CODES.DOP, SERVICE_ITEM_CODES.DOPSIT, SERVICE_ITEM_CODES.DOSHUT, + SERVICE_ITEM_CODES.IOSHUT, SERVICE_ITEM_CODES.DPK, SERVICE_ITEM_CODES.DNPK, SERVICE_ITEM_CODES.DSH, SERVICE_ITEM_CODES.DUPK, SERVICE_ITEM_CODES.FSC, SERVICE_ITEM_CODES.DDSHUT, + SERVICE_ITEM_CODES.IDSHUT, SERVICE_ITEM_CODES.DCRT, SERVICE_ITEM_CODES.DUCRT, SERVICE_ITEM_CODES.DOSFSC,