@saws/postgres-service 2.0.0-beta.3 → 2.0.0-beta.6
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/.tsbuildinfo +1 -0
- package/dist/PostgresService.d.ts +81 -0
- package/dist/PostgresService.js +289 -0
- package/dist/index.js +1 -0
- package/dist/migrate-command.d.ts +10 -0
- package/dist/migrate-command.js +41 -0
- package/package.json +10 -3
- package/src/PostgresService.ts +0 -411
- package/src/migrate-command.ts +0 -64
- package/tsconfig.json +0 -9
- /package/{src/index.ts → dist/index.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"fileNames":["../../../node_modules/typescript/lib/lib.es5.d.ts","../../../node_modules/typescript/lib/lib.es2015.d.ts","../../../node_modules/typescript/lib/lib.es2016.d.ts","../../../node_modules/typescript/lib/lib.es2017.d.ts","../../../node_modules/typescript/lib/lib.es2018.d.ts","../../../node_modules/typescript/lib/lib.es2019.d.ts","../../../node_modules/typescript/lib/lib.es2020.d.ts","../../../node_modules/typescript/lib/lib.es2021.d.ts","../../../node_modules/typescript/lib/lib.es2022.d.ts","../../../node_modules/typescript/lib/lib.es2023.d.ts","../../../node_modules/typescript/lib/lib.es2024.d.ts","../../../node_modules/typescript/lib/lib.es2025.d.ts","../../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../node_modules/typescript/lib/lib.es2016.intl.d.ts","../../../node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts","../../../node_modules/typescript/lib/lib.es2017.date.d.ts","../../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../node_modules/typescript/lib/lib.es2019.intl.d.ts","../../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../node_modules/typescript/lib/lib.es2020.date.d.ts","../../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../node_modules/typescript/lib/lib.es2020.number.d.ts","../../../node_modules/typescript/lib/lib.es2021.promise.d.ts","../../../node_modules/typescript/lib/lib.es2021.string.d.ts","../../../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../../node_modules/typescript/lib/lib.es2021.intl.d.ts","../../../node_modules/typescript/lib/lib.es2022.array.d.ts","../../../node_modules/typescript/lib/lib.es2022.error.d.ts","../../../node_modules/typescript/lib/lib.es2022.intl.d.ts","../../../node_modules/typescript/lib/lib.es2022.object.d.ts","../../../node_modules/typescript/lib/lib.es2022.string.d.ts","../../../node_modules/typescript/lib/lib.es2022.regexp.d.ts","../../../node_modules/typescript/lib/lib.es2023.array.d.ts","../../../node_modules/typescript/lib/lib.es2023.collection.d.ts","../../../node_modules/typescript/lib/lib.es2023.intl.d.ts","../../../node_modules/typescript/lib/lib.es2024.arraybuffer.d.ts","../../../node_modules/typescript/lib/lib.es2024.collection.d.ts","../../../node_modules/typescript/lib/lib.es2024.object.d.ts","../../../node_modules/typescript/lib/lib.es2024.promise.d.ts","../../../node_modules/typescript/lib/lib.es2024.regexp.d.ts","../../../node_modules/typescript/lib/lib.es2024.sharedmemory.d.ts","../../../node_modules/typescript/lib/lib.es2024.string.d.ts","../../../node_modules/typescript/lib/lib.es2025.collection.d.ts","../../../node_modules/typescript/lib/lib.es2025.float16.d.ts","../../../node_modules/typescript/lib/lib.es2025.intl.d.ts","../../../node_modules/typescript/lib/lib.es2025.iterator.d.ts","../../../node_modules/typescript/lib/lib.es2025.promise.d.ts","../../../node_modules/typescript/lib/lib.es2025.regexp.d.ts","../../../node_modules/typescript/lib/lib.esnext.collection.d.ts","../../../node_modules/typescript/lib/lib.esnext.disposable.d.ts","../../../node_modules/typescript/lib/lib.esnext.temporal.d.ts","../../../node_modules/typescript/lib/lib.decorators.d.ts","../../../node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../core/dist/utils/stage-outputs.d.ts","../../core/dist/secrets-manager.d.ts","../../core/dist/ServiceDefinition.d.ts","../../core/dist/find-service-definition.d.ts","../../core/dist/get-saws-config.d.ts","../../core/dist/host-readiness.d.ts","../../core/dist/Host.d.ts","../../core/dist/index.d.ts","../../core/dist/utils/dependency-management.d.ts","../../core/dist/utils/file-exists.d.ts","../../core/dist/utils/list-files.d.ts","../../core/dist/utils/run-local.d.ts","../../core/dist/utils/shell-quote.d.ts","../../docker-service/dist/DockerService.d.ts","../../docker-service/dist/index.d.ts","../../../node_modules/commander/typings/index.d.ts","../src/migrate-command.ts","../src/PostgresService.ts","../src/index.ts","../../../node_modules/@types/node/globals.typedarray.d.ts","../../../node_modules/@types/node/buffer.buffer.d.ts","../../../node_modules/@types/node/globals.d.ts","../../../node_modules/@types/node/web-globals/abortcontroller.d.ts","../../../node_modules/@types/node/web-globals/blob.d.ts","../../../node_modules/@types/node/web-globals/console.d.ts","../../../node_modules/@types/node/web-globals/crypto.d.ts","../../../node_modules/@types/node/web-globals/domexception.d.ts","../../../node_modules/@types/node/web-globals/encoding.d.ts","../../../node_modules/@types/node/web-globals/events.d.ts","../../../node_modules/undici-types/utility.d.ts","../../../node_modules/undici-types/header.d.ts","../../../node_modules/undici-types/readable.d.ts","../../../node_modules/undici-types/fetch.d.ts","../../../node_modules/undici-types/formdata.d.ts","../../../node_modules/undici-types/connector.d.ts","../../../node_modules/undici-types/client-stats.d.ts","../../../node_modules/undici-types/client.d.ts","../../../node_modules/undici-types/errors.d.ts","../../../node_modules/undici-types/dispatcher.d.ts","../../../node_modules/undici-types/global-dispatcher.d.ts","../../../node_modules/undici-types/global-origin.d.ts","../../../node_modules/undici-types/pool-stats.d.ts","../../../node_modules/undici-types/pool.d.ts","../../../node_modules/undici-types/handlers.d.ts","../../../node_modules/undici-types/balanced-pool.d.ts","../../../node_modules/undici-types/round-robin-pool.d.ts","../../../node_modules/undici-types/h2c-client.d.ts","../../../node_modules/undici-types/agent.d.ts","../../../node_modules/undici-types/dispatcher1-wrapper.d.ts","../../../node_modules/undici-types/mock-interceptor.d.ts","../../../node_modules/undici-types/mock-call-history.d.ts","../../../node_modules/undici-types/mock-agent.d.ts","../../../node_modules/undici-types/mock-client.d.ts","../../../node_modules/undici-types/mock-pool.d.ts","../../../node_modules/undici-types/snapshot-agent.d.ts","../../../node_modules/undici-types/mock-errors.d.ts","../../../node_modules/undici-types/proxy-agent.d.ts","../../../node_modules/undici-types/socks5-proxy-agent.d.ts","../../../node_modules/undici-types/env-http-proxy-agent.d.ts","../../../node_modules/undici-types/retry-handler.d.ts","../../../node_modules/undici-types/retry-agent.d.ts","../../../node_modules/undici-types/api.d.ts","../../../node_modules/undici-types/cache-interceptor.d.ts","../../../node_modules/undici-types/interceptors.d.ts","../../../node_modules/undici-types/util.d.ts","../../../node_modules/undici-types/cookies.d.ts","../../../node_modules/undici-types/patch.d.ts","../../../node_modules/undici-types/websocket.d.ts","../../../node_modules/undici-types/eventsource.d.ts","../../../node_modules/undici-types/diagnostics-channel.d.ts","../../../node_modules/undici-types/content-type.d.ts","../../../node_modules/undici-types/cache.d.ts","../../../node_modules/undici-types/index.d.ts","../../../node_modules/@types/node/web-globals/fetch.d.ts","../../../node_modules/@types/node/web-globals/importmeta.d.ts","../../../node_modules/@types/node/web-globals/messaging.d.ts","../../../node_modules/@types/node/web-globals/navigator.d.ts","../../../node_modules/@types/node/web-globals/performance.d.ts","../../../node_modules/@types/node/web-globals/storage.d.ts","../../../node_modules/@types/node/web-globals/streams.d.ts","../../../node_modules/@types/node/web-globals/timers.d.ts","../../../node_modules/@types/node/web-globals/url.d.ts","../../../node_modules/@types/node/assert.d.ts","../../../node_modules/@types/node/assert/strict.d.ts","../../../node_modules/@types/node/async_hooks.d.ts","../../../node_modules/@types/node/buffer.d.ts","../../../node_modules/@types/node/child_process.d.ts","../../../node_modules/@types/node/cluster.d.ts","../../../node_modules/@types/node/console.d.ts","../../../node_modules/@types/node/constants.d.ts","../../../node_modules/@types/node/crypto.d.ts","../../../node_modules/@types/node/dgram.d.ts","../../../node_modules/@types/node/diagnostics_channel.d.ts","../../../node_modules/@types/node/dns.d.ts","../../../node_modules/@types/node/dns/promises.d.ts","../../../node_modules/@types/node/domain.d.ts","../../../node_modules/@types/node/events.d.ts","../../../node_modules/@types/node/ffi.d.ts","../../../node_modules/@types/node/fs.d.ts","../../../node_modules/@types/node/fs/promises.d.ts","../../../node_modules/@types/node/http.d.ts","../../../node_modules/@types/node/http2.d.ts","../../../node_modules/@types/node/https.d.ts","../../../node_modules/@types/node/inspector.d.ts","../../../node_modules/@types/node/inspector.generated.d.ts","../../../node_modules/@types/node/inspector/promises.d.ts","../../../node_modules/@types/node/module.d.ts","../../../node_modules/@types/node/net.d.ts","../../../node_modules/@types/node/os.d.ts","../../../node_modules/@types/node/path.d.ts","../../../node_modules/@types/node/path/posix.d.ts","../../../node_modules/@types/node/path/win32.d.ts","../../../node_modules/@types/node/perf_hooks.d.ts","../../../node_modules/@types/node/process.d.ts","../../../node_modules/@types/node/punycode.d.ts","../../../node_modules/@types/node/querystring.d.ts","../../../node_modules/@types/node/quic.d.ts","../../../node_modules/@types/node/readline.d.ts","../../../node_modules/@types/node/readline/promises.d.ts","../../../node_modules/@types/node/repl.d.ts","../../../node_modules/@types/node/sea.d.ts","../../../node_modules/@types/node/sqlite.d.ts","../../../node_modules/@types/node/stream.d.ts","../../../node_modules/@types/node/stream/consumers.d.ts","../../../node_modules/@types/node/stream/iter.d.ts","../../../node_modules/@types/node/stream/promises.d.ts","../../../node_modules/@types/node/stream/web.d.ts","../../../node_modules/@types/node/string_decoder.d.ts","../../../node_modules/@types/node/test.d.ts","../../../node_modules/@types/node/test/reporters.d.ts","../../../node_modules/@types/node/timers.d.ts","../../../node_modules/@types/node/timers/promises.d.ts","../../../node_modules/@types/node/tls.d.ts","../../../node_modules/@types/node/trace_events.d.ts","../../../node_modules/@types/node/tty.d.ts","../../../node_modules/@types/node/url.d.ts","../../../node_modules/@types/node/util.d.ts","../../../node_modules/@types/node/util/types.d.ts","../../../node_modules/@types/node/v8.d.ts","../../../node_modules/@types/node/vm.d.ts","../../../node_modules/@types/node/wasi.d.ts","../../../node_modules/@types/node/worker_threads.d.ts","../../../node_modules/@types/node/zlib.d.ts","../../../node_modules/@types/node/zlib/iter.d.ts","../../../node_modules/@types/node/index.d.ts","../../../node_modules/@types/find-package-json/package-json.d.ts","../../../node_modules/@types/find-package-json/index.d.ts"],"fileIdsList":[[100,165,173,178,181,183,184,185,197,224,225],[100,165,173,178,181,183,184,185,197],[100,162,163,165,173,178,181,183,184,185,197],[100,164,165,173,178,181,183,184,185,197],[165,173,178,181,183,184,185,197],[100,165,173,178,181,183,184,185,197,206],[100,165,166,171,173,176,178,181,183,184,185,187,197,202,215],[100,165,166,167,173,176,178,181,183,184,185,197],[100,165,168,173,178,181,183,184,185,197,216],[100,165,169,170,173,178,181,183,184,185,188,197],[100,165,170,173,178,181,183,184,185,197,202,212],[100,165,171,173,176,178,181,183,184,185,187,197],[100,164,165,172,173,178,181,183,184,185,197],[100,165,173,174,178,181,183,184,185,197],[100,165,173,175,176,178,181,183,184,185,197],[100,164,165,173,176,178,181,183,184,185,197],[100,165,173,176,178,179,181,183,184,185,197,202,215],[100,165,173,176,178,179,181,183,184,185,197,202,204,206],[100,152,165,173,176,178,180,181,183,184,185,187,197,202,215],[100,165,173,176,178,180,181,183,184,185,187,197,202,212,215],[100,165,173,178,180,181,182,183,184,185,197,202,212,215],[99,100,101,102,103,104,105,106,107,108,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223],[100,165,173,176,178,181,183,184,185,197],[100,165,173,178,181,183,185,197],[100,165,173,178,181,183,184,185,186,197,215],[100,165,173,176,178,181,183,184,185,187,197,202],[100,165,173,178,181,183,184,185,188,197],[100,165,173,178,181,183,184,185,189,197],[100,165,173,176,178,181,183,184,185,192,197],[100,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222],[100,165,173,178,181,183,184,185,194,197],[100,165,173,178,181,183,184,185,195,197],[100,165,170,173,178,181,183,184,185,187,197,206],[100,165,173,176,178,181,183,184,185,197,198],[100,165,173,178,181,183,184,185,197,199,216,219],[100,165,173,176,178,181,183,184,185,197,202,204,205,206],[100,165,173,178,181,183,184,185,197,203,206],[100,165,173,176,178,181,183,184,185,197,202,204],[100,165,173,176,178,181,183,184,185,197,202,205,206],[100,165,173,178,181,183,184,185,197,206,216],[100,165,173,178,181,183,184,185,197,207],[100,162,165,173,178,181,183,184,185,197,202,209,215],[100,165,173,178,181,183,184,185,197,202,208],[100,165,173,176,178,181,183,184,185,197,210,211],[100,165,173,178,181,183,184,185,197,210,211],[100,165,170,173,178,181,183,184,185,187,197,202,212],[100,165,173,178,181,183,184,185,197,213],[100,165,173,178,181,183,184,185,187,197,214],[100,165,173,178,180,181,183,184,185,195,197,215],[100,165,173,178,181,183,184,185,197,216,217],[100,165,170,173,178,181,183,184,185,197,217],[100,165,173,178,181,183,184,185,197,202,218],[100,165,173,178,181,183,184,185,186,197,219],[100,165,173,178,181,183,184,185,197,220],[100,165,168,173,178,181,183,184,185,197],[100,165,170,173,178,181,183,184,185,197],[100,165,173,178,181,183,184,185,197,216],[100,152,165,173,178,181,183,184,185,197],[100,165,173,178,181,183,184,185,197,215],[100,165,173,178,181,183,184,185,197,221],[100,165,173,178,181,183,184,185,192,197],[100,165,173,178,181,183,184,185,197,211],[100,152,165,173,176,178,179,181,183,184,185,192,197,202,206,215,218,219,221],[100,165,173,178,181,183,184,185,197,202,222],[100,165,173,178,181,183,184,185,197,204,223],[100,115,118,121,122,165,173,178,181,183,184,185,197,215],[100,118,165,173,178,181,183,184,185,197,202,215],[100,118,122,165,173,178,181,183,184,185,197,215],[100,165,173,178,181,183,184,185,197,202],[100,112,165,173,178,181,183,184,185,197],[100,116,165,173,178,181,183,184,185,197],[100,114,115,118,165,173,178,181,183,184,185,197,215],[100,165,173,178,181,183,184,185,187,197,212],[100,165,173,178,181,183,184,185,197,224],[100,112,165,173,178,181,183,184,185,197,224],[100,114,118,165,173,178,181,183,184,185,187,197,215],[100,109,110,111,113,117,165,173,176,178,181,183,184,185,197,202,215],[100,118,165,173,178,181,183,184,185,197],[100,118,127,136,165,173,178,181,183,184,185,197],[100,110,116,165,173,178,181,183,184,185,197],[100,118,146,147,165,173,178,181,183,184,185,197],[100,110,113,118,165,173,178,181,183,184,185,197,206,215,224],[100,114,118,165,173,178,181,183,184,185,197,215],[100,109,165,173,178,181,183,184,185,197],[100,112,113,114,116,117,118,119,120,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,147,148,149,150,151,165,173,178,181,183,184,185,197],[100,118,139,142,165,173,178,181,183,184,185,197],[100,118,127,129,130,165,173,178,181,183,184,185,197],[100,116,118,129,131,165,173,178,181,183,184,185,197],[100,117,165,173,178,181,183,184,185,197],[100,110,112,118,165,173,178,181,183,184,185,197],[100,118,122,129,131,165,173,178,181,183,184,185,197],[100,122,165,173,178,181,183,184,185,197],[100,116,118,121,165,173,178,181,183,184,185,197,215],[100,110,114,118,127,165,173,178,181,183,184,185,197],[100,118,139,165,173,178,181,183,184,185,197],[100,131,165,173,178,181,183,184,185,197],[100,110,114,118,122,165,173,178,181,183,184,185,197],[100,112,118,146,165,173,178,181,183,184,185,197,206,221,224],[81,85,100,165,173,178,181,183,184,185,197],[80,81,100,165,173,178,181,183,184,185,197,202],[82,100,165,173,178,181,183,184,185,197],[81,82,83,84,85,86,100,165,173,178,181,183,184,185,197],[87,100,165,166,173,178,181,183,184,185,197],[93,100,165,173,178,181,183,184,185,197],[80,87,88,89,90,91,92,94,96,100,165,170,173,178,179,181,183,184,185,189,197],[97,100,165,173,178,181,183,184,185,197],[95,97,100,165,173,178,181,183,184,185,189,197]],"fileInfos":[{"version":"bcd24271a113971ba9eb71ff8cb01bc6b0f872a85c23fdbe5d93065b375933cd","affectsGlobalScope":true,"impliedFormat":1},{"version":"3f88bedbeb09c6f5a6645cb24c7c55f1aa22d19ae96c8e6959cbd8b85a707bc6","impliedFormat":1},{"version":"7fe93b39b810eadd916be8db880dd7f0f7012a5cc6ffb62de8f62a2117fa6f1f","impliedFormat":1},{"version":"bb0074cc08b84a2374af33d8bf044b80851ccc9e719a5e202eacf40db2c31600","impliedFormat":1},{"version":"1a7daebe4f45fb03d9ec53d60008fbf9ac45a697fdc89e4ce218bc94b94f94d6","impliedFormat":1},{"version":"f94b133a3cb14a288803be545ac2683e0d0ff6661bcd37e31aaaec54fc382aed","impliedFormat":1},{"version":"f59d0650799f8782fd74cf73c19223730c6d1b9198671b1c5b3a38e1188b5953","impliedFormat":1},{"version":"8a15b4607d9a499e2dbeed9ec0d3c0d7372c850b2d5f1fb259e8f6d41d468a84","impliedFormat":1},{"version":"26e0fe14baee4e127f4365d1ae0b276f400562e45e19e35fd2d4c296684715e6","impliedFormat":1},{"version":"1e9332c23e9a907175e0ffc6a49e236f97b48838cc8aec9ce7e4cec21e544b65","impliedFormat":1},{"version":"3753fbc1113dc511214802a2342280a8b284ab9094f6420e7aa171e868679f91","impliedFormat":1},{"version":"999ca32883495a866aa5737fe1babc764a469e4cde6ee6b136a4b9ae68853e4b","impliedFormat":1},{"version":"eadcffda2aa84802c73938e589b9e58248d74c59cb7fcbca6474e3435ac15504","affectsGlobalScope":true,"impliedFormat":1},{"version":"105ba8ff7ba746404fe1a2e189d1d3d2e0eb29a08c18dded791af02f29fb4711","affectsGlobalScope":true,"impliedFormat":1},{"version":"00343ca5b2e3d48fa5df1db6e32ea2a59afab09590274a6cccb1dbae82e60c7c","affectsGlobalScope":true,"impliedFormat":1},{"version":"ebd9f816d4002697cb2864bea1f0b70a103124e18a8cd9645eeccc09bdf80ab4","affectsGlobalScope":true,"impliedFormat":1},{"version":"2c1afac30a01772cd2a9a298a7ce7706b5892e447bb46bdbeef720f7b5da77ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"7b0225f483e4fa685625ebe43dd584bb7973bbd84e66a6ba7bbe175ee1048b4f","affectsGlobalScope":true,"impliedFormat":1},{"version":"c0a4b8ac6ce74679c1da2b3795296f5896e31c38e888469a8e0f99dc3305de60","affectsGlobalScope":true,"impliedFormat":1},{"version":"3084a7b5f569088e0146533a00830e206565de65cae2239509168b11434cd84f","affectsGlobalScope":true,"impliedFormat":1},{"version":"c5079c53f0f141a0698faa903e76cb41cd664e3efb01cc17a5c46ec2eb0bef42","affectsGlobalScope":true,"impliedFormat":1},{"version":"32cafbc484dea6b0ab62cf8473182bbcb23020d70845b406f80b7526f38ae862","affectsGlobalScope":true,"impliedFormat":1},{"version":"fca4cdcb6d6c5ef18a869003d02c9f0fd95df8cfaf6eb431cd3376bc034cad36","affectsGlobalScope":true,"impliedFormat":1},{"version":"b93ec88115de9a9dc1b602291b85baf825c85666bf25985cc5f698073892b467","affectsGlobalScope":true,"impliedFormat":1},{"version":"f5c06dcc3fe849fcb297c247865a161f995cc29de7aa823afdd75aaaddc1419b","affectsGlobalScope":true,"impliedFormat":1},{"version":"b77e16112127a4b169ef0b8c3a4d730edf459c5f25fe52d5e436a6919206c4d7","affectsGlobalScope":true,"impliedFormat":1},{"version":"fbffd9337146eff822c7c00acbb78b01ea7ea23987f6c961eba689349e744f8c","affectsGlobalScope":true,"impliedFormat":1},{"version":"a995c0e49b721312f74fdfb89e4ba29bd9824c770bbb4021d74d2bf560e4c6bd","affectsGlobalScope":true,"impliedFormat":1},{"version":"c7b3542146734342e440a84b213384bfa188835537ddbda50d30766f0593aff9","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce6180fa19b1cccd07ee7f7dbb9a367ac19c0ed160573e4686425060b6df7f57","affectsGlobalScope":true,"impliedFormat":1},{"version":"3f02e2476bccb9dbe21280d6090f0df17d2f66b74711489415a8aa4df73c9675","affectsGlobalScope":true,"impliedFormat":1},{"version":"45e3ab34c1c013c8ab2dc1ba4c80c780744b13b5676800ae2e3be27ae862c40c","affectsGlobalScope":true,"impliedFormat":1},{"version":"805c86f6cca8d7702a62a844856dbaa2a3fd2abef0536e65d48732441dde5b5b","affectsGlobalScope":true,"impliedFormat":1},{"version":"e42e397f1a5a77994f0185fd1466520691456c772d06bf843e5084ceb879a0ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"f4c2b41f90c95b1c532ecc874bd3c111865793b23aebcc1c3cbbabcd5d76ffb0","affectsGlobalScope":true,"impliedFormat":1},{"version":"ab26191cfad5b66afa11b8bf935ef1cd88fabfcb28d30b2dfa6fad877d050332","affectsGlobalScope":true,"impliedFormat":1},{"version":"2088bc26531e38fb05eedac2951480db5309f6be3fa4a08d2221abb0f5b4200d","affectsGlobalScope":true,"impliedFormat":1},{"version":"cb9d366c425fea79716a8fb3af0d78e6b22ebbab3bd64d25063b42dc9f531c1e","affectsGlobalScope":true,"impliedFormat":1},{"version":"500934a8089c26d57ebdb688fc9757389bb6207a3c8f0674d68efa900d2abb34","affectsGlobalScope":true,"impliedFormat":1},{"version":"689da16f46e647cef0d64b0def88910e818a5877ca5379ede156ca3afb780ac3","affectsGlobalScope":true,"impliedFormat":1},{"version":"bc21cc8b6fee4f4c2440d08035b7ea3c06b3511314c8bab6bef7a92de58a2593","affectsGlobalScope":true,"impliedFormat":1},{"version":"7ca53d13d2957003abb47922a71866ba7cb2068f8d154877c596d63c359fed25","affectsGlobalScope":true,"impliedFormat":1},{"version":"54725f8c4df3d900cb4dac84b64689ce29548da0b4e9b7c2de61d41c79293611","affectsGlobalScope":true,"impliedFormat":1},{"version":"e5594bc3076ac29e6c1ebda77939bc4c8833de72f654b6e376862c0473199323","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f3eb332c2d73e729f3364fcc0c2b375e72a121e8157d25a82d67a138c83a95c","affectsGlobalScope":true,"impliedFormat":1},{"version":"6f4427f9642ce8d500970e4e69d1397f64072ab73b97e476b4002a646ac743b1","affectsGlobalScope":true,"impliedFormat":1},{"version":"48915f327cd1dea4d7bd358d9dc7732f58f9e1626a29cc0c05c8c692419d9bb7","affectsGlobalScope":true,"impliedFormat":1},{"version":"b7bf9377723203b5a6a4b920164df22d56a43f593269ba6ae1fdc97774b68855","affectsGlobalScope":true,"impliedFormat":1},{"version":"db9709688f82c9e5f65a119c64d835f906efe5f559d08b11642d56eb85b79357","affectsGlobalScope":true,"impliedFormat":1},{"version":"4b25b8c874acd1a4cf8444c3617e037d444d19080ac9f634b405583fd10ce1f7","affectsGlobalScope":true,"impliedFormat":1},{"version":"37be57d7c90cf1f8112ee2636a068d8fd181289f82b744160ec56a7dc158a9f5","affectsGlobalScope":true,"impliedFormat":1},{"version":"a917a49ac94cd26b754ab84e113369a75d1a47a710661d7cd25e961cc797065f","affectsGlobalScope":true,"impliedFormat":1},{"version":"6d3261badeb7843d157ef3e6f5d1427d0eeb0af0cf9df84a62cfd29fd47ac86e","affectsGlobalScope":true,"impliedFormat":1},{"version":"195daca651dde22f2167ac0d0a05e215308119a3100f5e6268e8317d05a92526","affectsGlobalScope":true,"impliedFormat":1},{"version":"8b11e4285cd2bb164a4dc09248bdec69e9842517db4ca47c1ba913011e44ff2f","affectsGlobalScope":true,"impliedFormat":1},{"version":"0508571a52475e245b02bc50fa1394065a0a3d05277fbf5120c3784b85651799","affectsGlobalScope":true,"impliedFormat":1},{"version":"8f9af488f510c3015af3cc8c267a9e9d96c4dd38a1fdff0e11dc5a544711415b","affectsGlobalScope":true,"impliedFormat":1},{"version":"fc611fea8d30ea72c6bbfb599c9b4d393ce22e2f5bfef2172534781e7d138104","affectsGlobalScope":true,"impliedFormat":1},{"version":"0bd714129fca875f7d4c477a1a392200b0bcd13fb2e80928cd334b63830ea047","affectsGlobalScope":true,"impliedFormat":1},{"version":"e2c9037ae6cd2c52d80ceef0b3c5ffdb488627d71529cf4f63776daf11161c9a","affectsGlobalScope":true,"impliedFormat":1},{"version":"135d5cf4d345f59f1a9caadfafcd858d3d9cc68290db616cc85797224448cccc","affectsGlobalScope":true,"impliedFormat":1},{"version":"bc238c3f81c2984751932b6aab223cd5b830e0ac6cad76389e5e9d2ffc03287d","affectsGlobalScope":true,"impliedFormat":1},{"version":"4a07f9b76d361f572620927e5735b77d6d2101c23cdd94383eb5b706e7b36357","affectsGlobalScope":true,"impliedFormat":1},{"version":"7c4e8dc6ab834cc6baa0227e030606d29e3e8449a9f67cdf5605ea5493c4db29","affectsGlobalScope":true,"impliedFormat":1},{"version":"de7ba0fd02e06cd9a5bd4ab441ed0e122735786e67dde1e849cced1cd8b46b78","affectsGlobalScope":true,"impliedFormat":1},{"version":"6148e4e88d720a06855071c3db02069434142a8332cf9c182cda551adedf3156","affectsGlobalScope":true,"impliedFormat":1},{"version":"d63dba625b108316a40c95a4425f8d4294e0deeccfd6c7e59d819efa19e23409","affectsGlobalScope":true,"impliedFormat":1},{"version":"0568d6befee03dd435bed4fc25c4e46865b24bdcb8c563fdc21f580a2c301904","affectsGlobalScope":true,"impliedFormat":1},{"version":"30d62269b05b584741f19a5369852d5d34895aa2ac4fd948956f886d15f9cc0d","affectsGlobalScope":true,"impliedFormat":1},{"version":"f128dae7c44d8f35ee42e0a437000a57c9f06cc04f8b4fb42eebf44954d53dc8","affectsGlobalScope":true,"impliedFormat":1},{"version":"ffbe6d7b295306b2ba88030f65b74c107d8d99bdcf596ea99c62a02f606108b0","affectsGlobalScope":true,"impliedFormat":1},{"version":"996fb27b15277369c68a4ba46ed138b4e9e839a02fb4ec756f7997629242fd9f","affectsGlobalScope":true,"impliedFormat":1},{"version":"79b712591b270d4778c89706ca2cfc56ddb8c3f895840e477388f1710dc5eda9","affectsGlobalScope":true,"impliedFormat":1},{"version":"20884846cef428b992b9bd032e70a4ef88e349263f63aeddf04dda837a7dba26","affectsGlobalScope":true,"impliedFormat":1},{"version":"db59a81f070c1880ad645b2c0275022baa6a0c4f0acdc58d29d349c6efcf0903","affectsGlobalScope":true,"impliedFormat":1},{"version":"1ecb8e347cb6b2a8927c09b86263663289418df375f5e68e11a0ae683776978f","affectsGlobalScope":true,"impliedFormat":1},{"version":"4ffedae1d1c2d53fdbca1c96d3c7dda544281f7d262f99b6880634f8fd8d9820","affectsGlobalScope":true,"impliedFormat":1},{"version":"1ce14b81c5cc821994aa8ec1d42b220dd41b27fcc06373bce3958af7421b77d4","affectsGlobalScope":true,"impliedFormat":1},{"version":"b3a048b3e9302ef9a34ef4ebb9aecfb28b66abb3bce577206a79fee559c230da","affectsGlobalScope":true,"impliedFormat":1},{"version":"b507173a7718609bb52011f33e6fc61b0f3de62ec38c935b38dcfbb68223dea9","impliedFormat":99},{"version":"b9d885dfb75202756c7faa24450a3ea7060f90fc117304d795259e2d5efe005f","impliedFormat":99},{"version":"c2c45e23c9ade84835e6589a92f4b1e0d959f4aad517ca2b9f306d505c8c186b","impliedFormat":99},{"version":"d5f72b73663996558032aae95128fd1c003dbc2a3c7c9616a4b9582885554547","impliedFormat":99},{"version":"e57056025ca2a90d0a3af80fca4a0b31e83e5325c80b4207cee4546521bad645","impliedFormat":99},{"version":"d096b43d56e50a815348abdc7f505bff20b7326edd25d5ceab70be8ae550b216","impliedFormat":99},{"version":"f4b14039ec5893b0c7691e5695493a13207b5a6e7ea07e9d58fe3f112e9e87fd","impliedFormat":99},{"version":"b83a9041067ced394f3cd30aa56868504af4110a549c98f236671c6d2d9e08b6","impliedFormat":99},{"version":"f65327e250d4fbac1ad1b516c28c5ec07e112cde36839a71ff88712c0bf67a9e","impliedFormat":99},{"version":"cb5c7d71525f231186e6533d1777efaca83cc03f270ba9f723ee8e4eb6e502d2","impliedFormat":99},{"version":"fb0a438a65acb111212232a8daf7138ca1895daf1195839af168f3f528186970","impliedFormat":99},{"version":"d5af5a55477c977d5c969e0b57015847db4ef7444431770cabb0dc067c35b629","impliedFormat":99},{"version":"3fdb492c7902b3162a9fa765e5ce843a831b87bf6a47c1aa4b73056e39a2eb17","impliedFormat":99},{"version":"6ea4541b3262486e583afb3e554fca8e5b8b0d3ed4c3fe299ff9508795d72934","impliedFormat":99},{"version":"41c2effc93c4a7c1143353cdd450d9f8b91c091630764c5654727bcb5af3cfce","impliedFormat":99},{"version":"a6005262ef9ae5d7325a381df594d6b35babfb6df4a89c4febd06e6101d05bc1","impliedFormat":99},{"version":"2715ab91e6214da7b38139a3964789d80566858b66603c16614989b24e5d0e88","signature":"a386d028b73f2db1d3aa1adad97e812ee588a82fa4b899eebebf7ac931bf2590","impliedFormat":99},{"version":"e47987ad29e100b3f85128a4f5649147608e13c7a3e5ed988096bd34620f94d7","signature":"9694552ae6739725fca4e20caa855f657a9dd893c37372a154b43472abc3c94d","impliedFormat":99},{"version":"6263cce5dbfb94becf003f5fe050254e82ab24d218222cbed30b2e4e5df7ce24","impliedFormat":99},{"version":"0ccdaa19852d25ecd84eec365c3bfa16e7859cadecf6e9ca6d0dbbbee439743f","affectsGlobalScope":true,"impliedFormat":1},{"version":"cc2110f7decca6bfb9392e30421cfa1436479e4a6756e8fec6cbc22625d4f881","affectsGlobalScope":true,"impliedFormat":1},{"version":"f53a7652392cf26ebbe4e29fd0672aa87c93bd6d0241289c13fab87b9ac35c8a","affectsGlobalScope":true,"impliedFormat":1},{"version":"e5e01375c9e124a83b52ee4b3244ed1a4d214a6cfb54ac73e164a823a4a7860a","affectsGlobalScope":true,"impliedFormat":1},{"version":"f90ae2bbce1505e67f2f6502392e318f5714bae82d2d969185c4a6cecc8af2fc","affectsGlobalScope":true,"impliedFormat":1},{"version":"4b58e207b93a8f1c88bbf2a95ddc686ac83962b13830fe8ad3f404ffc7051fb4","affectsGlobalScope":true,"impliedFormat":1},{"version":"1fefabcb2b06736a66d2904074d56268753654805e829989a46a0161cd8412c5","affectsGlobalScope":true,"impliedFormat":1},{"version":"b00a630557d1622ad312633bdbfbdb9c6b7220d948dca9f899db30679f160074","affectsGlobalScope":true,"impliedFormat":1},{"version":"c18a99f01eb788d849ad032b31cafd49de0b19e083fe775370834c5675d7df8e","affectsGlobalScope":true,"impliedFormat":1},{"version":"5247874c2a23b9a62d178ae84f2db6a1d54e6c9a2e7e057e178cc5eea13757fc","affectsGlobalScope":true,"impliedFormat":1},{"version":"cdcf9ea426ad970f96ac930cd176d5c69c6c24eebd9fc580e1572d6c6a88f62c","impliedFormat":1},{"version":"88809d6c1b9c78d04a133646a6feb926def05a8774c308c7c93bc32ee163d271","impliedFormat":1},{"version":"156a859e21ef3244d13afeeba4e49760a6afa035c149dda52f0c45ea8903b338","impliedFormat":1},{"version":"3ac40516c33b87f751f7507346933081a26cdb8a3e11a6b3aa07d23f803c85db","impliedFormat":1},{"version":"615754924717c0b1e293e083b83503c0a872717ad5aa60ed7f1a699eb1b4ea5c","impliedFormat":1},{"version":"14e9acf826baba0ef4b5665704084896e7bcc06f65a9ab13af7e93d27d6b7069","impliedFormat":1},{"version":"68834d631c8838c715f225509cfc3927913b9cc7a4870460b5b60c8dbdb99baf","impliedFormat":1},{"version":"829bc57ee8f287b490ab5bbc5a962fca57e432c1e38ec680ecd3ecaf12800613","impliedFormat":1},{"version":"eec76bf6b9346f3f95fa402621b889489e96930e72295b0369022f332e9b4a6a","impliedFormat":1},{"version":"3a3ff14da53d5013f3e6d8c4ad55225e3649c08786c4421ce639c00d8d589b7d","impliedFormat":1},{"version":"ea6bc8de8b59f90a7a3960005fd01988f98fd0784e14bc6922dde2e93305ec7d","impliedFormat":1},{"version":"36107995674b29284a115e21a0618c4c2751b32a8766dd4cb3ba740308b16d59","impliedFormat":1},{"version":"914a0ae30d96d71915fc519ccb4efbf2b62c0ddfb3a3fc6129151076bc01dc60","impliedFormat":1},{"version":"38004e6801340cb890afb8cb5a9fc8972297e7f88ab94026e4b0b3c61fb32f8a","impliedFormat":1},{"version":"d243db6b25788f439e7e2f03c05688e92f46764351673bb0e7b2f3631232e186","impliedFormat":1},{"version":"4d327f7d72ad0918275cea3eee49a6a8dc8114ae1d5b7f3f5d0774de75f7439a","impliedFormat":1},{"version":"149f9a9e7f04e67afa0e2a49fc0ff421035c01d6b793cfcae7d2e9f6819431e2","impliedFormat":1},{"version":"e8a9dfa4c75ef6d25df8b40eaa9c31e0a69452aaf2ced4a3f4215dbdbaa876f4","impliedFormat":1},{"version":"a70af845a2eb9dd6e2723e319e14ea7fb28b129ec1361c21509b49305448c323","impliedFormat":1},{"version":"b53dc572d4f187904207ae1166652de47aab8eeb00c254d009cb226863076b56","impliedFormat":1},{"version":"0a60a292b89ca7218b8616f78e5bbd1c96b87e048849469cccb4355e98af959a","impliedFormat":1},{"version":"0b6e25234b4eec6ed96ab138d96eb70b135690d7dd01f3dd8a8ab291c35a683a","impliedFormat":1},{"version":"9666f2f84b985b62400d2e5ab0adae9ff44de9b2a34803c2c5bd3c8325b17dc0","impliedFormat":1},{"version":"40cd35c95e9cf22cfa5bd84e96408b6fcbca55295f4ff822390abb11afbc3dca","impliedFormat":1},{"version":"b1616b8959bf557feb16369c6124a97a0e74ed6f49d1df73bb4b9ddf68acf3f3","impliedFormat":1},{"version":"f501234c5aeeeb5d7659412335227466aaacf30b952372d60afeb21c02c96348","impliedFormat":1},{"version":"40b463c6766ca1b689bfcc46d26b5e295954f32ad43e37ee6953c0a677e4ae2b","impliedFormat":1},{"version":"9ac977503f15bf13ca7c82ad9a32a782f42d43e474824e8b3bffe228fd5f2639","impliedFormat":1},{"version":"8b91ff5bb912be3ea213cbcf0075aace1f5d4ff249a0d227ed673868cb7bfabc","impliedFormat":1},{"version":"80aae6afc67faa5ac0b32b5b8bc8cc9f7fa299cff15cf09cc2e11fd28c6ae29e","impliedFormat":1},{"version":"f473cd2288991ff3221165dcf73cd5d24da30391f87e85b3dd4d0450c787a391","impliedFormat":1},{"version":"499e5b055a5aba1e1998f7311a6c441a369831c70905cc565ceac93c28083d53","impliedFormat":1},{"version":"8aee8b6d4f9f62cf3776cda1305fb18763e2aade7e13cea5bbe699112df85214","impliedFormat":1},{"version":"98498b101803bb3dde9f76a56e65c14b75db1cc8bec5f4db72be541570f74fc5","impliedFormat":1},{"version":"7cb4f431a4591b0e23002bed805dc871a874dfed6b9a3994dce68a6df73e6739","impliedFormat":1},{"version":"5d0375ca7310efb77e3ef18d068d53784faf62705e0ad04569597ae0e755c401","impliedFormat":1},{"version":"59af37caec41ecf7b2e76059c9672a49e682c1a2aa6f9d7dc78878f53aa284d6","impliedFormat":1},{"version":"addf417b9eb3f938fddf8d81e96393a165e4be0d4a8b6402292f9c634b1cb00d","impliedFormat":1},{"version":"436d7b4543b340b0f3eef4310d524242e41369b9652aa9c70428767c4dcac455","impliedFormat":1},{"version":"adf27937dba6af9f08a68c5b1d3fce0ca7d4b960c57e6d6c844e7d1a8e53adae","impliedFormat":1},{"version":"12950411eeab8563b349cb7959543d92d8d02c289ed893d78499a19becb5a8cc","impliedFormat":1},{"version":"2e85db9e6fd73cfa3d7f28e0ab6b55417ea18931423bd47b409a96e4a169e8e6","impliedFormat":1},{"version":"c46e079fe54c76f95c67fb89081b3e399da2c7d109e7dca8e4b58d83e332e605","impliedFormat":1},{"version":"e99963ae1e3a48ca7a7958c02f3e88bb963eb7978c28b68ae6b8c9f03309d83c","impliedFormat":1},{"version":"c3f5289820990ab66b70c7fb5b63cb674001009ff84b13de40619619a9c8175f","affectsGlobalScope":true,"impliedFormat":1},{"version":"b3275d55fac10b799c9546804126239baf020d220136163f763b55a74e50e750","affectsGlobalScope":true,"impliedFormat":1},{"version":"fa68a0a3b7cb32c00e39ee3cd31f8f15b80cac97dce51b6ee7fc14a1e8deb30b","affectsGlobalScope":true,"impliedFormat":1},{"version":"1cf059eaf468efcc649f8cf6075d3cb98e9a35a0fe9c44419ec3d2f5428d7123","affectsGlobalScope":true,"impliedFormat":1},{"version":"6c36e755bced82df7fb6ce8169265d0a7bb046ab4e2cb6d0da0cb72b22033e89","affectsGlobalScope":true,"impliedFormat":1},{"version":"e7721c4f69f93c91360c26a0a84ee885997d748237ef78ef665b153e622b36c1","affectsGlobalScope":true,"impliedFormat":1},{"version":"7a93de4ff8a63bafe62ba86b89af1df0ccb5e40bb85b0c67d6bbcfdcf96bf3d4","affectsGlobalScope":true,"impliedFormat":1},{"version":"90e85f9bc549dfe2b5749b45fe734144e96cd5d04b38eae244028794e142a77e","affectsGlobalScope":true,"impliedFormat":1},{"version":"e0a5deeb610b2a50a6350bd23df6490036a1773a8a71d70f2f9549ab009e67ee","affectsGlobalScope":true,"impliedFormat":1},{"version":"594ae90cacd813fa392ff80d2e0a8eff4e41f4a136329a940e321399dd8895b4","impliedFormat":1},{"version":"d1f333ade8ff35a409b4984e1f11956fe11c61855b0c7e9b59f0313e48b40c4a","impliedFormat":1},{"version":"0224aa4b3464895d69c413a640a19ac2166778a74eb5eb3b36b021c72d42b274","impliedFormat":1},{"version":"2e6fca0024dd8a076a886d9ec031a936ea59ad878a25b944820495d92f8381dd","affectsGlobalScope":true,"impliedFormat":1},{"version":"177459cba484e2f1e08872a3d2fdbca3162d9d43ca5ec9dc0c946835b55f74be","impliedFormat":1},{"version":"2fbf504c4791f9d32cd766cfe6b605bcda63289b925401953a7900db9af85348","impliedFormat":1},{"version":"ed0fb633cae35948d9e144004299a4bdf1ab912667c787b7fbffcd6d8c7b92a2","impliedFormat":1},{"version":"1678b04557dca52feab73cc67610918a7f5e25bfdba3e7fa081acd625d93106d","impliedFormat":1},{"version":"0e312260895afc9de021ce9de3c8a857392f0ccc7f19d3a030e4d6136a4ac91e","impliedFormat":1},{"version":"2ea729503db9793f2691162fec3dd1118cab62e96d025f8eeb376d43ec293395","impliedFormat":1},{"version":"98fc7231d6c846a8ed19bdef026ddffe5e2182cc818be74899287421ad370a87","impliedFormat":1},{"version":"3a40b5d34e014017539acb92f04cf2bc0aa71e49efb33c66039df93be97842a1","impliedFormat":1},{"version":"2bc7aa4fba46df0bd495425a7c8201437a7d465f83854fac859df2d67f664df3","impliedFormat":1},{"version":"41d17e1ad9a002feb11c8cdd2777e5bbc0cdb1e3f595d237e4dded0b6949983b","impliedFormat":1},{"version":"8c7e618c2a91ea7f6b5cca272a295864e92c16413be8fc56a943e8c7d5320011","affectsGlobalScope":true,"impliedFormat":1},{"version":"79a85c64bf083c5f4dd7074e804d1000c0c47301b84d48417a224decd681be30","impliedFormat":1},{"version":"9f1e3a76d5f509b5579e567de522b402cb79e201c4f47dcd014451c0580b290d","impliedFormat":1},{"version":"2ddab5b6932f9a6327f71baeb82a1d6b0824e0d23a4c7a5de5d355857113c22f","impliedFormat":1},{"version":"70f3f8b2dcaf7388f26731a59c79437813e3620b594903525a303cb2a7901016","impliedFormat":1},{"version":"62e8f884c3bc6dff6189b6e662ebe8b238a645938f2df7a97b8a82fca56773a4","impliedFormat":1},{"version":"2c2bdaa1d8ead9f68628d6d9d250e46ee8e81aa4898b4769a36956ae15e060fe","impliedFormat":1},{"version":"57a0d1b3d59063d4af2d3f8aac27cfe3c20a0f5d1faf0f8598ccf0b779637939","impliedFormat":1},{"version":"5ff4433a2deae4f85ab1377e90a7554ce6b47ae51c69a84ca30a6e22fae85834","impliedFormat":1},{"version":"82b91e4e42e6c41bc7fc1b6c2dc5eba6a2ba98375eb1f210e6ff6bba2d54177e","impliedFormat":1},{"version":"97234c5303866576f913d0ccae7d58d6322d9e803c7bf1228a3fda46ab8087b2","affectsGlobalScope":true,"impliedFormat":1},{"version":"93ecf87143cac7b9d05cffc1d6bdc075b7e4fdd48ff05f1fad85043f6ae678d3","impliedFormat":1},{"version":"6f200afcb82b3e9a54bed6db23f2edf2508cd266801257312c0f124b47f2bdb9","impliedFormat":1},{"version":"ec501101c2a96133a6c695f934c8f6642149cc728571b29cbb7b770984c1088e","impliedFormat":1},{"version":"b214ebcf76c51b115453f69729ee8aa7b7f8eccdae2a922b568a45c2d7ff52f7","impliedFormat":1},{"version":"429c9cdfa7d126255779efd7e6d9057ced2d69c81859bbab32073bad52e9ba76","impliedFormat":1},{"version":"39338f84e8c4d0e3de7b3c4a7024fb3925f42100eed5cbe73be58902799dff4d","impliedFormat":1},{"version":"fbf83eb33bf5e329527add92acc65da59323876c702ddccf5f4bf1e848c92369","affectsGlobalScope":true,"impliedFormat":1},{"version":"230763250f20449fa7b3c9273e1967adb0023dc890d4be1553faca658ee65971","impliedFormat":1},{"version":"c3e9078b60cb329d1221f5878e88cecfa3e74460550e605a58fcfb41a66029ff","impliedFormat":1},{"version":"515318bc6e656f75e9e34db625316bfafbafd800dfb1642574af93735a24ad38","impliedFormat":1},{"version":"441b9bb09013654aa3d050e68b06464d8959b473e85868249d9d18f692acd35b","impliedFormat":1},{"version":"bc18a1991ba681f03e13285fa1d7b99b03b67ee671b7bc936254467177543890","impliedFormat":1},{"version":"55246f15e33ff1e2e9e679b25fa9790a48db55dc63d567fe25fac8b6a0efe911","impliedFormat":1},{"version":"fa94bbf532b7af8f394b95fa310980d6e20bd2d4c871c6a6cb9f70f03750a44b","impliedFormat":1},{"version":"03b7804d69cecd66850abada858ed6d4a59001f8c228a9fe212306ee860a4ff6","impliedFormat":1},{"version":"5b26c4dd672d88336bb929787c9bfb55119e80ba89ec6dc923da1c063892843e","affectsGlobalScope":true,"impliedFormat":1},{"version":"7fa2214bb0d64701bc6f9ce8cde2fd2ff8c571e0b23065fa04a8a5a6beb91511","impliedFormat":1},{"version":"987fd1f85dc36f4b2c927aa3db814ac6b452e970f4f55d24ed4ecbb7df09be00","impliedFormat":1},{"version":"f12624a4a8d042b68914eac1b0a16571fc1c523173fcdf2517c65d191bd5a86c","impliedFormat":1},{"version":"b4769767f13a1692a66186e01c3aa186ff808d5ff72ed36eda8c37738fb2ac92","impliedFormat":1},{"version":"841983e39bd4cbb463be385e92fda11057cab368bf27100a801c492f1d86cbaa","impliedFormat":1},{"version":"683edfc4f2b411ebe04729cb6dc09ddd26fbac2c57771a6d7c55964af776e176","impliedFormat":1},{"version":"1ec3f3a5f04cc42df33274fbe5c0937d9a9e06f249a7a26288d7d54f0763ffd4","impliedFormat":1},{"version":"e4156ddb25aa0e3b5303d372f26957b36778f0f6bbd4326359269873295e3058","affectsGlobalScope":true,"impliedFormat":1},{"version":"cc1b433a84cae05ddc5672d4823170af78606ad21ecef60dbc4570190cbf1357","impliedFormat":1},{"version":"e47f532d6e1617833f13a5b0710c0089d402c89c2f2b54f324e5a20e418d287a","impliedFormat":1},{"version":"7f78cfb2b343838612c192cb251746e3a7c62ac7675726a47e130d9b213f6580","impliedFormat":1},{"version":"201db9cf1687fab1adf5282fcba861f382b32303dc4f67c89d59655e78a25461","impliedFormat":1},{"version":"8e2577e7262051fd3c5bd6ca2b2056d358ff8853565720f92455860824c25188","impliedFormat":1},{"version":"7ec8d7d483f7394f9da611b10d3a0e402f76ff5c991261e6ce43a15f81ca4258","impliedFormat":1},{"version":"bb9dbb4b2ad81e3e71ec5ba4314973718555b9d04ba2a17dfbf875efecb8e2c0","impliedFormat":1},{"version":"82c3cc48c692438e41b94d936b8acd75ca97b18c50fa1af8a0715eb9d07d18cd","impliedFormat":1},{"version":"045a210189ec63c5488410b33f9fca53d77d051599d0d6506d8048551399c5f3","impliedFormat":1},{"version":"99ab6d0d660ce4d21efb52288a39fd35bb3f556980ec5463b1ae8f304a3bbc85","impliedFormat":1},{"version":"632c45ccb4cdc2c3a80c7a36a63dd7763016e59cac5e07bfb3e37e3548957028","impliedFormat":1},{"version":"c9a2daf6cd1eb854cd5b9e424247c5e306692055738c2effd35f7871d942b76e","impliedFormat":1},{"version":"afa1c49f8e559e413d57343339db857d2a8159435cf9cf7d4deb41718fff1b88","impliedFormat":1},{"version":"e50a7130339a951e6da9e968ed5521b0997a5b0479e148914087213839b5474c","impliedFormat":1},{"version":"990db7c9743d636fd3b2820ec8c40b512879da4c82e00488e7a352e2d005fc39","impliedFormat":1},{"version":"f091ed534c92e6408336f94323ecfe1890c0b5e0166154120712ed97ac9754a1","impliedFormat":1}],"root":[[96,98]],"options":{"composite":true,"esModuleInterop":true,"module":199,"outDir":"./","rootDir":"../src","skipLibCheck":true,"target":12,"tsBuildInfoFile":"./.tsbuildinfo"},"referencedMap":[[226,1],[225,2],[162,3],[163,3],[164,4],[100,5],[165,6],[166,7],[167,8],[168,9],[169,10],[170,11],[171,12],[172,13],[173,14],[174,14],[175,15],[176,16],[177,2],[178,17],[179,18],[101,2],[99,2],[180,19],[181,20],[182,21],[224,22],[183,23],[184,24],[185,23],[186,25],[187,26],[188,27],[189,28],[190,28],[191,28],[192,29],[193,30],[194,31],[195,32],[196,33],[197,34],[198,34],[199,35],[200,2],[201,2],[202,36],[203,37],[204,38],[205,39],[206,40],[207,41],[208,42],[209,43],[210,44],[211,45],[212,46],[213,47],[214,48],[215,49],[216,50],[217,51],[218,52],[219,53],[220,54],[102,23],[103,2],[104,55],[105,56],[106,2],[107,57],[108,2],[153,58],[154,59],[155,60],[156,60],[157,61],[158,2],[159,6],[160,62],[161,59],[221,63],[222,64],[223,65],[95,2],[78,2],[79,2],[14,2],[13,2],[2,2],[15,2],[16,2],[17,2],[18,2],[19,2],[20,2],[21,2],[22,2],[3,2],[23,2],[24,2],[4,2],[25,2],[29,2],[26,2],[27,2],[28,2],[30,2],[31,2],[32,2],[5,2],[33,2],[34,2],[35,2],[36,2],[6,2],[40,2],[37,2],[38,2],[39,2],[41,2],[7,2],[42,2],[47,2],[48,2],[43,2],[44,2],[45,2],[46,2],[8,2],[52,2],[49,2],[50,2],[51,2],[53,2],[9,2],[54,2],[55,2],[56,2],[58,2],[57,2],[59,2],[60,2],[10,2],[61,2],[62,2],[63,2],[11,2],[64,2],[65,2],[66,2],[67,2],[68,2],[69,2],[12,2],[70,2],[71,2],[72,2],[73,2],[74,2],[1,2],[75,2],[76,2],[77,2],[127,66],[141,67],[124,68],[142,69],[151,70],[115,71],[116,72],[114,73],[150,74],[145,75],[149,76],[118,77],[128,78],[138,79],[117,80],[148,81],[112,82],[113,75],[119,78],[120,2],[126,83],[123,78],[110,84],[152,85],[143,86],[131,87],[130,78],[132,88],[135,89],[129,90],[133,91],[146,74],[121,92],[122,93],[136,94],[111,69],[140,95],[139,78],[125,93],[134,96],[137,97],[144,2],[109,2],[147,98],[86,99],[82,100],[83,101],[84,101],[85,2],[87,102],[81,2],[88,101],[89,2],[90,2],[91,101],[92,2],[80,2],[93,103],[94,104],[97,105],[98,106],[96,107]],"latestChangedDtsFile":"./index.d.ts","version":"6.0.3"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { ServiceDefinition, type SecretReference, type ServiceEnvironmentTarget } from "@saws/core";
|
|
2
|
+
import { DockerService, type DockerServiceConfig } from "@saws/docker-service";
|
|
3
|
+
export type PostgresConnectionTarget = "container" | "host";
|
|
4
|
+
export type PostgresConnectionInfo = {
|
|
5
|
+
host: string;
|
|
6
|
+
port: string;
|
|
7
|
+
username: string;
|
|
8
|
+
password: string;
|
|
9
|
+
database: string;
|
|
10
|
+
url: string;
|
|
11
|
+
};
|
|
12
|
+
export interface PostgresServiceConfig extends Omit<DockerServiceConfig, "image" | "dockerfile" | "buildContext" | "volumes" | "ports" | "command"> {
|
|
13
|
+
image?: string;
|
|
14
|
+
/** Host port to expose Postgres on. Local dev defaults to 5432; deploys stay private unless set. */
|
|
15
|
+
port?: number;
|
|
16
|
+
/** Database created by the Postgres image and used in generated connection URLs. */
|
|
17
|
+
database?: string;
|
|
18
|
+
/** Postgres superuser created by the Postgres image. Defaults to "postgres". */
|
|
19
|
+
username?: string;
|
|
20
|
+
/** Postgres password secret reference. Omit to store a generated password in SAWS secrets. */
|
|
21
|
+
password?: SecretReference;
|
|
22
|
+
/** Override the Docker volume name. By default SAWS derives a stable stage/service volume. */
|
|
23
|
+
volume?: string;
|
|
24
|
+
/** Enable logical WAL for replication/change data capture use cases. */
|
|
25
|
+
wal_enabled?: boolean;
|
|
26
|
+
/** dbmate image used to apply migrations in an ephemeral sibling container. */
|
|
27
|
+
migrationImage?: string;
|
|
28
|
+
}
|
|
29
|
+
export declare class PostgresService extends DockerService {
|
|
30
|
+
static getCommands(services?: ServiceDefinition[]): import("commander").Command[];
|
|
31
|
+
readonly port?: number;
|
|
32
|
+
readonly database?: string;
|
|
33
|
+
readonly username: string;
|
|
34
|
+
readonly password?: SecretReference;
|
|
35
|
+
readonly volume?: string;
|
|
36
|
+
readonly walEnabled: boolean;
|
|
37
|
+
readonly migrationImage: string;
|
|
38
|
+
protected readonly serviceType = "postgres";
|
|
39
|
+
constructor(config: PostgresServiceConfig);
|
|
40
|
+
init(): Promise<void>;
|
|
41
|
+
getEnvironmentVariables(stage: string, target?: ServiceEnvironmentTarget): Promise<Record<string, string>>;
|
|
42
|
+
dev(): Promise<void>;
|
|
43
|
+
deploy(stage: string): Promise<void>;
|
|
44
|
+
getConnectionInfo(stage: string, target?: PostgresConnectionTarget): Promise<PostgresConnectionInfo>;
|
|
45
|
+
toDatabaseUrl(connection: Omit<PostgresConnectionInfo, "url">): string;
|
|
46
|
+
protected getContainerEnvironment(stage: string): Promise<Record<string, string>>;
|
|
47
|
+
protected getDockerRunConfig(stage: string, deploy: boolean): Promise<{
|
|
48
|
+
volumes: string[];
|
|
49
|
+
ports: string[];
|
|
50
|
+
command: string[] | undefined;
|
|
51
|
+
name: string;
|
|
52
|
+
image: string;
|
|
53
|
+
network: string;
|
|
54
|
+
env?: Record<string, string>;
|
|
55
|
+
envFiles?: string[];
|
|
56
|
+
labels?: Record<string, string>;
|
|
57
|
+
restart?: import("@saws/docker-service").RestartConfig;
|
|
58
|
+
healthCheck?: import("@saws/docker-service").DockerHealthCheckConfig | false;
|
|
59
|
+
pull?: boolean;
|
|
60
|
+
configHash?: string;
|
|
61
|
+
}>;
|
|
62
|
+
protected onContainerStarted(stage: string): Promise<void>;
|
|
63
|
+
runMigrations(stage: string, options: {
|
|
64
|
+
rootDir: string;
|
|
65
|
+
dbmateArgs: string[];
|
|
66
|
+
readOnly?: boolean;
|
|
67
|
+
dryRun?: boolean;
|
|
68
|
+
}): Promise<void>;
|
|
69
|
+
private runMigrationContainer;
|
|
70
|
+
private runLocalMigrations;
|
|
71
|
+
private writeMigrationLog;
|
|
72
|
+
private get migrationLogServiceName();
|
|
73
|
+
private get environmentVariablePrefix();
|
|
74
|
+
private getHost;
|
|
75
|
+
private getHostPort;
|
|
76
|
+
private getVolumeName;
|
|
77
|
+
private defaultDatabaseName;
|
|
78
|
+
private toOutputs;
|
|
79
|
+
private getOrCreateManagedPassword;
|
|
80
|
+
private resolvePassword;
|
|
81
|
+
}
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { randomBytes } from "node:crypto";
|
|
2
|
+
import { mkdir, readFile, stat } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { SecretsManager, } from "@saws/core";
|
|
5
|
+
import { hasDependency, installDependencies } from "@saws/core/utils/dependency-management";
|
|
6
|
+
import { fileExists } from "@saws/core/utils/file-exists";
|
|
7
|
+
import { listFiles } from "@saws/core/utils/list-files";
|
|
8
|
+
import { runLocal } from "@saws/core/utils/run-local";
|
|
9
|
+
import { shellQuote } from "@saws/core/utils/shell-quote";
|
|
10
|
+
import { DockerService, } from "@saws/docker-service";
|
|
11
|
+
import { createMigrateCommand } from "./migrate-command.js";
|
|
12
|
+
const POSTGRES_VOLUME_DIRECTORY = "/var/lib/postgresql";
|
|
13
|
+
export class PostgresService extends DockerService {
|
|
14
|
+
static getCommands(services = []) {
|
|
15
|
+
return [createMigrateCommand(services.filter(isPostgresService))];
|
|
16
|
+
}
|
|
17
|
+
port;
|
|
18
|
+
database;
|
|
19
|
+
username;
|
|
20
|
+
password;
|
|
21
|
+
volume;
|
|
22
|
+
walEnabled;
|
|
23
|
+
migrationImage;
|
|
24
|
+
serviceType = "postgres";
|
|
25
|
+
constructor(config) {
|
|
26
|
+
super({
|
|
27
|
+
...config,
|
|
28
|
+
image: config.image ?? "postgres:18",
|
|
29
|
+
healthCheck: config.healthCheck ?? {
|
|
30
|
+
command: 'pg_isready -U "$POSTGRES_USER" -d "$POSTGRES_DB"',
|
|
31
|
+
interval: "10s",
|
|
32
|
+
timeout: "5s",
|
|
33
|
+
retries: 5,
|
|
34
|
+
startPeriod: "10s",
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
this.port = config.port;
|
|
38
|
+
this.database = config.database;
|
|
39
|
+
this.username = config.username ?? "postgres";
|
|
40
|
+
this.password = config.password;
|
|
41
|
+
this.volume = config.volume;
|
|
42
|
+
this.walEnabled = config.wal_enabled ?? false;
|
|
43
|
+
this.migrationImage = config.migrationImage ?? "ghcr.io/amacneil/dbmate:2.33.0";
|
|
44
|
+
}
|
|
45
|
+
async init() {
|
|
46
|
+
await super.init();
|
|
47
|
+
await mkdir(path.resolve(this.name, "migrations"), { recursive: true });
|
|
48
|
+
if (!(await hasDependency("dbmate")) ||
|
|
49
|
+
!(await fileExists(path.resolve("node_modules", ".bin", "dbmate")))) {
|
|
50
|
+
await installDependencies(["dbmate"], {
|
|
51
|
+
development: true,
|
|
52
|
+
logSink: this.getRuntimeLogSink(),
|
|
53
|
+
serviceName: this.migrationLogServiceName,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
async getEnvironmentVariables(stage, target = "container") {
|
|
58
|
+
const connection = await this.getConnectionInfo(stage, target);
|
|
59
|
+
const prefix = this.environmentVariablePrefix;
|
|
60
|
+
return {
|
|
61
|
+
[`${prefix}_POSTGRES_HOST`]: connection.host,
|
|
62
|
+
[`${prefix}_POSTGRES_PORT`]: connection.port,
|
|
63
|
+
[`${prefix}_POSTGRES_USERNAME`]: connection.username,
|
|
64
|
+
[`${prefix}_POSTGRES_PASSWORD`]: connection.password,
|
|
65
|
+
[`${prefix}_POSTGRES_DB_NAME`]: connection.database,
|
|
66
|
+
[`${prefix}_DATABASE_URL`]: connection.url,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
async dev() {
|
|
70
|
+
await super.dev();
|
|
71
|
+
await this.runMigrations("local", {
|
|
72
|
+
rootDir: process.cwd(),
|
|
73
|
+
dbmateArgs: ["--wait", "--no-dump-schema", "migrate"],
|
|
74
|
+
readOnly: true,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
async deploy(stage) {
|
|
78
|
+
await super.deploy(stage);
|
|
79
|
+
await this.runMigrations(stage, {
|
|
80
|
+
rootDir: process.cwd(),
|
|
81
|
+
dbmateArgs: ["--wait", "--no-dump-schema", "migrate"],
|
|
82
|
+
readOnly: true,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
async getConnectionInfo(stage, target = "host") {
|
|
86
|
+
const password = await this.resolvePassword(stage);
|
|
87
|
+
const host = target === "container" ? this.getContainerName(stage) : this.getHost(stage);
|
|
88
|
+
const port = target === "container" ? "5432" : String(this.getHostPort(stage));
|
|
89
|
+
const database = this.database ?? this.defaultDatabaseName(stage);
|
|
90
|
+
const connection = {
|
|
91
|
+
host,
|
|
92
|
+
port,
|
|
93
|
+
username: this.username,
|
|
94
|
+
password,
|
|
95
|
+
database,
|
|
96
|
+
};
|
|
97
|
+
return {
|
|
98
|
+
...connection,
|
|
99
|
+
url: this.toDatabaseUrl(connection),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
toDatabaseUrl(connection) {
|
|
103
|
+
return withSslModeDisabled(`postgresql://${encodeURIComponent(connection.username)}:${encodeURIComponent(connection.password)}@${connection.host}:${connection.port}/${connection.database}`);
|
|
104
|
+
}
|
|
105
|
+
async getContainerEnvironment(stage) {
|
|
106
|
+
const connection = await this.getConnectionInfo(stage, "container");
|
|
107
|
+
return {
|
|
108
|
+
...(await super.getContainerEnvironment(stage)),
|
|
109
|
+
POSTGRES_USER: connection.username,
|
|
110
|
+
POSTGRES_PASSWORD: connection.password,
|
|
111
|
+
POSTGRES_DB: connection.database,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
async getDockerRunConfig(stage, deploy) {
|
|
115
|
+
const config = await super.getDockerRunConfig(stage, deploy);
|
|
116
|
+
return {
|
|
117
|
+
...config,
|
|
118
|
+
volumes: [`${this.getVolumeName(stage)}:${POSTGRES_VOLUME_DIRECTORY}`],
|
|
119
|
+
ports: deploy && this.port == null ? [] : [`${this.getHostPort(stage)}:5432`],
|
|
120
|
+
command: this.walEnabled ? ["postgres", "-c", "wal_level=logical"] : config.command,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
async onContainerStarted(stage) {
|
|
124
|
+
await this.setOutputs(this.toOutputs(await this.getConnectionInfo(stage, "host")), stage);
|
|
125
|
+
}
|
|
126
|
+
async runMigrations(stage, options) {
|
|
127
|
+
const sourceDirectory = path.join(options.rootDir, this.name, "migrations");
|
|
128
|
+
let migrationFiles;
|
|
129
|
+
try {
|
|
130
|
+
const result = await stat(sourceDirectory);
|
|
131
|
+
if (!result.isDirectory()) {
|
|
132
|
+
throw new Error("No migrations");
|
|
133
|
+
}
|
|
134
|
+
migrationFiles = await listFiles(sourceDirectory);
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
// no migrations to run
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
if (migrationFiles.length === 0)
|
|
141
|
+
return;
|
|
142
|
+
this.writeMigrationLog(`${options.dryRun ? "Dry run" : "Run"} migrations for ${this.name} (${stage})\n`);
|
|
143
|
+
if (stage === "local") {
|
|
144
|
+
await this.runLocalMigrations(stage, {
|
|
145
|
+
rootDir: options.rootDir,
|
|
146
|
+
sourceDirectory,
|
|
147
|
+
dbmateArgs: options.dbmateArgs,
|
|
148
|
+
dryRun: options.dryRun,
|
|
149
|
+
});
|
|
150
|
+
this.writeMigrationLog(`Finished migrations for ${this.name} (${stage})\n`);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const relativeDirectory = `${this.name}/migrations`;
|
|
154
|
+
const remoteDirectory = path.posix.join(this.getAppDirectory(stage), relativeDirectory);
|
|
155
|
+
const runtimeFiles = [];
|
|
156
|
+
await this.host.exec([`rm -rf ${shellQuote(remoteDirectory)}`, `mkdir -p ${shellQuote(remoteDirectory)}`].join("\n"), { dryRun: options.dryRun });
|
|
157
|
+
try {
|
|
158
|
+
for (const file of migrationFiles) {
|
|
159
|
+
const relativeFile = path
|
|
160
|
+
.relative(sourceDirectory, file)
|
|
161
|
+
.split(path.sep)
|
|
162
|
+
.join(path.posix.sep);
|
|
163
|
+
runtimeFiles.push(await this.writeRemoteRuntimeFile(stage, path.posix.join(relativeDirectory, relativeFile), await readFile(file, "utf8"), options.dryRun));
|
|
164
|
+
}
|
|
165
|
+
await this.runMigrationContainer(stage, {
|
|
166
|
+
migrationVolume: `${remoteDirectory}:/db/migrations${options.readOnly ? ":ro" : ""}`,
|
|
167
|
+
dbmateArgs: options.dbmateArgs,
|
|
168
|
+
dryRun: options.dryRun,
|
|
169
|
+
});
|
|
170
|
+
this.writeMigrationLog(`Finished migrations for ${this.name} (${stage})\n`);
|
|
171
|
+
}
|
|
172
|
+
finally {
|
|
173
|
+
for (const runtimeFile of runtimeFiles.reverse()) {
|
|
174
|
+
await this.removeRemoteRuntimeFile(runtimeFile, options.dryRun);
|
|
175
|
+
}
|
|
176
|
+
await this.host.exec(`rm -rf ${shellQuote(remoteDirectory)}`, { dryRun: options.dryRun });
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
async runMigrationContainer(stage, options) {
|
|
180
|
+
const connection = await this.getConnectionInfo(stage, "container");
|
|
181
|
+
const config = {
|
|
182
|
+
name: `${this.getContainerName(stage)}-migrations`,
|
|
183
|
+
image: this.migrationImage,
|
|
184
|
+
network: this.getNetwork(stage),
|
|
185
|
+
pull: true,
|
|
186
|
+
env: {
|
|
187
|
+
DATABASE_URL: connection.url,
|
|
188
|
+
DBMATE_MIGRATIONS_DIR: "/db/migrations",
|
|
189
|
+
},
|
|
190
|
+
volumes: [options.migrationVolume],
|
|
191
|
+
command: options.dbmateArgs,
|
|
192
|
+
healthCheck: false,
|
|
193
|
+
labels: {
|
|
194
|
+
"saws.service": this.name,
|
|
195
|
+
"saws.serviceType": this.serviceType,
|
|
196
|
+
"saws.stage": stage,
|
|
197
|
+
"saws.task": "postgres-migrations",
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
await this.runEphemeralContainer(stage, config, {
|
|
201
|
+
dryRun: options.dryRun,
|
|
202
|
+
logServiceName: this.migrationLogServiceName,
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
async runLocalMigrations(stage, options) {
|
|
206
|
+
const connection = await this.getConnectionInfo(stage, "host");
|
|
207
|
+
const command = [
|
|
208
|
+
`DATABASE_URL=${shellQuote(connection.url)}`,
|
|
209
|
+
`DBMATE_MIGRATIONS_DIR=${shellQuote(options.sourceDirectory)}`,
|
|
210
|
+
shellQuote(path.resolve(options.rootDir, "node_modules", ".bin", "dbmate")),
|
|
211
|
+
...options.dbmateArgs.map(shellQuote),
|
|
212
|
+
].join(" ");
|
|
213
|
+
await runLocal(command, {
|
|
214
|
+
dryRun: options.dryRun,
|
|
215
|
+
logSink: this.getRuntimeLogSink(),
|
|
216
|
+
serviceName: this.migrationLogServiceName,
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
writeMigrationLog(chunk, stream = "stdout") {
|
|
220
|
+
const sink = this.getRuntimeLogSink();
|
|
221
|
+
if (sink == null) {
|
|
222
|
+
this.writeRuntimeLog(chunk, stream);
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
sink({
|
|
226
|
+
serviceName: this.migrationLogServiceName,
|
|
227
|
+
stream,
|
|
228
|
+
chunk,
|
|
229
|
+
timestamp: new Date(),
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
get migrationLogServiceName() {
|
|
233
|
+
return `${this.name}--migrations`;
|
|
234
|
+
}
|
|
235
|
+
get environmentVariablePrefix() {
|
|
236
|
+
return this.name.replace(/[^a-zA-Z\d]/g, "_").toUpperCase();
|
|
237
|
+
}
|
|
238
|
+
getHost(stage) {
|
|
239
|
+
return stage === "local" ? "localhost" : this.getContainerName(stage);
|
|
240
|
+
}
|
|
241
|
+
getHostPort(_stage) {
|
|
242
|
+
return this.port ?? 5432;
|
|
243
|
+
}
|
|
244
|
+
getVolumeName(stage) {
|
|
245
|
+
return this.volume ?? `${stage}-${this.name}-postgres-data`.replaceAll("_", "-").toLowerCase();
|
|
246
|
+
}
|
|
247
|
+
defaultDatabaseName(stage) {
|
|
248
|
+
return `${stage}_${this.name}`.replaceAll("-", "_").toLowerCase();
|
|
249
|
+
}
|
|
250
|
+
toOutputs(connection) {
|
|
251
|
+
return {
|
|
252
|
+
postgresHost: connection.host,
|
|
253
|
+
postgresPort: connection.port,
|
|
254
|
+
postgresUsername: connection.username,
|
|
255
|
+
postgresPassword: connection.password,
|
|
256
|
+
postgresDBName: connection.database,
|
|
257
|
+
databaseUrl: connection.url,
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
async getOrCreateManagedPassword(stage) {
|
|
261
|
+
const manager = new SecretsManager({ stage });
|
|
262
|
+
const secretName = `${this.name}-postgres-password`;
|
|
263
|
+
try {
|
|
264
|
+
return await manager.get(secretName);
|
|
265
|
+
}
|
|
266
|
+
catch (error) {
|
|
267
|
+
if (error.name !== "ParameterNotFound")
|
|
268
|
+
throw error;
|
|
269
|
+
}
|
|
270
|
+
const password = randomBytes(24).toString("base64url");
|
|
271
|
+
await manager.set(secretName, password);
|
|
272
|
+
return password;
|
|
273
|
+
}
|
|
274
|
+
async resolvePassword(stage) {
|
|
275
|
+
return this.password == null
|
|
276
|
+
? this.getOrCreateManagedPassword(stage)
|
|
277
|
+
: this.password.resolve({ stage });
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
function isPostgresService(service) {
|
|
281
|
+
return service instanceof PostgresService;
|
|
282
|
+
}
|
|
283
|
+
function withSslModeDisabled(databaseUrl) {
|
|
284
|
+
const url = new URL(databaseUrl);
|
|
285
|
+
if (!url.searchParams.has("sslmode")) {
|
|
286
|
+
url.searchParams.set("sslmode", "disable");
|
|
287
|
+
}
|
|
288
|
+
return url.toString();
|
|
289
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./PostgresService.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import type { PostgresService } from "./PostgresService.js";
|
|
3
|
+
export interface MigrateCommandOptions {
|
|
4
|
+
rootDir?: string;
|
|
5
|
+
service?: string;
|
|
6
|
+
stage?: string;
|
|
7
|
+
dryRun?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare const createMigrateCommand: (services: PostgresService[]) => Command;
|
|
10
|
+
export declare function migrateCommand(services: PostgresService[], dbmateArgs: string[], options: MigrateCommandOptions): Promise<void>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
export const createMigrateCommand = (services) => new Command("migrate")
|
|
4
|
+
.description("run dbmate commands in an ephemeral Docker container")
|
|
5
|
+
.argument("[dbmateArgs...]", "arguments passed to dbmate")
|
|
6
|
+
.option("--root-dir <path>", "project root containing the service migrations directory")
|
|
7
|
+
.option("--service <name>", "Postgres service whose migrations and database URL to use")
|
|
8
|
+
.option("--stage <stage>", "SAWS stage to migrate", "local")
|
|
9
|
+
.option("--dry-run", "print the dbmate command without running it")
|
|
10
|
+
.helpOption(false)
|
|
11
|
+
.allowUnknownOption()
|
|
12
|
+
.action((dbmateArgs, options) => migrateCommand(services, dbmateArgs, options));
|
|
13
|
+
export async function migrateCommand(services, dbmateArgs, options) {
|
|
14
|
+
const service = resolveService(options.service, services);
|
|
15
|
+
const stage = options.stage ?? "local";
|
|
16
|
+
const rootDir = path.resolve(options.rootDir ?? process.cwd());
|
|
17
|
+
const args = dbmateArgs.length === 0 ? ["--wait", "--no-dump-schema", "migrate"] : dbmateArgs;
|
|
18
|
+
await service.runMigrations(stage, {
|
|
19
|
+
rootDir,
|
|
20
|
+
dbmateArgs: args,
|
|
21
|
+
dryRun: options.dryRun,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function resolveService(requestedService, services) {
|
|
25
|
+
if (requestedService != null) {
|
|
26
|
+
const service = services.find((candidate) => candidate.name === requestedService);
|
|
27
|
+
if (service != null)
|
|
28
|
+
return service;
|
|
29
|
+
throw new Error(`Postgres service "${requestedService}" was not found. Available services: ${services
|
|
30
|
+
.map((candidate) => candidate.name)
|
|
31
|
+
.join(", ")}`);
|
|
32
|
+
}
|
|
33
|
+
if (services.length === 1)
|
|
34
|
+
return services[0];
|
|
35
|
+
if (services.length === 0) {
|
|
36
|
+
throw new Error("No Postgres services are configured.");
|
|
37
|
+
}
|
|
38
|
+
throw new Error(`Multiple Postgres services are configured. Select one with --service: ${services
|
|
39
|
+
.map((service) => service.name)
|
|
40
|
+
.join(", ")}`);
|
|
41
|
+
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saws/postgres-service",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/shichongrui/saws.git"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"./dist"
|
|
13
|
+
],
|
|
7
14
|
"type": "module",
|
|
8
15
|
"types": "./dist/index.d.ts",
|
|
9
16
|
"exports": {
|
|
@@ -13,8 +20,8 @@
|
|
|
13
20
|
}
|
|
14
21
|
},
|
|
15
22
|
"dependencies": {
|
|
16
|
-
"@saws/core": "2.0.0-beta.
|
|
17
|
-
"@saws/docker-service": "2.0.0-beta.
|
|
23
|
+
"@saws/core": "2.0.0-beta.6",
|
|
24
|
+
"@saws/docker-service": "2.0.0-beta.6",
|
|
18
25
|
"commander": "^15.0.0"
|
|
19
26
|
}
|
|
20
27
|
}
|
package/src/PostgresService.ts
DELETED
|
@@ -1,411 +0,0 @@
|
|
|
1
|
-
import { randomBytes } from "node:crypto";
|
|
2
|
-
import { mkdir, readFile, stat } from "node:fs/promises";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import {
|
|
5
|
-
SecretsManager,
|
|
6
|
-
ServiceDefinition,
|
|
7
|
-
type SecretReference,
|
|
8
|
-
type ServiceEnvironmentTarget,
|
|
9
|
-
} from "@saws/core";
|
|
10
|
-
import { hasDependency, installDependencies } from "@saws/core/utils/dependency-management";
|
|
11
|
-
import { fileExists } from "@saws/core/utils/file-exists";
|
|
12
|
-
import { listFiles } from "@saws/core/utils/list-files";
|
|
13
|
-
import { runLocal } from "@saws/core/utils/run-local";
|
|
14
|
-
import { shellQuote } from "@saws/core/utils/shell-quote";
|
|
15
|
-
import type { Outputs } from "@saws/core/utils/stage-outputs";
|
|
16
|
-
import {
|
|
17
|
-
DockerService,
|
|
18
|
-
type DockerRunConfig,
|
|
19
|
-
type DockerServiceConfig,
|
|
20
|
-
type RuntimeFile,
|
|
21
|
-
} from "@saws/docker-service";
|
|
22
|
-
import { createMigrateCommand } from "./migrate-command.js";
|
|
23
|
-
|
|
24
|
-
const POSTGRES_VOLUME_DIRECTORY = "/var/lib/postgresql";
|
|
25
|
-
|
|
26
|
-
export type PostgresConnectionTarget = "container" | "host";
|
|
27
|
-
|
|
28
|
-
export type PostgresConnectionInfo = {
|
|
29
|
-
host: string;
|
|
30
|
-
port: string;
|
|
31
|
-
username: string;
|
|
32
|
-
password: string;
|
|
33
|
-
database: string;
|
|
34
|
-
url: string;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export interface PostgresServiceConfig extends Omit<
|
|
38
|
-
DockerServiceConfig,
|
|
39
|
-
"image" | "dockerfile" | "buildContext" | "volumes" | "ports" | "command"
|
|
40
|
-
> {
|
|
41
|
-
image?: string;
|
|
42
|
-
/** Host port to expose Postgres on. Local dev defaults to 5432; deploys stay private unless set. */
|
|
43
|
-
port?: number;
|
|
44
|
-
/** Database created by the Postgres image and used in generated connection URLs. */
|
|
45
|
-
database?: string;
|
|
46
|
-
/** Postgres superuser created by the Postgres image. Defaults to "postgres". */
|
|
47
|
-
username?: string;
|
|
48
|
-
/** Postgres password secret reference. Omit to store a generated password in SAWS secrets. */
|
|
49
|
-
password?: SecretReference;
|
|
50
|
-
/** Override the Docker volume name. By default SAWS derives a stable stage/service volume. */
|
|
51
|
-
volume?: string;
|
|
52
|
-
/** Enable logical WAL for replication/change data capture use cases. */
|
|
53
|
-
wal_enabled?: boolean;
|
|
54
|
-
/** dbmate image used to apply migrations in an ephemeral sibling container. */
|
|
55
|
-
migrationImage?: string;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export class PostgresService extends DockerService {
|
|
59
|
-
static getCommands(services: ServiceDefinition[] = []) {
|
|
60
|
-
return [createMigrateCommand(services.filter(isPostgresService))];
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
readonly port?: number;
|
|
64
|
-
readonly database?: string;
|
|
65
|
-
readonly username: string;
|
|
66
|
-
readonly password?: SecretReference;
|
|
67
|
-
readonly volume?: string;
|
|
68
|
-
readonly walEnabled: boolean;
|
|
69
|
-
readonly migrationImage: string;
|
|
70
|
-
protected override readonly serviceType = "postgres";
|
|
71
|
-
|
|
72
|
-
constructor(config: PostgresServiceConfig) {
|
|
73
|
-
super({
|
|
74
|
-
...config,
|
|
75
|
-
image: config.image ?? "postgres:18",
|
|
76
|
-
healthCheck: config.healthCheck ?? {
|
|
77
|
-
command: 'pg_isready -U "$POSTGRES_USER" -d "$POSTGRES_DB"',
|
|
78
|
-
interval: "10s",
|
|
79
|
-
timeout: "5s",
|
|
80
|
-
retries: 5,
|
|
81
|
-
startPeriod: "10s",
|
|
82
|
-
},
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
this.port = config.port;
|
|
86
|
-
this.database = config.database;
|
|
87
|
-
this.username = config.username ?? "postgres";
|
|
88
|
-
this.password = config.password;
|
|
89
|
-
this.volume = config.volume;
|
|
90
|
-
this.walEnabled = config.wal_enabled ?? false;
|
|
91
|
-
this.migrationImage = config.migrationImage ?? "ghcr.io/amacneil/dbmate:2.33.0";
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
override async init() {
|
|
95
|
-
await super.init();
|
|
96
|
-
await mkdir(path.resolve(this.name, "migrations"), { recursive: true });
|
|
97
|
-
if (
|
|
98
|
-
!(await hasDependency("dbmate")) ||
|
|
99
|
-
!(await fileExists(path.resolve("node_modules", ".bin", "dbmate")))
|
|
100
|
-
) {
|
|
101
|
-
await installDependencies(["dbmate"], {
|
|
102
|
-
development: true,
|
|
103
|
-
logSink: this.getRuntimeLogSink(),
|
|
104
|
-
serviceName: this.migrationLogServiceName,
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
override async getEnvironmentVariables(
|
|
110
|
-
stage: string,
|
|
111
|
-
target: ServiceEnvironmentTarget = "container",
|
|
112
|
-
): Promise<Record<string, string>> {
|
|
113
|
-
const connection = await this.getConnectionInfo(stage, target);
|
|
114
|
-
const prefix = this.environmentVariablePrefix;
|
|
115
|
-
|
|
116
|
-
return {
|
|
117
|
-
[`${prefix}_POSTGRES_HOST`]: connection.host,
|
|
118
|
-
[`${prefix}_POSTGRES_PORT`]: connection.port,
|
|
119
|
-
[`${prefix}_POSTGRES_USERNAME`]: connection.username,
|
|
120
|
-
[`${prefix}_POSTGRES_PASSWORD`]: connection.password,
|
|
121
|
-
[`${prefix}_POSTGRES_DB_NAME`]: connection.database,
|
|
122
|
-
[`${prefix}_DATABASE_URL`]: connection.url,
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
override async dev() {
|
|
127
|
-
await super.dev();
|
|
128
|
-
await this.runMigrations("local", {
|
|
129
|
-
rootDir: process.cwd(),
|
|
130
|
-
dbmateArgs: ["--wait", "--no-dump-schema", "migrate"],
|
|
131
|
-
readOnly: true,
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
override async deploy(stage: string) {
|
|
136
|
-
await super.deploy(stage);
|
|
137
|
-
await this.runMigrations(stage, {
|
|
138
|
-
rootDir: process.cwd(),
|
|
139
|
-
dbmateArgs: ["--wait", "--no-dump-schema", "migrate"],
|
|
140
|
-
readOnly: true,
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
async getConnectionInfo(
|
|
145
|
-
stage: string,
|
|
146
|
-
target: PostgresConnectionTarget = "host",
|
|
147
|
-
): Promise<PostgresConnectionInfo> {
|
|
148
|
-
const password = await this.resolvePassword(stage);
|
|
149
|
-
const host = target === "container" ? this.getContainerName(stage) : this.getHost(stage);
|
|
150
|
-
const port = target === "container" ? "5432" : String(this.getHostPort(stage));
|
|
151
|
-
const database = this.database ?? this.defaultDatabaseName(stage);
|
|
152
|
-
const connection = {
|
|
153
|
-
host,
|
|
154
|
-
port,
|
|
155
|
-
username: this.username,
|
|
156
|
-
password,
|
|
157
|
-
database,
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
return {
|
|
161
|
-
...connection,
|
|
162
|
-
url: this.toDatabaseUrl(connection),
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
toDatabaseUrl(connection: Omit<PostgresConnectionInfo, "url">) {
|
|
167
|
-
return withSslModeDisabled(
|
|
168
|
-
`postgresql://${encodeURIComponent(connection.username)}:${encodeURIComponent(
|
|
169
|
-
connection.password,
|
|
170
|
-
)}@${connection.host}:${connection.port}/${connection.database}`,
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
protected override async getContainerEnvironment(stage: string): Promise<Record<string, string>> {
|
|
175
|
-
const connection = await this.getConnectionInfo(stage, "container");
|
|
176
|
-
|
|
177
|
-
return {
|
|
178
|
-
...(await super.getContainerEnvironment(stage)),
|
|
179
|
-
POSTGRES_USER: connection.username,
|
|
180
|
-
POSTGRES_PASSWORD: connection.password,
|
|
181
|
-
POSTGRES_DB: connection.database,
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
protected override async getDockerRunConfig(stage: string, deploy: boolean) {
|
|
186
|
-
const config = await super.getDockerRunConfig(stage, deploy);
|
|
187
|
-
|
|
188
|
-
return {
|
|
189
|
-
...config,
|
|
190
|
-
volumes: [`${this.getVolumeName(stage)}:${POSTGRES_VOLUME_DIRECTORY}`],
|
|
191
|
-
ports: deploy && this.port == null ? [] : [`${this.getHostPort(stage)}:5432`],
|
|
192
|
-
command: this.walEnabled ? ["postgres", "-c", "wal_level=logical"] : config.command,
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
protected override async onContainerStarted(stage: string) {
|
|
197
|
-
await this.setOutputs(this.toOutputs(await this.getConnectionInfo(stage, "host")), stage);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
async runMigrations(
|
|
201
|
-
stage: string,
|
|
202
|
-
options: {
|
|
203
|
-
rootDir: string;
|
|
204
|
-
dbmateArgs: string[];
|
|
205
|
-
readOnly?: boolean;
|
|
206
|
-
dryRun?: boolean;
|
|
207
|
-
},
|
|
208
|
-
) {
|
|
209
|
-
const sourceDirectory = path.join(options.rootDir, this.name, "migrations");
|
|
210
|
-
let migrationFiles: string[];
|
|
211
|
-
try {
|
|
212
|
-
const result = await stat(sourceDirectory);
|
|
213
|
-
if (!result.isDirectory()) {
|
|
214
|
-
throw new Error("No migrations");
|
|
215
|
-
}
|
|
216
|
-
migrationFiles = await listFiles(sourceDirectory);
|
|
217
|
-
} catch {
|
|
218
|
-
// no migrations to run
|
|
219
|
-
return;
|
|
220
|
-
}
|
|
221
|
-
if (migrationFiles.length === 0) return;
|
|
222
|
-
|
|
223
|
-
this.writeMigrationLog(
|
|
224
|
-
`${options.dryRun ? "Dry run" : "Run"} migrations for ${this.name} (${stage})\n`,
|
|
225
|
-
);
|
|
226
|
-
|
|
227
|
-
if (stage === "local") {
|
|
228
|
-
await this.runLocalMigrations(stage, {
|
|
229
|
-
rootDir: options.rootDir,
|
|
230
|
-
sourceDirectory,
|
|
231
|
-
dbmateArgs: options.dbmateArgs,
|
|
232
|
-
dryRun: options.dryRun,
|
|
233
|
-
});
|
|
234
|
-
this.writeMigrationLog(`Finished migrations for ${this.name} (${stage})\n`);
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
const relativeDirectory = `${this.name}/migrations`;
|
|
239
|
-
const remoteDirectory = path.posix.join(this.getAppDirectory(stage), relativeDirectory);
|
|
240
|
-
const runtimeFiles: RuntimeFile[] = [];
|
|
241
|
-
|
|
242
|
-
await this.host.exec(
|
|
243
|
-
[`rm -rf ${shellQuote(remoteDirectory)}`, `mkdir -p ${shellQuote(remoteDirectory)}`].join(
|
|
244
|
-
"\n",
|
|
245
|
-
),
|
|
246
|
-
{ dryRun: options.dryRun },
|
|
247
|
-
);
|
|
248
|
-
|
|
249
|
-
try {
|
|
250
|
-
for (const file of migrationFiles) {
|
|
251
|
-
const relativeFile = path
|
|
252
|
-
.relative(sourceDirectory, file)
|
|
253
|
-
.split(path.sep)
|
|
254
|
-
.join(path.posix.sep);
|
|
255
|
-
runtimeFiles.push(
|
|
256
|
-
await this.writeRemoteRuntimeFile(
|
|
257
|
-
stage,
|
|
258
|
-
path.posix.join(relativeDirectory, relativeFile),
|
|
259
|
-
await readFile(file, "utf8"),
|
|
260
|
-
options.dryRun,
|
|
261
|
-
),
|
|
262
|
-
);
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
await this.runMigrationContainer(stage, {
|
|
266
|
-
migrationVolume: `${remoteDirectory}:/db/migrations${options.readOnly ? ":ro" : ""}`,
|
|
267
|
-
dbmateArgs: options.dbmateArgs,
|
|
268
|
-
dryRun: options.dryRun,
|
|
269
|
-
});
|
|
270
|
-
this.writeMigrationLog(`Finished migrations for ${this.name} (${stage})\n`);
|
|
271
|
-
} finally {
|
|
272
|
-
for (const runtimeFile of runtimeFiles.reverse()) {
|
|
273
|
-
await this.removeRemoteRuntimeFile(runtimeFile, options.dryRun);
|
|
274
|
-
}
|
|
275
|
-
await this.host.exec(`rm -rf ${shellQuote(remoteDirectory)}`, { dryRun: options.dryRun });
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
private async runMigrationContainer(
|
|
280
|
-
stage: string,
|
|
281
|
-
options: { migrationVolume: string; dbmateArgs: string[]; dryRun?: boolean },
|
|
282
|
-
) {
|
|
283
|
-
const connection = await this.getConnectionInfo(stage, "container");
|
|
284
|
-
const config: DockerRunConfig = {
|
|
285
|
-
name: `${this.getContainerName(stage)}-migrations`,
|
|
286
|
-
image: this.migrationImage,
|
|
287
|
-
network: this.getNetwork(stage),
|
|
288
|
-
pull: true,
|
|
289
|
-
env: {
|
|
290
|
-
DATABASE_URL: connection.url,
|
|
291
|
-
DBMATE_MIGRATIONS_DIR: "/db/migrations",
|
|
292
|
-
},
|
|
293
|
-
volumes: [options.migrationVolume],
|
|
294
|
-
command: options.dbmateArgs,
|
|
295
|
-
healthCheck: false,
|
|
296
|
-
labels: {
|
|
297
|
-
"saws.service": this.name,
|
|
298
|
-
"saws.serviceType": this.serviceType,
|
|
299
|
-
"saws.stage": stage,
|
|
300
|
-
"saws.task": "postgres-migrations",
|
|
301
|
-
},
|
|
302
|
-
};
|
|
303
|
-
|
|
304
|
-
await this.runEphemeralContainer(stage, config, {
|
|
305
|
-
dryRun: options.dryRun,
|
|
306
|
-
logServiceName: this.migrationLogServiceName,
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
private async runLocalMigrations(
|
|
311
|
-
stage: string,
|
|
312
|
-
options: { rootDir: string; sourceDirectory: string; dbmateArgs: string[]; dryRun?: boolean },
|
|
313
|
-
) {
|
|
314
|
-
const connection = await this.getConnectionInfo(stage, "host");
|
|
315
|
-
const command = [
|
|
316
|
-
`DATABASE_URL=${shellQuote(connection.url)}`,
|
|
317
|
-
`DBMATE_MIGRATIONS_DIR=${shellQuote(options.sourceDirectory)}`,
|
|
318
|
-
shellQuote(path.resolve(options.rootDir, "node_modules", ".bin", "dbmate")),
|
|
319
|
-
...options.dbmateArgs.map(shellQuote),
|
|
320
|
-
].join(" ");
|
|
321
|
-
|
|
322
|
-
await runLocal(command, {
|
|
323
|
-
dryRun: options.dryRun,
|
|
324
|
-
logSink: this.getRuntimeLogSink(),
|
|
325
|
-
serviceName: this.migrationLogServiceName,
|
|
326
|
-
});
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
private writeMigrationLog(chunk: string, stream: "stdout" | "stderr" = "stdout") {
|
|
330
|
-
const sink = this.getRuntimeLogSink();
|
|
331
|
-
if (sink == null) {
|
|
332
|
-
this.writeRuntimeLog(chunk, stream);
|
|
333
|
-
return;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
sink({
|
|
337
|
-
serviceName: this.migrationLogServiceName,
|
|
338
|
-
stream,
|
|
339
|
-
chunk,
|
|
340
|
-
timestamp: new Date(),
|
|
341
|
-
});
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
private get migrationLogServiceName() {
|
|
345
|
-
return `${this.name}--migrations`;
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
private get environmentVariablePrefix() {
|
|
349
|
-
return this.name.replace(/[^a-zA-Z\d]/g, "_").toUpperCase();
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
private getHost(stage: string) {
|
|
353
|
-
return stage === "local" ? "localhost" : this.getContainerName(stage);
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
private getHostPort(_stage: string) {
|
|
357
|
-
return this.port ?? 5432;
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
private getVolumeName(stage: string) {
|
|
361
|
-
return this.volume ?? `${stage}-${this.name}-postgres-data`.replaceAll("_", "-").toLowerCase();
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
private defaultDatabaseName(stage: string) {
|
|
365
|
-
return `${stage}_${this.name}`.replaceAll("-", "_").toLowerCase();
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
private toOutputs(connection: PostgresConnectionInfo): Outputs {
|
|
369
|
-
return {
|
|
370
|
-
postgresHost: connection.host,
|
|
371
|
-
postgresPort: connection.port,
|
|
372
|
-
postgresUsername: connection.username,
|
|
373
|
-
postgresPassword: connection.password,
|
|
374
|
-
postgresDBName: connection.database,
|
|
375
|
-
databaseUrl: connection.url,
|
|
376
|
-
};
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
private async getOrCreateManagedPassword(stage: string) {
|
|
380
|
-
const manager = new SecretsManager({ stage });
|
|
381
|
-
const secretName = `${this.name}-postgres-password`;
|
|
382
|
-
|
|
383
|
-
try {
|
|
384
|
-
return await manager.get(secretName);
|
|
385
|
-
} catch (error) {
|
|
386
|
-
if ((error as Error).name !== "ParameterNotFound") throw error;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
const password = randomBytes(24).toString("base64url");
|
|
390
|
-
await manager.set(secretName, password);
|
|
391
|
-
return password;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
private async resolvePassword(stage: string) {
|
|
395
|
-
return this.password == null
|
|
396
|
-
? this.getOrCreateManagedPassword(stage)
|
|
397
|
-
: this.password.resolve({ stage });
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
function isPostgresService(service: ServiceDefinition): service is PostgresService {
|
|
402
|
-
return service instanceof PostgresService;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
function withSslModeDisabled(databaseUrl: string) {
|
|
406
|
-
const url = new URL(databaseUrl);
|
|
407
|
-
if (!url.searchParams.has("sslmode")) {
|
|
408
|
-
url.searchParams.set("sslmode", "disable");
|
|
409
|
-
}
|
|
410
|
-
return url.toString();
|
|
411
|
-
}
|
package/src/migrate-command.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { Command } from "commander";
|
|
3
|
-
import type { PostgresService } from "./PostgresService.js";
|
|
4
|
-
|
|
5
|
-
export interface MigrateCommandOptions {
|
|
6
|
-
rootDir?: string;
|
|
7
|
-
service?: string;
|
|
8
|
-
stage?: string;
|
|
9
|
-
dryRun?: boolean;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const createMigrateCommand = (services: PostgresService[]) =>
|
|
13
|
-
new Command("migrate")
|
|
14
|
-
.description("run dbmate commands in an ephemeral Docker container")
|
|
15
|
-
.argument("[dbmateArgs...]", "arguments passed to dbmate")
|
|
16
|
-
.option("--root-dir <path>", "project root containing the service migrations directory")
|
|
17
|
-
.option("--service <name>", "Postgres service whose migrations and database URL to use")
|
|
18
|
-
.option("--stage <stage>", "SAWS stage to migrate", "local")
|
|
19
|
-
.option("--dry-run", "print the dbmate command without running it")
|
|
20
|
-
.helpOption(false)
|
|
21
|
-
.allowUnknownOption()
|
|
22
|
-
.action((dbmateArgs: string[], options: MigrateCommandOptions) =>
|
|
23
|
-
migrateCommand(services, dbmateArgs, options),
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
export async function migrateCommand(
|
|
27
|
-
services: PostgresService[],
|
|
28
|
-
dbmateArgs: string[],
|
|
29
|
-
options: MigrateCommandOptions,
|
|
30
|
-
) {
|
|
31
|
-
const service = resolveService(options.service, services);
|
|
32
|
-
const stage = options.stage ?? "local";
|
|
33
|
-
const rootDir = path.resolve(options.rootDir ?? process.cwd());
|
|
34
|
-
const args = dbmateArgs.length === 0 ? ["--wait", "--no-dump-schema", "migrate"] : dbmateArgs;
|
|
35
|
-
|
|
36
|
-
await service.runMigrations(stage, {
|
|
37
|
-
rootDir,
|
|
38
|
-
dbmateArgs: args,
|
|
39
|
-
dryRun: options.dryRun,
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function resolveService(requestedService: string | undefined, services: PostgresService[]) {
|
|
44
|
-
if (requestedService != null) {
|
|
45
|
-
const service = services.find((candidate) => candidate.name === requestedService);
|
|
46
|
-
if (service != null) return service;
|
|
47
|
-
throw new Error(
|
|
48
|
-
`Postgres service "${requestedService}" was not found. Available services: ${services
|
|
49
|
-
.map((candidate) => candidate.name)
|
|
50
|
-
.join(", ")}`,
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (services.length === 1) return services[0]!;
|
|
55
|
-
if (services.length === 0) {
|
|
56
|
-
throw new Error("No Postgres services are configured.");
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
throw new Error(
|
|
60
|
-
`Multiple Postgres services are configured. Select one with --service: ${services
|
|
61
|
-
.map((service) => service.name)
|
|
62
|
-
.join(", ")}`,
|
|
63
|
-
);
|
|
64
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig-node.base.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "./dist",
|
|
5
|
-
"rootDir": "./src",
|
|
6
|
-
"tsBuildInfoFile": "./dist/.tsbuildinfo"
|
|
7
|
-
},
|
|
8
|
-
"references": [{ "path": "../core/tsconfig.json" }, { "path": "../docker-service/tsconfig.json" }]
|
|
9
|
-
}
|
|
File without changes
|