turbine-orm 0.93.1 → 0.94.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -23
- package/dist/adapters/cockroachdb.d.ts +3 -3
- package/dist/adapters/cockroachdb.js +7 -11
- package/dist/adapters/index.d.ts +1 -1
- package/dist/adapters/yugabytedb.js +1 -1
- package/dist/better-sqlite3.d.ts +132 -0
- package/dist/better-sqlite3.js +303 -0
- package/dist/catalog-metadata.d.ts +250 -0
- package/dist/catalog-metadata.js +730 -0
- package/dist/cjs/adapters/cockroachdb.d.ts +3 -3
- package/dist/cjs/adapters/cockroachdb.js +7 -11
- package/dist/cjs/adapters/index.d.ts +1 -1
- package/dist/cjs/adapters/yugabytedb.js +1 -1
- package/dist/cjs/better-sqlite3.d.ts +132 -0
- package/dist/cjs/better-sqlite3.js +311 -0
- package/dist/cjs/catalog-metadata.d.ts +250 -0
- package/dist/cjs/catalog-metadata.js +747 -0
- package/dist/cjs/cli/compile-query.d.ts +6 -3
- package/dist/cjs/cli/compile-query.js +24 -3
- package/dist/cjs/cli/config.d.ts +35 -10
- package/dist/cjs/cli/config.js +173 -42
- package/dist/cjs/cli/d1-config.d.ts +14 -0
- package/dist/cjs/cli/d1-config.js +9 -0
- package/dist/cjs/cli/d1-local.d.ts +31 -0
- package/dist/cjs/cli/d1-local.js +298 -0
- package/dist/cjs/cli/d1-migrations.d.ts +16 -0
- package/dist/cjs/cli/d1-migrations.js +156 -0
- package/dist/cjs/cli/d1-project.d.ts +23 -0
- package/dist/cjs/cli/d1-project.js +314 -0
- package/dist/cjs/cli/d1-seed.d.ts +35 -0
- package/dist/cjs/cli/d1-seed.js +220 -0
- package/dist/cjs/cli/destructive.js +1 -2
- package/dist/cjs/cli/error-catalog.d.ts +3 -3
- package/dist/cjs/cli/error-catalog.js +21 -3
- package/dist/cjs/cli/index.d.ts +13 -8
- package/dist/cjs/cli/index.js +503 -71
- package/dist/cjs/cli/libsql-migrate-command.d.ts +5 -0
- package/dist/cjs/cli/libsql-migrate-command.js +82 -0
- package/dist/cjs/cli/libsql-migrate-status.d.ts +33 -0
- package/dist/cjs/cli/libsql-migrate-status.js +189 -0
- package/dist/cjs/cli/libsql-migrate.d.ts +14 -0
- package/dist/cjs/cli/libsql-migrate.js +522 -0
- package/dist/cjs/cli/libsql-project-config.d.ts +11 -0
- package/dist/cjs/cli/libsql-project-config.js +59 -0
- package/dist/cjs/cli/libsql-project.d.ts +52 -0
- package/dist/cjs/cli/libsql-project.js +409 -0
- package/dist/cjs/cli/libsql-seed-command.d.ts +29 -0
- package/dist/cjs/cli/libsql-seed-command.js +93 -0
- package/dist/cjs/cli/loader.d.ts +6 -5
- package/dist/cjs/cli/loader.js +53 -9
- package/dist/cjs/cli/mcp.d.ts +16 -1
- package/dist/cjs/cli/mcp.js +219 -125
- package/dist/cjs/cli/migrate.d.ts +2 -2
- package/dist/cjs/cli/migrate.js +29 -14
- package/dist/cjs/cli/mssql-doctor.d.ts +44 -0
- package/dist/cjs/cli/mssql-doctor.js +277 -0
- package/dist/cjs/cli/mssql-migrate-command.d.ts +9 -0
- package/dist/cjs/cli/mssql-migrate-command.js +230 -0
- package/dist/cjs/cli/mssql-migrate-connection.d.ts +51 -0
- package/dist/cjs/cli/mssql-migrate-connection.js +255 -0
- package/dist/cjs/cli/mssql-migrate-sql.d.ts +12 -0
- package/dist/cjs/cli/mssql-migrate-sql.js +282 -0
- package/dist/cjs/cli/mssql-migrate.d.ts +45 -0
- package/dist/cjs/cli/mssql-migrate.js +296 -0
- package/dist/cjs/cli/mssql-project.d.ts +34 -0
- package/dist/cjs/cli/mssql-project.js +171 -0
- package/dist/cjs/cli/mssql-seed.d.ts +7 -0
- package/dist/cjs/cli/mssql-seed.js +78 -0
- package/dist/cjs/cli/mssql-tools.d.ts +37 -0
- package/dist/cjs/cli/mssql-tools.js +354 -0
- package/dist/cjs/cli/mysql-doctor.d.ts +48 -0
- package/dist/cjs/cli/mysql-doctor.js +323 -0
- package/dist/cjs/cli/mysql-migrate-command.d.ts +7 -0
- package/dist/cjs/cli/mysql-migrate-command.js +290 -0
- package/dist/cjs/cli/mysql-migrate-sql.d.ts +18 -0
- package/dist/cjs/cli/mysql-migrate-sql.js +166 -0
- package/dist/cjs/cli/mysql-migrate.d.ts +77 -0
- package/dist/cjs/cli/mysql-migrate.js +619 -0
- package/dist/cjs/cli/mysql-project.d.ts +49 -0
- package/dist/cjs/cli/mysql-project.js +284 -0
- package/dist/cjs/cli/mysql-push-command.d.ts +7 -0
- package/dist/cjs/cli/mysql-push-command.js +94 -0
- package/dist/cjs/cli/mysql-push.d.ts +15 -0
- package/dist/cjs/cli/mysql-push.js +98 -0
- package/dist/cjs/cli/mysql-schema-command.d.ts +5 -0
- package/dist/cjs/cli/mysql-schema-command.js +58 -0
- package/dist/cjs/cli/mysql-schema-ddl.d.ts +37 -0
- package/dist/cjs/cli/mysql-schema-ddl.js +234 -0
- package/dist/cjs/cli/mysql-schema-snapshot.d.ts +21 -0
- package/dist/cjs/cli/mysql-schema-snapshot.js +127 -0
- package/dist/cjs/cli/mysql-schema.d.ts +27 -0
- package/dist/cjs/cli/mysql-schema.js +206 -0
- package/dist/cjs/cli/mysql-seed-loader.cjs +58 -0
- package/dist/cjs/cli/mysql-seed-loader.d.cts +3 -0
- package/dist/cjs/cli/mysql-seed.d.ts +6 -0
- package/dist/cjs/cli/mysql-seed.js +83 -0
- package/dist/cjs/cli/mysql-tools.d.ts +44 -0
- package/dist/cjs/cli/mysql-tools.js +336 -0
- package/dist/cjs/cli/no-follow.d.ts +29 -0
- package/dist/cjs/cli/no-follow.js +73 -0
- package/dist/cjs/cli/pii-predicate-guard.d.ts +1 -1
- package/dist/cjs/cli/pii-predicate-guard.js +2 -2
- package/dist/cjs/cli/pii-tags.d.ts +2 -2
- package/dist/cjs/cli/pii-tags.js +1 -1
- package/dist/cjs/cli/prisma-schema.js +2 -2
- package/dist/cjs/cli/sql-statements.d.ts +1 -1
- package/dist/cjs/cli/sql-statements.js +1 -1
- package/dist/cjs/cli/sqlite-doctor.d.ts +35 -0
- package/dist/cjs/cli/sqlite-doctor.js +400 -0
- package/dist/cjs/cli/sqlite-migrate-command.d.ts +4 -0
- package/dist/cjs/cli/sqlite-migrate-command.js +175 -0
- package/dist/cjs/cli/sqlite-migrate.d.ts +61 -0
- package/dist/cjs/cli/sqlite-migrate.js +692 -0
- package/dist/cjs/cli/sqlite-project.d.ts +42 -0
- package/dist/cjs/cli/sqlite-project.js +254 -0
- package/dist/cjs/cli/sqlite-schema-command.d.ts +4 -0
- package/dist/cjs/cli/sqlite-schema-command.js +82 -0
- package/dist/cjs/cli/sqlite-schema-ddl.d.ts +25 -0
- package/dist/cjs/cli/sqlite-schema-ddl.js +252 -0
- package/dist/cjs/cli/sqlite-schema.d.ts +25 -0
- package/dist/cjs/cli/sqlite-schema.js +334 -0
- package/dist/cjs/cli/sqlite-seed.d.ts +4 -0
- package/dist/cjs/cli/sqlite-seed.js +94 -0
- package/dist/cjs/cli/sqlite-tools.d.ts +24 -0
- package/dist/cjs/cli/sqlite-tools.js +169 -0
- package/dist/cjs/cli/studio.js +9 -9
- package/dist/cjs/cli/tool-capabilities.d.ts +72 -0
- package/dist/cjs/cli/tool-capabilities.js +120 -0
- package/dist/cjs/cli/tool-command.d.ts +11 -0
- package/dist/cjs/cli/tool-command.js +49 -0
- package/dist/cjs/cli/ui.d.ts +1 -1
- package/dist/cjs/cli/ui.js +1 -1
- package/dist/cjs/client.d.ts +20 -20
- package/dist/cjs/client.js +65 -344
- package/dist/cjs/connection-url.d.ts +1 -1
- package/dist/cjs/connection-url.js +1 -1
- package/dist/cjs/core.d.ts +58 -0
- package/dist/cjs/core.js +225 -0
- package/dist/cjs/d1/catalog-metadata.d.ts +5 -0
- package/dist/cjs/d1/catalog-metadata.js +230 -0
- package/dist/cjs/d1/catalog.d.ts +15 -0
- package/dist/cjs/d1/catalog.js +88 -0
- package/dist/cjs/d1/generate.d.ts +8 -0
- package/dist/cjs/d1/generate.js +163 -0
- package/dist/cjs/d1/introspect.d.ts +21 -0
- package/dist/cjs/d1/introspect.js +74 -0
- package/dist/cjs/d1/migrate.d.ts +29 -0
- package/dist/cjs/d1/migrate.js +222 -0
- package/dist/cjs/d1/migrations/sql.d.ts +2 -0
- package/dist/cjs/d1/migrations/sql.js +109 -0
- package/dist/cjs/d1/pool.d.ts +14 -0
- package/dist/cjs/d1/pool.js +90 -0
- package/dist/cjs/d1/sql.d.ts +5 -0
- package/dist/cjs/d1/sql.js +140 -0
- package/dist/cjs/d1/sqlite-dialect.d.ts +16 -0
- package/dist/cjs/d1/sqlite-dialect.js +579 -0
- package/dist/cjs/d1/types.d.ts +29 -0
- package/dist/cjs/d1/types.js +2 -0
- package/dist/cjs/d1.d.ts +53 -0
- package/dist/cjs/d1.js +220 -0
- package/dist/cjs/dialect.d.ts +33 -5
- package/dist/cjs/dialect.js +8 -6
- package/dist/cjs/errors.d.ts +38 -1
- package/dist/cjs/errors.js +72 -18
- package/dist/cjs/generate.d.ts +19 -3
- package/dist/cjs/generate.js +330 -97
- package/dist/cjs/global-filters-config.js +4 -4
- package/dist/cjs/index-advisor.js +6 -6
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +3 -2
- package/dist/cjs/introspect.d.ts +59 -356
- package/dist/cjs/introspect.js +158 -984
- package/dist/cjs/libsql/bindings.d.ts +2 -0
- package/dist/cjs/libsql/bindings.js +78 -0
- package/dist/cjs/libsql/dialect.d.ts +3 -0
- package/dist/cjs/libsql/dialect.js +48 -0
- package/dist/cjs/libsql/generate.d.ts +4 -0
- package/dist/cjs/libsql/generate.js +56 -0
- package/dist/cjs/libsql/introspect.d.ts +16 -0
- package/dist/cjs/libsql/introspect.js +295 -0
- package/dist/cjs/libsql/pool.d.ts +42 -0
- package/dist/cjs/libsql/pool.js +275 -0
- package/dist/cjs/libsql/seed-cleanup.d.ts +2 -0
- package/dist/cjs/libsql/seed-cleanup.js +19 -0
- package/dist/cjs/libsql/values.d.ts +20 -0
- package/dist/cjs/libsql/values.js +75 -0
- package/dist/cjs/libsql-seed.d.ts +19 -0
- package/dist/cjs/libsql-seed.js +50 -0
- package/dist/cjs/libsql.d.ts +28 -0
- package/dist/cjs/libsql.js +88 -0
- package/dist/cjs/live-query.d.ts +33 -0
- package/dist/cjs/live-query.js +172 -0
- package/dist/cjs/log-codes.d.ts +1 -1
- package/dist/cjs/log-codes.js +4 -0
- package/dist/cjs/mssql-seed.d.ts +27 -0
- package/dist/cjs/mssql-seed.js +118 -0
- package/dist/cjs/mssql.d.ts +7 -7
- package/dist/cjs/mssql.js +365 -53
- package/dist/cjs/mysql-seed.d.ts +25 -0
- package/dist/cjs/mysql-seed.js +169 -0
- package/dist/cjs/mysql.d.ts +18 -6
- package/dist/cjs/mysql.js +602 -94
- package/dist/cjs/neon-http/client.d.ts +95 -0
- package/dist/cjs/neon-http/client.js +291 -0
- package/dist/cjs/neon-http/sql.d.ts +3 -0
- package/dist/cjs/neon-http/sql.js +116 -0
- package/dist/cjs/neon-http.d.ts +5 -0
- package/dist/cjs/neon-http.js +8 -0
- package/dist/cjs/neon-ws/load-driver.cjs +44 -0
- package/dist/cjs/neon-ws/load-driver.d.cts +9 -0
- package/dist/cjs/neon-ws/recovery.d.ts +14 -0
- package/dist/cjs/neon-ws/recovery.js +69 -0
- package/dist/cjs/neon-ws/snapshot.d.ts +3 -0
- package/dist/cjs/neon-ws/snapshot.js +17 -0
- package/dist/cjs/neon-ws/transport.d.ts +112 -0
- package/dist/cjs/neon-ws/transport.js +290 -0
- package/dist/cjs/neon-ws.d.ts +26 -0
- package/dist/cjs/neon-ws.js +189 -0
- package/dist/cjs/nested-write.d.ts +34 -3
- package/dist/cjs/nested-write.js +117 -24
- package/dist/cjs/notification-hub/consumer.d.ts +22 -0
- package/dist/cjs/notification-hub/consumer.js +111 -0
- package/dist/cjs/notification-hub.d.ts +41 -0
- package/dist/cjs/notification-hub.js +373 -0
- package/dist/cjs/pg-catalog-text.d.ts +96 -0
- package/dist/cjs/pg-catalog-text.js +213 -0
- package/dist/cjs/pg-types.d.ts +46 -2
- package/dist/cjs/pipeline-submittable.d.ts +15 -5
- package/dist/cjs/pipeline-submittable.js +103 -48
- package/dist/cjs/pipeline.d.ts +5 -2
- package/dist/cjs/pipeline.js +111 -41
- package/dist/cjs/plan-divergence.d.ts +1 -1
- package/dist/cjs/plan-divergence.js +1 -1
- package/dist/cjs/powdb-introspect.d.ts +1 -1
- package/dist/cjs/powdb-introspect.js +5 -5
- package/dist/cjs/powdb-shared.d.ts +5 -5
- package/dist/cjs/powdb-shared.js +6 -5
- package/dist/cjs/powdb.d.ts +28 -10
- package/dist/cjs/powdb.js +80 -28
- package/dist/cjs/powql.d.ts +50 -28
- package/dist/cjs/powql.js +47 -33
- package/dist/cjs/prisma-compat.js +4 -5
- package/dist/cjs/prisma-schema-fingerprint.d.ts +1 -1
- package/dist/cjs/prisma-schema-fingerprint.js +1 -1
- package/dist/cjs/query/aggregates.d.ts +0 -13
- package/dist/cjs/query/aggregates.js +105 -238
- package/dist/cjs/query/batched-loader.d.ts +1 -1
- package/dist/cjs/query/batched-loader.js +18 -20
- package/dist/cjs/query/builder.d.ts +108 -144
- package/dist/cjs/query/builder.js +592 -893
- package/dist/cjs/query/compound-unique.d.ts +18 -3
- package/dist/cjs/query/compound-unique.js +110 -43
- package/dist/cjs/query/cursor-tuple.d.ts +17 -0
- package/dist/cjs/query/cursor-tuple.js +121 -0
- package/dist/cjs/query/expr.d.ts +2 -0
- package/dist/cjs/query/expr.js +40 -23
- package/dist/cjs/query/filters.d.ts +39 -7
- package/dist/cjs/query/filters.js +77 -19
- package/dist/cjs/query/normalize-args.d.ts +1 -1
- package/dist/cjs/query/normalize-args.js +7 -5
- package/dist/cjs/query/option-surface.d.ts +1 -1
- package/dist/cjs/query/option-surface.js +5 -3
- package/dist/cjs/query/pg-type-parsers.d.ts +126 -0
- package/dist/cjs/query/pg-type-parsers.js +306 -0
- package/dist/cjs/query/relation-names.d.ts +4 -2
- package/dist/cjs/query/relation-names.js +21 -12
- package/dist/cjs/query/relations.d.ts +19 -7
- package/dist/cjs/query/relations.js +329 -260
- package/dist/cjs/query/row-lock.js +3 -3
- package/dist/cjs/query/sql-comment.js +3 -3
- package/dist/cjs/query/stream-idle.d.ts +11 -1
- package/dist/cjs/query/stream-idle.js +53 -13
- package/dist/cjs/query/stream-signal.d.ts +21 -0
- package/dist/cjs/query/stream-signal.js +132 -0
- package/dist/cjs/query/temporal-parsers.d.ts +101 -0
- package/dist/cjs/query/temporal-parsers.js +362 -0
- package/dist/cjs/query/types.d.ts +67 -20
- package/dist/cjs/query/utils.d.ts +2 -878
- package/dist/cjs/query/utils.js +25 -2058
- package/dist/cjs/query/warn-registry.d.ts +1 -1
- package/dist/cjs/query/warn-registry.js +1 -1
- package/dist/cjs/query/where-compile.d.ts +4 -1
- package/dist/cjs/query/where-compile.js +18 -14
- package/dist/cjs/query/where.d.ts +14 -7
- package/dist/cjs/query/where.js +244 -436
- package/dist/cjs/query/writes.d.ts +33 -2
- package/dist/cjs/query/writes.js +104 -77
- package/dist/cjs/query-utils.d.ts +687 -0
- package/dist/cjs/query-utils.js +1444 -0
- package/dist/cjs/realtime.d.ts +1 -1
- package/dist/cjs/realtime.js +3 -3
- package/dist/cjs/schema-builder.js +2 -2
- package/dist/cjs/schema-metadata.d.ts +13 -3
- package/dist/cjs/schema-metadata.js +33 -5
- package/dist/cjs/schema-sql.d.ts +15 -24
- package/dist/cjs/schema-sql.js +53 -63
- package/dist/cjs/schema.d.ts +37 -2
- package/dist/cjs/schema.js +29 -2
- package/dist/cjs/seed.js +5 -5
- package/dist/cjs/serverless.d.ts +24 -71
- package/dist/cjs/serverless.js +24 -71
- package/dist/cjs/sql.d.ts +111 -0
- package/dist/cjs/sql.js +335 -0
- package/dist/cjs/sqlite-seed.d.ts +17 -0
- package/dist/cjs/sqlite-seed.js +31 -0
- package/dist/cjs/sqlite.d.ts +32 -19
- package/dist/cjs/sqlite.js +865 -652
- package/dist/cjs/supplied-pool-types.js +10 -9
- package/dist/cjs/transaction-control.js +6 -1
- package/dist/cjs/transaction-outcome.d.ts +61 -0
- package/dist/cjs/transaction-outcome.js +239 -0
- package/dist/cjs/transaction-state.d.ts +82 -13
- package/dist/cjs/transaction-state.js +222 -56
- package/dist/cjs/transaction-transport.d.ts +38 -0
- package/dist/cjs/transaction-transport.js +157 -0
- package/dist/cjs/typed-sql.d.ts +1 -1
- package/dist/cjs/typed-sql.js +1 -1
- package/dist/cli/compile-query.d.ts +6 -3
- package/dist/cli/compile-query.js +25 -4
- package/dist/cli/config.d.ts +35 -10
- package/dist/cli/config.js +170 -43
- package/dist/cli/d1-config.d.ts +14 -0
- package/dist/cli/d1-config.js +6 -0
- package/dist/cli/d1-local.d.ts +31 -0
- package/dist/cli/d1-local.js +285 -0
- package/dist/cli/d1-migrations.d.ts +16 -0
- package/dist/cli/d1-migrations.js +151 -0
- package/dist/cli/d1-project.d.ts +23 -0
- package/dist/cli/d1-project.js +304 -0
- package/dist/cli/d1-seed.d.ts +35 -0
- package/dist/cli/d1-seed.js +213 -0
- package/dist/cli/destructive.js +1 -2
- package/dist/cli/error-catalog.d.ts +3 -3
- package/dist/cli/error-catalog.js +21 -3
- package/dist/cli/index.d.ts +13 -8
- package/dist/cli/index.js +500 -71
- package/dist/cli/libsql-migrate-command.d.ts +5 -0
- package/dist/cli/libsql-migrate-command.js +77 -0
- package/dist/cli/libsql-migrate-status.d.ts +33 -0
- package/dist/cli/libsql-migrate-status.js +182 -0
- package/dist/cli/libsql-migrate.d.ts +14 -0
- package/dist/cli/libsql-migrate.js +516 -0
- package/dist/cli/libsql-project-config.d.ts +11 -0
- package/dist/cli/libsql-project-config.js +55 -0
- package/dist/cli/libsql-project.d.ts +52 -0
- package/dist/cli/libsql-project.js +391 -0
- package/dist/cli/libsql-seed-command.d.ts +29 -0
- package/dist/cli/libsql-seed-command.js +85 -0
- package/dist/cli/loader.d.ts +6 -5
- package/dist/cli/loader.js +50 -9
- package/dist/cli/mcp.d.ts +16 -1
- package/dist/cli/mcp.js +220 -127
- package/dist/cli/migrate.d.ts +2 -2
- package/dist/cli/migrate.js +29 -14
- package/dist/cli/mssql-doctor.d.ts +44 -0
- package/dist/cli/mssql-doctor.js +237 -0
- package/dist/cli/mssql-migrate-command.d.ts +9 -0
- package/dist/cli/mssql-migrate-command.js +192 -0
- package/dist/cli/mssql-migrate-connection.d.ts +51 -0
- package/dist/cli/mssql-migrate-connection.js +245 -0
- package/dist/cli/mssql-migrate-sql.d.ts +12 -0
- package/dist/cli/mssql-migrate-sql.js +275 -0
- package/dist/cli/mssql-migrate.d.ts +45 -0
- package/dist/cli/mssql-migrate.js +290 -0
- package/dist/cli/mssql-project.d.ts +34 -0
- package/dist/cli/mssql-project.js +160 -0
- package/dist/cli/mssql-seed.d.ts +7 -0
- package/dist/cli/mssql-seed.js +73 -0
- package/dist/cli/mssql-tools.d.ts +37 -0
- package/dist/cli/mssql-tools.js +341 -0
- package/dist/cli/mysql-doctor.d.ts +48 -0
- package/dist/cli/mysql-doctor.js +316 -0
- package/dist/cli/mysql-migrate-command.d.ts +7 -0
- package/dist/cli/mysql-migrate-command.js +285 -0
- package/dist/cli/mysql-migrate-sql.d.ts +18 -0
- package/dist/cli/mysql-migrate-sql.js +162 -0
- package/dist/cli/mysql-migrate.d.ts +77 -0
- package/dist/cli/mysql-migrate.js +606 -0
- package/dist/cli/mysql-project.d.ts +49 -0
- package/dist/cli/mysql-project.js +272 -0
- package/dist/cli/mysql-push-command.d.ts +7 -0
- package/dist/cli/mysql-push-command.js +89 -0
- package/dist/cli/mysql-push.d.ts +15 -0
- package/dist/cli/mysql-push.js +95 -0
- package/dist/cli/mysql-schema-command.d.ts +5 -0
- package/dist/cli/mysql-schema-command.js +54 -0
- package/dist/cli/mysql-schema-ddl.d.ts +37 -0
- package/dist/cli/mysql-schema-ddl.js +227 -0
- package/dist/cli/mysql-schema-snapshot.d.ts +21 -0
- package/dist/cli/mysql-schema-snapshot.js +119 -0
- package/dist/cli/mysql-schema.d.ts +27 -0
- package/dist/cli/mysql-schema.js +200 -0
- package/dist/cli/mysql-seed-loader.cjs +25 -0
- package/dist/cli/mysql-seed-loader.d.cts +3 -0
- package/dist/cli/mysql-seed.d.ts +6 -0
- package/dist/cli/mysql-seed.js +75 -0
- package/dist/cli/mysql-tools.d.ts +44 -0
- package/dist/cli/mysql-tools.js +290 -0
- package/dist/cli/no-follow.d.ts +29 -0
- package/dist/cli/no-follow.js +67 -0
- package/dist/cli/pii-predicate-guard.d.ts +1 -1
- package/dist/cli/pii-predicate-guard.js +2 -2
- package/dist/cli/pii-tags.d.ts +2 -2
- package/dist/cli/pii-tags.js +1 -1
- package/dist/cli/prisma-schema.js +2 -2
- package/dist/cli/sql-statements.d.ts +1 -1
- package/dist/cli/sql-statements.js +1 -1
- package/dist/cli/sqlite-doctor.d.ts +35 -0
- package/dist/cli/sqlite-doctor.js +392 -0
- package/dist/cli/sqlite-migrate-command.d.ts +4 -0
- package/dist/cli/sqlite-migrate-command.js +171 -0
- package/dist/cli/sqlite-migrate.d.ts +61 -0
- package/dist/cli/sqlite-migrate.js +681 -0
- package/dist/cli/sqlite-project.d.ts +42 -0
- package/dist/cli/sqlite-project.js +244 -0
- package/dist/cli/sqlite-schema-command.d.ts +4 -0
- package/dist/cli/sqlite-schema-command.js +79 -0
- package/dist/cli/sqlite-schema-ddl.d.ts +25 -0
- package/dist/cli/sqlite-schema-ddl.js +248 -0
- package/dist/cli/sqlite-schema.d.ts +25 -0
- package/dist/cli/sqlite-schema.js +330 -0
- package/dist/cli/sqlite-seed.d.ts +4 -0
- package/dist/cli/sqlite-seed.js +57 -0
- package/dist/cli/sqlite-tools.d.ts +24 -0
- package/dist/cli/sqlite-tools.js +163 -0
- package/dist/cli/studio.js +9 -9
- package/dist/cli/tool-capabilities.d.ts +72 -0
- package/dist/cli/tool-capabilities.js +114 -0
- package/dist/cli/tool-command.d.ts +11 -0
- package/dist/cli/tool-command.js +45 -0
- package/dist/cli/ui.d.ts +1 -1
- package/dist/cli/ui.js +1 -1
- package/dist/client.d.ts +20 -20
- package/dist/client.js +62 -341
- package/dist/connection-url.d.ts +1 -1
- package/dist/connection-url.js +1 -1
- package/dist/core.d.ts +58 -0
- package/dist/core.js +220 -0
- package/dist/d1/catalog-metadata.d.ts +5 -0
- package/dist/d1/catalog-metadata.js +227 -0
- package/dist/d1/catalog.d.ts +15 -0
- package/dist/d1/catalog.js +82 -0
- package/dist/d1/generate.d.ts +8 -0
- package/dist/d1/generate.js +160 -0
- package/dist/d1/introspect.d.ts +21 -0
- package/dist/d1/introspect.js +71 -0
- package/dist/d1/migrate.d.ts +29 -0
- package/dist/d1/migrate.js +217 -0
- package/dist/d1/migrations/sql.d.ts +2 -0
- package/dist/d1/migrations/sql.js +106 -0
- package/dist/d1/pool.d.ts +14 -0
- package/dist/d1/pool.js +86 -0
- package/dist/d1/sql.d.ts +5 -0
- package/dist/d1/sql.js +135 -0
- package/dist/d1/sqlite-dialect.d.ts +16 -0
- package/dist/d1/sqlite-dialect.js +572 -0
- package/dist/d1/types.d.ts +29 -0
- package/dist/d1/types.js +1 -0
- package/dist/d1.d.ts +53 -0
- package/dist/d1.js +215 -0
- package/dist/dialect.d.ts +33 -5
- package/dist/dialect.js +6 -4
- package/dist/errors.d.ts +38 -1
- package/dist/errors.js +68 -17
- package/dist/generate.d.ts +19 -3
- package/dist/generate.js +330 -97
- package/dist/global-filters-config.js +2 -2
- package/dist/index-advisor.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/introspect.d.ts +59 -356
- package/dist/introspect.js +116 -943
- package/dist/libsql/bindings.d.ts +2 -0
- package/dist/libsql/bindings.js +75 -0
- package/dist/libsql/dialect.d.ts +3 -0
- package/dist/libsql/dialect.js +45 -0
- package/dist/libsql/generate.d.ts +4 -0
- package/dist/libsql/generate.js +53 -0
- package/dist/libsql/introspect.d.ts +16 -0
- package/dist/libsql/introspect.js +289 -0
- package/dist/libsql/pool.d.ts +42 -0
- package/dist/libsql/pool.js +270 -0
- package/dist/libsql/seed-cleanup.d.ts +2 -0
- package/dist/libsql/seed-cleanup.js +15 -0
- package/dist/libsql/values.d.ts +20 -0
- package/dist/libsql/values.js +68 -0
- package/dist/libsql-seed.d.ts +19 -0
- package/dist/libsql-seed.js +46 -0
- package/dist/libsql.d.ts +28 -0
- package/dist/libsql.js +79 -0
- package/dist/live-query.d.ts +33 -0
- package/dist/live-query.js +169 -0
- package/dist/log-codes.d.ts +1 -1
- package/dist/log-codes.js +4 -0
- package/dist/mssql-seed.d.ts +27 -0
- package/dist/mssql-seed.js +114 -0
- package/dist/mssql.d.ts +7 -7
- package/dist/mssql.js +366 -54
- package/dist/mysql-seed.d.ts +25 -0
- package/dist/mysql-seed.js +165 -0
- package/dist/mysql.d.ts +18 -6
- package/dist/mysql.js +603 -95
- package/dist/neon-http/client.d.ts +95 -0
- package/dist/neon-http/client.js +286 -0
- package/dist/neon-http/sql.d.ts +3 -0
- package/dist/neon-http/sql.js +112 -0
- package/dist/neon-http.d.ts +5 -0
- package/dist/neon-http.js +2 -0
- package/dist/neon-ws/load-driver.cjs +11 -0
- package/dist/neon-ws/load-driver.d.cts +9 -0
- package/dist/neon-ws/recovery.d.ts +14 -0
- package/dist/neon-ws/recovery.js +66 -0
- package/dist/neon-ws/snapshot.d.ts +3 -0
- package/dist/neon-ws/snapshot.js +15 -0
- package/dist/neon-ws/transport.d.ts +112 -0
- package/dist/neon-ws/transport.js +286 -0
- package/dist/neon-ws.d.ts +26 -0
- package/dist/neon-ws.js +182 -0
- package/dist/nested-write.d.ts +34 -3
- package/dist/nested-write.js +114 -22
- package/dist/notification-hub/consumer.d.ts +22 -0
- package/dist/notification-hub/consumer.js +106 -0
- package/dist/notification-hub.d.ts +41 -0
- package/dist/notification-hub.js +370 -0
- package/dist/pg-catalog-text.d.ts +96 -0
- package/dist/pg-catalog-text.js +208 -0
- package/dist/pg-types.d.ts +46 -2
- package/dist/pipeline-submittable.d.ts +15 -5
- package/dist/pipeline-submittable.js +105 -50
- package/dist/pipeline.d.ts +5 -2
- package/dist/pipeline.js +113 -43
- package/dist/plan-divergence.d.ts +1 -1
- package/dist/plan-divergence.js +1 -1
- package/dist/powdb-introspect.d.ts +1 -1
- package/dist/powdb-introspect.js +5 -5
- package/dist/powdb-shared.d.ts +5 -5
- package/dist/powdb-shared.js +6 -5
- package/dist/powdb.d.ts +28 -10
- package/dist/powdb.js +80 -28
- package/dist/powql.d.ts +50 -28
- package/dist/powql.js +49 -35
- package/dist/prisma-compat.js +4 -5
- package/dist/prisma-schema-fingerprint.d.ts +1 -1
- package/dist/prisma-schema-fingerprint.js +1 -1
- package/dist/query/aggregates.d.ts +0 -13
- package/dist/query/aggregates.js +97 -230
- package/dist/query/batched-loader.d.ts +1 -1
- package/dist/query/batched-loader.js +5 -7
- package/dist/query/builder.d.ts +108 -144
- package/dist/query/builder.js +563 -864
- package/dist/query/compound-unique.d.ts +18 -3
- package/dist/query/compound-unique.js +99 -33
- package/dist/query/cursor-tuple.d.ts +17 -0
- package/dist/query/cursor-tuple.js +114 -0
- package/dist/query/expr.d.ts +2 -0
- package/dist/query/expr.js +32 -16
- package/dist/query/filters.d.ts +39 -7
- package/dist/query/filters.js +69 -14
- package/dist/query/normalize-args.d.ts +1 -1
- package/dist/query/normalize-args.js +4 -2
- package/dist/query/option-surface.d.ts +1 -1
- package/dist/query/option-surface.js +4 -2
- package/dist/query/pg-type-parsers.d.ts +126 -0
- package/dist/query/pg-type-parsers.js +296 -0
- package/dist/query/relation-names.d.ts +4 -2
- package/dist/query/relation-names.js +15 -7
- package/dist/query/relations.d.ts +19 -7
- package/dist/query/relations.js +293 -227
- package/dist/query/row-lock.js +1 -1
- package/dist/query/sql-comment.js +1 -1
- package/dist/query/stream-idle.d.ts +11 -1
- package/dist/query/stream-idle.js +51 -13
- package/dist/query/stream-signal.d.ts +21 -0
- package/dist/query/stream-signal.js +125 -0
- package/dist/query/temporal-parsers.d.ts +101 -0
- package/dist/query/temporal-parsers.js +354 -0
- package/dist/query/types.d.ts +67 -20
- package/dist/query/utils.d.ts +2 -878
- package/dist/query/utils.js +5 -2003
- package/dist/query/warn-registry.d.ts +1 -1
- package/dist/query/warn-registry.js +1 -1
- package/dist/query/where-compile.d.ts +4 -1
- package/dist/query/where-compile.js +14 -10
- package/dist/query/where.d.ts +14 -7
- package/dist/query/where.js +236 -430
- package/dist/query/writes.d.ts +33 -2
- package/dist/query/writes.js +90 -65
- package/dist/query-utils.d.ts +687 -0
- package/dist/query-utils.js +1390 -0
- package/dist/realtime.d.ts +1 -1
- package/dist/realtime.js +3 -3
- package/dist/schema-builder.js +2 -2
- package/dist/schema-metadata.d.ts +13 -3
- package/dist/schema-metadata.js +33 -5
- package/dist/schema-sql.d.ts +15 -24
- package/dist/schema-sql.js +50 -60
- package/dist/schema.d.ts +37 -2
- package/dist/schema.js +29 -2
- package/dist/seed.js +5 -5
- package/dist/serverless.d.ts +24 -71
- package/dist/serverless.js +24 -71
- package/dist/sql.d.ts +111 -0
- package/dist/sql.js +321 -0
- package/dist/sqlite-seed.d.ts +17 -0
- package/dist/sqlite-seed.js +27 -0
- package/dist/sqlite.d.ts +32 -19
- package/dist/sqlite.js +859 -648
- package/dist/supplied-pool-types.js +2 -1
- package/dist/transaction-control.js +6 -1
- package/dist/transaction-outcome.d.ts +61 -0
- package/dist/transaction-outcome.js +234 -0
- package/dist/transaction-state.d.ts +82 -13
- package/dist/transaction-state.js +220 -57
- package/dist/transaction-transport.d.ts +38 -0
- package/dist/transaction-transport.js +153 -0
- package/dist/typed-sql.d.ts +1 -1
- package/dist/typed-sql.js +1 -1
- package/package.json +239 -13
- package/skills/turbine-orm/SKILL.md +6 -5
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assertMysqlProjectCommand = assertMysqlProjectCommand;
|
|
4
|
+
exports.introspectMysqlProject = introspectMysqlProject;
|
|
5
|
+
exports.generateMysqlProject = generateMysqlProject;
|
|
6
|
+
exports.mysqlConfigTemplate = mysqlConfigTemplate;
|
|
7
|
+
exports.ignoreEnvFile = ignoreEnvFile;
|
|
8
|
+
exports.initMysqlProject = initMysqlProject;
|
|
9
|
+
exports.cmdMysqlInit = cmdMysqlInit;
|
|
10
|
+
exports.cmdMysqlGenerate = cmdMysqlGenerate;
|
|
11
|
+
exports.cmdMysqlStatus = cmdMysqlStatus;
|
|
12
|
+
exports.showMysqlHelp = showMysqlHelp;
|
|
13
|
+
/** SQL-first MySQL project commands backed by the optional native introspector. */
|
|
14
|
+
const node_fs_1 = require("node:fs");
|
|
15
|
+
const node_path_1 = require("node:path");
|
|
16
|
+
const errors_js_1 = require("../errors.js");
|
|
17
|
+
const generate_js_1 = require("../generate.js");
|
|
18
|
+
const introspect_js_1 = require("../introspect.js");
|
|
19
|
+
const mysql_js_1 = require("../mysql.js");
|
|
20
|
+
const config_js_1 = require("./config.js");
|
|
21
|
+
const no_follow_js_1 = require("./no-follow.js");
|
|
22
|
+
const ui_js_1 = require("./ui.js");
|
|
23
|
+
function checkConfig(config, args) {
|
|
24
|
+
if ((0, config_js_1.resolveCliEngine)(config.engine) !== 'mysql') {
|
|
25
|
+
throw new errors_js_1.ValidationError('MySQL project commands require engine "mysql".');
|
|
26
|
+
}
|
|
27
|
+
let database;
|
|
28
|
+
try {
|
|
29
|
+
database = (0, config_js_1.mysqlDatabaseFromUrl)(config.url);
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
throw new errors_js_1.ValidationError(error.message);
|
|
33
|
+
}
|
|
34
|
+
if (config.schema !== database)
|
|
35
|
+
throw new errors_js_1.ValidationError('MySQL CLI schema must match the database in its URL.');
|
|
36
|
+
if (config.adapter !== undefined)
|
|
37
|
+
throw new errors_js_1.ValidationError('PostgreSQL adapters cannot be used with MySQL.');
|
|
38
|
+
for (const key of ['include', 'exclude']) {
|
|
39
|
+
if (!Array.isArray(config[key]) || !config[key].every((value) => typeof value === 'string' && value.length > 0)) {
|
|
40
|
+
throw new errors_js_1.ValidationError(`MySQL config ${key} must be an array of nonempty table names.`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
for (const key of ['out', 'migrationsDir']) {
|
|
44
|
+
if (typeof config[key] !== 'string' || !config[key].trim() || config[key].includes('\0')) {
|
|
45
|
+
throw new errors_js_1.ValidationError(`MySQL config ${key} must be a nonempty path.`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (!['auto', 'js', 'ts', 'none'].includes(config.importExtension)) {
|
|
49
|
+
throw new errors_js_1.ValidationError('MySQL config importExtension must be auto, js, ts, or none.');
|
|
50
|
+
}
|
|
51
|
+
if (typeof config.keepColumnNames !== 'boolean' || typeof config.legacyToManyUniques !== 'boolean') {
|
|
52
|
+
throw new errors_js_1.ValidationError('MySQL config keepColumnNames and legacyToManyUniques must be booleans.');
|
|
53
|
+
}
|
|
54
|
+
if (config.columnTypes !== undefined &&
|
|
55
|
+
(!config.columnTypes ||
|
|
56
|
+
typeof config.columnTypes !== 'object' ||
|
|
57
|
+
Array.isArray(config.columnTypes) ||
|
|
58
|
+
!Object.values(config.columnTypes).every((value) => typeof value === 'string' && value.trim()))) {
|
|
59
|
+
throw new errors_js_1.ValidationError('MySQL config columnTypes must map database columns to nonempty TypeScript type strings.');
|
|
60
|
+
}
|
|
61
|
+
if (config.relationNames !== undefined &&
|
|
62
|
+
(!config.relationNames ||
|
|
63
|
+
typeof config.relationNames !== 'object' ||
|
|
64
|
+
Array.isArray(config.relationNames) ||
|
|
65
|
+
!Object.values(config.relationNames).every((names) => names &&
|
|
66
|
+
typeof names === 'object' &&
|
|
67
|
+
!Array.isArray(names) &&
|
|
68
|
+
Object.values(names).every((name) => typeof name === 'string' && name.length > 0)))) {
|
|
69
|
+
throw new errors_js_1.ValidationError('MySQL config relationNames must map tables to relation rename maps.');
|
|
70
|
+
}
|
|
71
|
+
if (args.includeViews)
|
|
72
|
+
throw new errors_js_1.ValidationError('MySQL CLI introspection does not support --include-views yet.');
|
|
73
|
+
if (args.withSchema || config.schemaFileConfigured) {
|
|
74
|
+
throw new errors_js_1.ValidationError('MySQL CLI projects use SQL migrations, not schemaFile or --with-schema.');
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/** Refuse every unsupported command before reaching PostgreSQL handlers. */
|
|
78
|
+
function assertMysqlProjectCommand(command) {
|
|
79
|
+
if (['init', 'generate', 'gen', 'g', 'pull', 'status', 'info', 'migrate', 'migration', 'm'].includes(command))
|
|
80
|
+
return;
|
|
81
|
+
throw new errors_js_1.ValidationError(`Command "${command}" is not supported for MySQL. Supported commands: init, pull, generate, status, migrate.`);
|
|
82
|
+
}
|
|
83
|
+
/** Read the native MySQL catalog and release its short-lived pool on all paths. */
|
|
84
|
+
async function introspectMysqlProject(config, args = {}) {
|
|
85
|
+
checkConfig(config, args);
|
|
86
|
+
const metadata = await (0, mysql_js_1.introspectMysql)({
|
|
87
|
+
connectionString: config.url,
|
|
88
|
+
schema: config.schema,
|
|
89
|
+
include: config.include,
|
|
90
|
+
legacyToManyUniques: config.legacyToManyUniques,
|
|
91
|
+
// The native migration runner journals partial DDL separately from history.
|
|
92
|
+
exclude: config.include.includes('_turbine_migration_state')
|
|
93
|
+
? config.exclude
|
|
94
|
+
: [...config.exclude, '_turbine_migration_state'],
|
|
95
|
+
});
|
|
96
|
+
const schema = config.relationNames ? (0, introspect_js_1.applyRelationRenames)(metadata, config.relationNames) : metadata;
|
|
97
|
+
(0, introspect_js_1.assertSafeCatalogSchema)(schema);
|
|
98
|
+
return schema;
|
|
99
|
+
}
|
|
100
|
+
/** Generate only after native introspection and validation succeed. */
|
|
101
|
+
async function generateMysqlProject(config, args = {}) {
|
|
102
|
+
const schema = await introspectMysqlProject(config, args);
|
|
103
|
+
if (Object.keys(schema.tables).length === 0 && !args.allowEmpty) {
|
|
104
|
+
throw new errors_js_1.ValidationError('MySQL introspection matched 0 tables; refusing an empty client. Apply SQL, check include/exclude, or pass --allow-empty.');
|
|
105
|
+
}
|
|
106
|
+
let columnTypes = config.columnTypes;
|
|
107
|
+
if (columnTypes && (config.include.length || config.exclude.length)) {
|
|
108
|
+
// Validate excluded overrides against the full catalog so genuine typos still fail.
|
|
109
|
+
const catalog = await introspectMysqlProject({ ...config, include: [], exclude: [], relationNames: undefined }, args);
|
|
110
|
+
columnTypes = Object.fromEntries(Object.entries(columnTypes).filter(([key]) => {
|
|
111
|
+
const table = key.slice(0, key.lastIndexOf('.'));
|
|
112
|
+
const column = key.slice(key.lastIndexOf('.') + 1);
|
|
113
|
+
return Object.hasOwn(schema.tables, table) || !catalog.tables[table]?.columns.some((c) => c.name === column);
|
|
114
|
+
}));
|
|
115
|
+
}
|
|
116
|
+
const result = (0, generate_js_1.generate)({
|
|
117
|
+
target: 'mysql',
|
|
118
|
+
schema,
|
|
119
|
+
exactNativeIntegers: config.exactNativeIntegers,
|
|
120
|
+
outDir: config.out,
|
|
121
|
+
connectionString: config.url,
|
|
122
|
+
importExtension: config.importExtension,
|
|
123
|
+
keepColumnNames: config.keepColumnNames,
|
|
124
|
+
columnTypes,
|
|
125
|
+
noTimestamp: args.noTimestamp,
|
|
126
|
+
zod: args.zod,
|
|
127
|
+
});
|
|
128
|
+
return { schema, ...result };
|
|
129
|
+
}
|
|
130
|
+
/** Credentials always stay in the environment, never the tracked config. */
|
|
131
|
+
function mysqlConfigTemplate(config) {
|
|
132
|
+
return `import type { TurbineCliConfig } from 'turbine-orm/cli';
|
|
133
|
+
|
|
134
|
+
const config: TurbineCliConfig = {
|
|
135
|
+
engine: 'mysql',
|
|
136
|
+
url: process.env.DATABASE_URL,
|
|
137
|
+
out: ${JSON.stringify(config.out)},
|
|
138
|
+
migrationsDir: ${JSON.stringify(config.migrationsDir)},
|
|
139
|
+
legacyToManyUniques: ${JSON.stringify(config.legacyToManyUniques)},
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
// Apply schema changes with native MySQL SQL tooling, then turbine generate.
|
|
143
|
+
export default config;
|
|
144
|
+
`;
|
|
145
|
+
}
|
|
146
|
+
function createFile(path, contents, created) {
|
|
147
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.dirname)(path), { recursive: true });
|
|
148
|
+
try {
|
|
149
|
+
(0, node_fs_1.writeFileSync)(path, contents, { encoding: 'utf8', flag: 'wx' });
|
|
150
|
+
created.push(path);
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
if (error.code !== 'EEXIST')
|
|
154
|
+
throw error;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Make `.gitignore` ignore `/.env`. Created only when nothing is at the name;
|
|
159
|
+
* otherwise read and appended through one descriptor, so the file read is the
|
|
160
|
+
* file appended to, and a `.gitignore` that appeared after a separate look is
|
|
161
|
+
* given the rule instead of being skipped before `.env` is written.
|
|
162
|
+
* @internal exported for tests.
|
|
163
|
+
*/
|
|
164
|
+
function ignoreEnvFile(created) {
|
|
165
|
+
const rule = '# Local database credentials\n/.env\n';
|
|
166
|
+
try {
|
|
167
|
+
(0, node_fs_1.writeFileSync)('.gitignore', rule, { encoding: 'utf8', flag: 'wx' });
|
|
168
|
+
created.push('.gitignore');
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
catch (error) {
|
|
172
|
+
if (error.code !== 'EEXIST')
|
|
173
|
+
throw error;
|
|
174
|
+
}
|
|
175
|
+
const lacksRule = (fd) => !/(?:^|\n)\/\.env\s*$/.test((0, node_fs_1.readFileSync)(fd, 'utf8').trimEnd());
|
|
176
|
+
let fd;
|
|
177
|
+
try {
|
|
178
|
+
fd = (0, node_fs_1.openSync)('.gitignore', node_fs_1.constants.O_RDWR | node_fs_1.constants.O_APPEND);
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
if (error.code === 'ENOENT') {
|
|
182
|
+
throw new errors_js_1.ValidationError('.gitignore cannot be read or created (a dangling symlink?). Remove it and run the command again.');
|
|
183
|
+
}
|
|
184
|
+
// A .gitignore that cannot be written but already has the rule needs nothing.
|
|
185
|
+
if (!(0, no_follow_js_1.isWriteRefusal)(error))
|
|
186
|
+
throw error;
|
|
187
|
+
const readOnly = (0, node_fs_1.openSync)('.gitignore', node_fs_1.constants.O_RDONLY);
|
|
188
|
+
try {
|
|
189
|
+
if (!lacksRule(readOnly))
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
finally {
|
|
193
|
+
(0, node_fs_1.closeSync)(readOnly);
|
|
194
|
+
}
|
|
195
|
+
throw error;
|
|
196
|
+
}
|
|
197
|
+
try {
|
|
198
|
+
if (lacksRule(fd))
|
|
199
|
+
(0, node_fs_1.appendFileSync)(fd, `\n${rule}`);
|
|
200
|
+
}
|
|
201
|
+
finally {
|
|
202
|
+
(0, node_fs_1.closeSync)(fd);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
const STARTER_SQL = `-- UP
|
|
206
|
+
CREATE TABLE users (
|
|
207
|
+
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
|
208
|
+
email VARCHAR(255) NOT NULL UNIQUE,
|
|
209
|
+
display_name VARCHAR(255)
|
|
210
|
+
) COLLATE utf8mb4_0900_bin;
|
|
211
|
+
|
|
212
|
+
-- DOWN
|
|
213
|
+
DROP TABLE users;
|
|
214
|
+
`;
|
|
215
|
+
/** Additive scaffolding. Never creates a database or applies SQL, even with --force. */
|
|
216
|
+
async function initMysqlProject(config, args = {}) {
|
|
217
|
+
// Probe before writing anything; inspect the complete catalog before choosing a starter.
|
|
218
|
+
const catalog = await introspectMysqlProject({ ...config, include: [], exclude: [], relationNames: undefined }, args);
|
|
219
|
+
const created = [];
|
|
220
|
+
if (!(0, config_js_1.findConfigFile)())
|
|
221
|
+
createFile('turbine.config.ts', mysqlConfigTemplate(config), created);
|
|
222
|
+
// Establish the ignore rule before writing a URL that might contain a password.
|
|
223
|
+
ignoreEnvFile(created);
|
|
224
|
+
createFile('.env', `DATABASE_URL=${JSON.stringify(config.url)}\n`, created);
|
|
225
|
+
createFile('.env.example', 'DATABASE_URL=mysql://user:password@localhost:3306/app\n', created);
|
|
226
|
+
(0, node_fs_1.mkdirSync)(config.migrationsDir, { recursive: true });
|
|
227
|
+
if (!Object.keys(catalog.tables).length &&
|
|
228
|
+
!args.skipSchema &&
|
|
229
|
+
!(0, node_fs_1.readdirSync)(config.migrationsDir).some((file) => file.endsWith('.sql'))) {
|
|
230
|
+
const timestamp = new Date().toISOString().replace(/\D/g, '').slice(0, 14);
|
|
231
|
+
createFile((0, node_path_1.join)(config.migrationsDir, `${timestamp}_create_users.sql`), STARTER_SQL, created);
|
|
232
|
+
}
|
|
233
|
+
const occupied = ['index.ts', 'types.ts', 'metadata.ts', 'zod.ts'].some((file) => (0, node_fs_1.existsSync)((0, node_path_1.resolve)(config.out, file)));
|
|
234
|
+
const generated = Object.keys(catalog.tables).length && !args.skipGenerate && !occupied
|
|
235
|
+
? await generateMysqlProject(config, args)
|
|
236
|
+
: undefined;
|
|
237
|
+
return { created, ...(generated ? { generated } : {}) };
|
|
238
|
+
}
|
|
239
|
+
async function cmdMysqlInit(args, config) {
|
|
240
|
+
(0, ui_js_1.banner)();
|
|
241
|
+
const result = await initMysqlProject(config, args);
|
|
242
|
+
(0, ui_js_1.label)('MySQL database', (0, ui_js_1.redactUrl)(config.url));
|
|
243
|
+
for (const path of result.created)
|
|
244
|
+
(0, ui_js_1.success)(`Created ${(0, introspect_js_1.printableCatalogName)(path)}`);
|
|
245
|
+
if (result.generated)
|
|
246
|
+
(0, ui_js_1.success)(`Generated ${result.generated.files.join(', ')} in ${(0, introspect_js_1.printableCatalogName)(result.generated.outDir)}`);
|
|
247
|
+
(0, ui_js_1.info)('Existing files are preserved, including with --force. Check DATABASE_URL in your environment or .env.');
|
|
248
|
+
(0, ui_js_1.info)('Init never applies SQL. Apply schema changes with native MySQL tooling, then run turbine generate.');
|
|
249
|
+
}
|
|
250
|
+
async function cmdMysqlGenerate(args, config) {
|
|
251
|
+
(0, ui_js_1.banner)();
|
|
252
|
+
const result = await generateMysqlProject(config, args);
|
|
253
|
+
(0, ui_js_1.label)('MySQL database', (0, ui_js_1.redactUrl)(config.url));
|
|
254
|
+
(0, ui_js_1.success)(`Found ${Object.keys(result.schema.tables).length} tables`);
|
|
255
|
+
(0, ui_js_1.success)(`Generated ${result.files.join(', ')} in ${(0, introspect_js_1.printableCatalogName)(result.outDir)}`);
|
|
256
|
+
}
|
|
257
|
+
async function cmdMysqlStatus(args, config) {
|
|
258
|
+
(0, ui_js_1.banner)();
|
|
259
|
+
const schema = await introspectMysqlProject(config, args);
|
|
260
|
+
(0, ui_js_1.label)('MySQL database', (0, ui_js_1.redactUrl)(config.url));
|
|
261
|
+
(0, ui_js_1.label)('Tables', String(Object.keys(schema.tables).length));
|
|
262
|
+
for (const table of Object.values(schema.tables)) {
|
|
263
|
+
(0, ui_js_1.label)((0, introspect_js_1.printableCatalogName)(table.name), `${table.columns.length} columns, ${Object.keys(table.relations).length} relations`);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
function showMysqlHelp() {
|
|
267
|
+
console.log(`MySQL SQL-first project commands (mysql2 optional peer required):
|
|
268
|
+
turbine init --engine mysql --url mysql://user:password@host:3306/database
|
|
269
|
+
turbine pull --engine mysql
|
|
270
|
+
turbine generate --engine mysql [--include users] [--exclude audit] [--allow-empty]
|
|
271
|
+
turbine status --engine mysql
|
|
272
|
+
turbine push --engine mysql --dry-run [--exit-code]
|
|
273
|
+
turbine push --engine mysql --yes [--allow-destructive]
|
|
274
|
+
turbine seed --engine mysql
|
|
275
|
+
|
|
276
|
+
Config: engine: 'mysql', url: process.env.DATABASE_URL; database comes from the URL.
|
|
277
|
+
Generation: --out, --import-ext, --keep-column-names, --no-timestamp, --zod.
|
|
278
|
+
Init preserves files and never applies SQL. Use turbine migrate --engine mysql --help for native SQL migrations.
|
|
279
|
+
MySQL diff --schema-file path [--exit-code] compares a conservative SchemaDef subset without writes.
|
|
280
|
+
Use migrate create <name> --from-diff --schema-file path to scaffold reviewed native SQL.
|
|
281
|
+
Seeds are explicit trusted DML callbacks; use turbine seed --engine mysql --help for rollback limits.
|
|
282
|
+
Journaled push preserves a SQL migration before execution; use turbine push --engine mysql --help.
|
|
283
|
+
Views and automatic seeding are unavailable.`);
|
|
284
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SchemaDef } from '../schema-builder.js';
|
|
2
|
+
import type { ResolvedConfig } from './config.js';
|
|
3
|
+
import type { CliArgs } from './index.js';
|
|
4
|
+
/** Validate original operands before a swallowed --dry-run can become an apply. */
|
|
5
|
+
export declare function assertMysqlPushArguments(args: CliArgs, argv: readonly string[]): void;
|
|
6
|
+
export declare function showMysqlPushHelp(): void;
|
|
7
|
+
export declare function cmdMysqlPush(args: CliArgs, config: ResolvedConfig, loadSchema: (path: string) => Promise<SchemaDef>, argv?: readonly string[]): Promise<void>;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assertMysqlPushArguments = assertMysqlPushArguments;
|
|
4
|
+
exports.showMysqlPushHelp = showMysqlPushHelp;
|
|
5
|
+
exports.cmdMysqlPush = cmdMysqlPush;
|
|
6
|
+
/** MySQL push argument boundary and CLI presentation; shared dispatch supplies the loader. */
|
|
7
|
+
const errors_js_1 = require("../errors.js");
|
|
8
|
+
const introspect_js_1 = require("../introspect.js");
|
|
9
|
+
const mysql_push_js_1 = require("./mysql-push.js");
|
|
10
|
+
const mysql_schema_command_js_1 = require("./mysql-schema-command.js");
|
|
11
|
+
const ui_js_1 = require("./ui.js");
|
|
12
|
+
/** Validate original operands before a swallowed --dry-run can become an apply. */
|
|
13
|
+
function assertMysqlPushArguments(args, argv) {
|
|
14
|
+
const keys = new Set([
|
|
15
|
+
'command',
|
|
16
|
+
'positional',
|
|
17
|
+
'engine',
|
|
18
|
+
'url',
|
|
19
|
+
'schema',
|
|
20
|
+
'schemaFile',
|
|
21
|
+
'dryRun',
|
|
22
|
+
'yes',
|
|
23
|
+
'allowDestructive',
|
|
24
|
+
'exitCode',
|
|
25
|
+
'help',
|
|
26
|
+
]);
|
|
27
|
+
for (const [key, value] of Object.entries(args))
|
|
28
|
+
if (value !== undefined && !keys.has(key))
|
|
29
|
+
throw new errors_js_1.ValidationError(`Unsupported MySQL push option: ${key}.`);
|
|
30
|
+
if (args.command !== 'push' || args.positional.length)
|
|
31
|
+
throw new errors_js_1.ValidationError('Usage: turbine push --engine mysql (--dry-run | --yes) [--allow-destructive].');
|
|
32
|
+
if (args.engine !== undefined && args.engine !== 'mysql')
|
|
33
|
+
throw new errors_js_1.ValidationError('MySQL push requires engine mysql.');
|
|
34
|
+
const operands = new Set(['--engine', '--url', '-u', '--schema', '-s', '--schema-file']);
|
|
35
|
+
const flags = new Set(['--dry-run', '--yes', '-y', '--allow-destructive', '--exit-code', '--help', '-h']);
|
|
36
|
+
for (let i = 1; i < argv.length; i++) {
|
|
37
|
+
const token = argv[i];
|
|
38
|
+
if (operands.has(token)) {
|
|
39
|
+
const operand = argv[++i];
|
|
40
|
+
if (!operand?.trim() || operand.startsWith('-'))
|
|
41
|
+
throw new errors_js_1.ValidationError(`MySQL push ${token} requires an explicit non-flag operand.`);
|
|
42
|
+
}
|
|
43
|
+
else if (token.startsWith('-') && !flags.has(token))
|
|
44
|
+
throw new errors_js_1.ValidationError(`Unsupported MySQL push flag: ${(0, introspect_js_1.printableCatalogName)(token)}.`);
|
|
45
|
+
else if (!token.startsWith('-'))
|
|
46
|
+
throw new errors_js_1.ValidationError('Unexpected MySQL push operand.');
|
|
47
|
+
}
|
|
48
|
+
if (args.help)
|
|
49
|
+
return;
|
|
50
|
+
if ((args.dryRun === true) === (args.yes === true))
|
|
51
|
+
throw new errors_js_1.ValidationError('MySQL push requires exactly one of --dry-run or --yes (explicit apply).');
|
|
52
|
+
if (args.yes && args.engine !== 'mysql')
|
|
53
|
+
throw new errors_js_1.ValidationError('MySQL push --yes requires explicit --engine mysql.');
|
|
54
|
+
if (args.exitCode && !args.dryRun)
|
|
55
|
+
throw new errors_js_1.ValidationError('MySQL push --exit-code requires --dry-run.');
|
|
56
|
+
}
|
|
57
|
+
function showMysqlPushHelp() {
|
|
58
|
+
(0, ui_js_1.info)(`MySQL conservative schema push:
|
|
59
|
+
turbine push --engine mysql --dry-run [--exit-code] [--schema-file path]
|
|
60
|
+
turbine push --engine mysql --yes [--allow-destructive] [--schema-file path]
|
|
61
|
+
Requires clean history and a complete supported schema. Preview writes nothing.
|
|
62
|
+
Apply preserves one ordinary SQL migration and uses the native partial-DDL journal.
|
|
63
|
+
Every ALTER requires separate --allow-destructive consent. DDL is not atomic.
|
|
64
|
+
Stop external schema changes; the cooperative runner lock is not a DDL lock.
|
|
65
|
+
Failures preserve files and dirty state; inspect and manually reconcile before migrate recover.`);
|
|
66
|
+
}
|
|
67
|
+
async function cmdMysqlPush(args, config, loadSchema, argv = process.argv.slice(2)) {
|
|
68
|
+
assertMysqlPushArguments(args, argv);
|
|
69
|
+
if (args.help)
|
|
70
|
+
return showMysqlPushHelp();
|
|
71
|
+
if (config.engine !== 'mysql')
|
|
72
|
+
throw new errors_js_1.ValidationError('MySQL push requires engine mysql.');
|
|
73
|
+
(0, mysql_schema_command_js_1.assertMysqlSchemaConfig)(config);
|
|
74
|
+
const result = await (0, mysql_push_js_1.pushMysqlSchema)(config.url, config.migrationsDir, await loadSchema(config.schemaFile), {
|
|
75
|
+
dryRun: args.dryRun,
|
|
76
|
+
apply: args.yes,
|
|
77
|
+
allowDestructive: args.allowDestructive,
|
|
78
|
+
});
|
|
79
|
+
(0, ui_js_1.label)('MySQL database', (0, introspect_js_1.printableCatalogName)(result.plan.database));
|
|
80
|
+
(0, ui_js_1.label)('Catalog fingerprint', result.plan.fingerprint);
|
|
81
|
+
if (!result.plan.steps.length)
|
|
82
|
+
return (0, ui_js_1.success)('No supported schema changes; no migration file created.');
|
|
83
|
+
if (args.dryRun) {
|
|
84
|
+
console.log(result.plan.up);
|
|
85
|
+
(0, ui_js_1.info)('Dry run: no files, history or schema changes made.');
|
|
86
|
+
if (result.plan.requiresAlterConsent)
|
|
87
|
+
(0, ui_js_1.info)('Apply requires --yes and --allow-destructive for every ALTER.');
|
|
88
|
+
if (args.exitCode)
|
|
89
|
+
process.exitCode = 2;
|
|
90
|
+
}
|
|
91
|
+
else
|
|
92
|
+
(0, ui_js_1.success)(`Applied journaled migration ${(0, introspect_js_1.printableCatalogName)(result.file.filename)}.`);
|
|
93
|
+
(0, ui_js_1.warn)('Catalog checks are advisory, not a DDL lock. MySQL DDL implicitly commits; partial effects may remain.');
|
|
94
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { SchemaDef } from '../schema-builder.js';
|
|
2
|
+
import { type MigrationFile } from './migrate.js';
|
|
3
|
+
import { type MysqlSchemaPlan } from './mysql-schema.js';
|
|
4
|
+
export interface MysqlPushOptions {
|
|
5
|
+
/** Exactly one of dryRun or apply must be true. */
|
|
6
|
+
dryRun?: boolean;
|
|
7
|
+
apply?: boolean;
|
|
8
|
+
allowDestructive?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface MysqlPushResult {
|
|
11
|
+
plan: MysqlSchemaPlan;
|
|
12
|
+
file?: MigrationFile;
|
|
13
|
+
}
|
|
14
|
+
/** No preview effects; apply persists one immutable SQL file before journaled execution. */
|
|
15
|
+
export declare function pushMysqlSchema(url: string, migrationsDir: string, schema: SchemaDef, options: MysqlPushOptions): Promise<MysqlPushResult>;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pushMysqlSchema = pushMysqlSchema;
|
|
4
|
+
/** Conservative schema push through the ordinary native migration journal. */
|
|
5
|
+
const node_crypto_1 = require("node:crypto");
|
|
6
|
+
const node_fs_1 = require("node:fs");
|
|
7
|
+
const errors_js_1 = require("../errors.js");
|
|
8
|
+
const migrate_js_1 = require("./migrate.js");
|
|
9
|
+
const mysql_migrate_js_1 = require("./mysql-migrate.js");
|
|
10
|
+
const mysql_schema_js_1 = require("./mysql-schema.js");
|
|
11
|
+
const mysql_schema_ddl_js_1 = require("./mysql-schema-ddl.js");
|
|
12
|
+
const mysql_schema_snapshot_js_1 = require("./mysql-schema-snapshot.js");
|
|
13
|
+
const sha = (bytes) => (0, node_crypto_1.createHash)('sha256').update(bytes).digest('hex');
|
|
14
|
+
function inventory(dir) {
|
|
15
|
+
if ((0, migrate_js_1.listIgnoredSqlFiles)(dir).length)
|
|
16
|
+
throw new errors_js_1.MigrationError('MySQL push refuses ignored SQL files in the migrations directory.');
|
|
17
|
+
return JSON.stringify((0, migrate_js_1.listMigrationFiles)(dir).map((file) => [file.filename, sha((0, node_fs_1.readFileSync)(file.path))]));
|
|
18
|
+
}
|
|
19
|
+
function clean(history) {
|
|
20
|
+
if (history.dirty || history.pending.length || history.mismatches.length)
|
|
21
|
+
throw new errors_js_1.MigrationError('MySQL push requires clean migration history: dirty, pending, drifted or missing files must be reconciled explicitly first.');
|
|
22
|
+
}
|
|
23
|
+
// Metadata tables may first appear when the runner initializes its journal.
|
|
24
|
+
function catalog(snapshot) {
|
|
25
|
+
const excluded = new Set(mysql_schema_snapshot_js_1.MYSQL_SCHEMA_EXCLUDED);
|
|
26
|
+
return JSON.stringify(Object.fromEntries(Object.entries(snapshot.facts).map(([key, rows]) => [
|
|
27
|
+
key,
|
|
28
|
+
rows.filter((row) => !excluded.has(String(row.TABLE_NAME))),
|
|
29
|
+
])));
|
|
30
|
+
}
|
|
31
|
+
function syncPath(path) {
|
|
32
|
+
const fd = (0, node_fs_1.openSync)(path, 'r');
|
|
33
|
+
try {
|
|
34
|
+
(0, node_fs_1.fsyncSync)(fd);
|
|
35
|
+
}
|
|
36
|
+
finally {
|
|
37
|
+
(0, node_fs_1.closeSync)(fd);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/** No preview effects; apply persists one immutable SQL file before journaled execution. */
|
|
41
|
+
async function pushMysqlSchema(url, migrationsDir, schema, options) {
|
|
42
|
+
if ((options.dryRun === true) === (options.apply === true))
|
|
43
|
+
throw new errors_js_1.ValidationError('MySQL push requires exactly one of --dry-run or --yes (explicit apply).');
|
|
44
|
+
if (typeof migrationsDir !== 'string' || !migrationsDir.trim() || migrationsDir.includes('\0'))
|
|
45
|
+
throw new errors_js_1.ValidationError('MySQL push requires a nonempty migrations directory path.');
|
|
46
|
+
(0, mysql_schema_ddl_js_1.modelMysqlSchema)(schema);
|
|
47
|
+
return (0, mysql_migrate_js_1.withMysqlMigrationWorkspace)(url, migrationsDir, { allowDestructive: options.allowDestructive }, async (workspace) => {
|
|
48
|
+
const originalFiles = inventory(migrationsDir);
|
|
49
|
+
clean(await workspace.inspect());
|
|
50
|
+
const snapshot = await (0, mysql_schema_js_1.inspectMysqlSchema)(url);
|
|
51
|
+
const plan = (0, mysql_schema_js_1.planMysqlSchema)(schema, snapshot);
|
|
52
|
+
if (inventory(migrationsDir) !== originalFiles)
|
|
53
|
+
throw new errors_js_1.MigrationError('MySQL push migration files changed during planning.');
|
|
54
|
+
clean(await workspace.inspect());
|
|
55
|
+
if (options.dryRun || !plan.steps.length)
|
|
56
|
+
return { plan };
|
|
57
|
+
if (plan.requiresAlterConsent && options.allowDestructive !== true)
|
|
58
|
+
throw new errors_js_1.MigrationError('Every MySQL ALTER requires --allow-destructive, including additive ALTER.');
|
|
59
|
+
const before = await (0, mysql_schema_js_1.inspectMysqlSchema)(url);
|
|
60
|
+
if (catalog(before) !== catalog(snapshot))
|
|
61
|
+
throw new errors_js_1.MigrationError('MySQL push catalog changed before persistence; no migration was created.');
|
|
62
|
+
if (inventory(migrationsDir) !== originalFiles)
|
|
63
|
+
throw new errors_js_1.MigrationError('MySQL push migration files changed before persistence.');
|
|
64
|
+
// Shared writer uses exclusive wx creation. Never overwrite or remove any file,
|
|
65
|
+
// including this one after a later failure. Random suffix avoids clock collisions.
|
|
66
|
+
const file = (0, migrate_js_1.createMigration)(migrationsDir, `schema_push_${(0, node_crypto_1.randomBytes)(6).toString('hex')}`, plan, {
|
|
67
|
+
header: `-- MySQL catalog fingerprint: ${plan.fingerprint}\n-- DOWN can delete data. Every ALTER requires --allow-destructive.\n-- MySQL DDL implicitly commits; inspect partial state and recover manually.`,
|
|
68
|
+
});
|
|
69
|
+
const content = (0, node_fs_1.readFileSync)(file.path, 'utf8');
|
|
70
|
+
const sections = (0, migrate_js_1.parseMigrationContent)(content, file.path);
|
|
71
|
+
if (sections.up !== plan.up.trim() || sections.down !== plan.down.trim())
|
|
72
|
+
throw new errors_js_1.MigrationError('MySQL push scaffold changed before it could be frozen.');
|
|
73
|
+
syncPath(file.path);
|
|
74
|
+
syncPath(migrationsDir);
|
|
75
|
+
const expectedFiles = JSON.parse(originalFiles);
|
|
76
|
+
const checksum = sha(content);
|
|
77
|
+
expectedFiles.push([file.filename, checksum]);
|
|
78
|
+
expectedFiles.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
|
|
79
|
+
const frozen = JSON.stringify(expectedFiles);
|
|
80
|
+
const result = await workspace.apply({ name: file.name, checksum }, async (completed) => {
|
|
81
|
+
if (inventory(migrationsDir) !== frozen)
|
|
82
|
+
throw new errors_js_1.MigrationError('MySQL push migration files changed; preserved the scaffold for inspection.');
|
|
83
|
+
const current = await (0, mysql_schema_js_1.inspectMysqlSchema)(url);
|
|
84
|
+
if (completed === 0 && catalog(current) !== catalog(snapshot))
|
|
85
|
+
throw new errors_js_1.MigrationError('MySQL push catalog changed before execution.');
|
|
86
|
+
const remaining = (0, mysql_schema_js_1.planMysqlSchema)(schema, current);
|
|
87
|
+
if (remaining.up !==
|
|
88
|
+
plan.steps
|
|
89
|
+
.slice(completed)
|
|
90
|
+
.map((step) => step.sql)
|
|
91
|
+
.join('\n'))
|
|
92
|
+
throw new errors_js_1.MigrationError('MySQL push catalog no longer matches the remaining planned statements.');
|
|
93
|
+
});
|
|
94
|
+
if (result.errors.length)
|
|
95
|
+
throw new errors_js_1.MigrationError(`${result.errors.map((entry) => entry.error).join('\n')} Preserved migration: ${file.filename}.`);
|
|
96
|
+
return { plan, file };
|
|
97
|
+
});
|
|
98
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SchemaDef } from '../schema-builder.js';
|
|
2
|
+
import { type ResolvedConfig } from './config.js';
|
|
3
|
+
import type { CliArgs } from './index.js';
|
|
4
|
+
export declare function assertMysqlSchemaConfig(config: ResolvedConfig): void;
|
|
5
|
+
export declare function cmdMysqlSchema(args: CliArgs, config: ResolvedConfig, loadSchema: (path: string) => Promise<SchemaDef>, argv?: readonly string[]): Promise<void>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assertMysqlSchemaConfig = assertMysqlSchemaConfig;
|
|
4
|
+
exports.cmdMysqlSchema = cmdMysqlSchema;
|
|
5
|
+
/** CLI presentation for a read-only MySQL diff. Shared dispatch is injected by the CLI. */
|
|
6
|
+
const errors_js_1 = require("../errors.js");
|
|
7
|
+
const config_js_1 = require("./config.js");
|
|
8
|
+
const mysql_schema_js_1 = require("./mysql-schema.js");
|
|
9
|
+
const mysql_schema_ddl_js_1 = require("./mysql-schema-ddl.js");
|
|
10
|
+
const ui_js_1 = require("./ui.js");
|
|
11
|
+
function assertMysqlSchemaConfig(config) {
|
|
12
|
+
if (config.adapter || config.include.length || config.exclude.length)
|
|
13
|
+
throw new errors_js_1.ValidationError('MySQL schema comparison requires engine mysql, no adapter and the complete schema without include/exclude filters.');
|
|
14
|
+
(0, config_js_1.validateCliEngineUrl)((0, config_js_1.resolveCliEngine)(config.engine), config.url);
|
|
15
|
+
if (!config.url || (0, config_js_1.mysqlDatabaseFromUrl)(config.url) !== config.schema)
|
|
16
|
+
throw new errors_js_1.ValidationError('MySQL schema comparison needs a URL selecting the configured database.');
|
|
17
|
+
if (!config.schemaFile?.trim() || config.schemaFile.includes('\0'))
|
|
18
|
+
throw new errors_js_1.ValidationError('MySQL schema comparison requires a schema file path.');
|
|
19
|
+
}
|
|
20
|
+
async function cmdMysqlSchema(args, config, loadSchema, argv = process.argv.slice(2)) {
|
|
21
|
+
const keys = new Set(['command', 'positional', 'engine', 'url', 'schema', 'schemaFile', 'exitCode', 'help']);
|
|
22
|
+
for (const [key, value] of Object.entries(args))
|
|
23
|
+
if (value !== undefined && !keys.has(key))
|
|
24
|
+
throw new errors_js_1.ValidationError(`Unsupported MySQL diff option: ${key}.`);
|
|
25
|
+
if (args.command !== 'diff' || args.positional.length)
|
|
26
|
+
throw new errors_js_1.ValidationError('Usage: turbine diff --engine mysql [--schema-file path] [--exit-code].');
|
|
27
|
+
const operands = new Set(['--engine', '--url', '-u', '--schema', '-s', '--schema-file']);
|
|
28
|
+
const flags = new Set(['--exit-code', '--help', '-h']);
|
|
29
|
+
for (let i = 1; i < argv.length; i++) {
|
|
30
|
+
const token = argv[i];
|
|
31
|
+
if (operands.has(token)) {
|
|
32
|
+
const value = argv[++i];
|
|
33
|
+
if (!value?.trim() || value.startsWith('-'))
|
|
34
|
+
throw new errors_js_1.ValidationError(`MySQL diff ${token} requires an explicit operand.`);
|
|
35
|
+
}
|
|
36
|
+
else if (token.startsWith('-') && !flags.has(token))
|
|
37
|
+
throw new errors_js_1.ValidationError(`Unsupported MySQL diff flag: ${token}.`);
|
|
38
|
+
}
|
|
39
|
+
assertMysqlSchemaConfig(config);
|
|
40
|
+
const schema = await loadSchema(config.schemaFile);
|
|
41
|
+
(0, mysql_schema_ddl_js_1.modelMysqlSchema)(schema);
|
|
42
|
+
const plan = (0, mysql_schema_js_1.planMysqlSchema)(schema, await (0, mysql_schema_js_1.inspectMysqlSchema)(config.url));
|
|
43
|
+
(0, ui_js_1.label)('MySQL database', plan.database);
|
|
44
|
+
(0, ui_js_1.label)('Catalog fingerprint', plan.fingerprint);
|
|
45
|
+
if (!plan.steps.length)
|
|
46
|
+
(0, ui_js_1.success)('No supported schema changes.');
|
|
47
|
+
else {
|
|
48
|
+
for (const step of plan.steps) {
|
|
49
|
+
(0, ui_js_1.info)(`${step.kind}: ${step.table}`);
|
|
50
|
+
console.log(step.sql);
|
|
51
|
+
}
|
|
52
|
+
(0, ui_js_1.info)('Read-only comparison. Create a reviewed SQL migration with migrate create <name> --from-diff --engine mysql.');
|
|
53
|
+
if (plan.requiresAlterConsent)
|
|
54
|
+
(0, ui_js_1.info)('The native runner requires --allow-destructive for every ALTER, including additions.');
|
|
55
|
+
if (args.exitCode)
|
|
56
|
+
process.exitCode = 2;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { SchemaDef } from '../schema-builder.js';
|
|
2
|
+
export declare const MYSQL_SCHEMA_COLLATION = "utf8mb4_0900_bin";
|
|
3
|
+
export interface MysqlColumn {
|
|
4
|
+
name: string;
|
|
5
|
+
type: string;
|
|
6
|
+
nullable: boolean;
|
|
7
|
+
auto: boolean;
|
|
8
|
+
defaultValue: string | null;
|
|
9
|
+
defaultSql: string | null;
|
|
10
|
+
text: boolean;
|
|
11
|
+
sql: string;
|
|
12
|
+
}
|
|
13
|
+
export interface MysqlIndex {
|
|
14
|
+
name: string;
|
|
15
|
+
columns: string[];
|
|
16
|
+
unique: boolean;
|
|
17
|
+
explicit: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface MysqlForeignKey {
|
|
20
|
+
name: string;
|
|
21
|
+
column: string;
|
|
22
|
+
targetTable: string;
|
|
23
|
+
targetColumn: string;
|
|
24
|
+
onDelete: string;
|
|
25
|
+
onUpdate: string;
|
|
26
|
+
}
|
|
27
|
+
export interface MysqlTable {
|
|
28
|
+
name: string;
|
|
29
|
+
columns: MysqlColumn[];
|
|
30
|
+
primary: string[];
|
|
31
|
+
indexes: MysqlIndex[];
|
|
32
|
+
foreignKeys: MysqlForeignKey[];
|
|
33
|
+
}
|
|
34
|
+
export declare function mysqlSchemaRefusal(reason: string): never;
|
|
35
|
+
export declare function quoteMysqlSchemaName(name: string): string;
|
|
36
|
+
export declare function modelMysqlSchema(schema: SchemaDef): MysqlTable[];
|
|
37
|
+
export declare function mysqlIndexDefinition(index: MysqlIndex): string;
|