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,272 @@
|
|
|
1
|
+
/** SQL-first MySQL project commands backed by the optional native introspector. */
|
|
2
|
+
import { appendFileSync, closeSync, constants, existsSync, mkdirSync, openSync, readdirSync, readFileSync, writeFileSync, } from 'node:fs';
|
|
3
|
+
import { dirname, join, resolve } from 'node:path';
|
|
4
|
+
import { ValidationError } from '../errors.js';
|
|
5
|
+
import { generate } from '../generate.js';
|
|
6
|
+
import { applyRelationRenames, assertSafeCatalogSchema, printableCatalogName as shown } from '../introspect.js';
|
|
7
|
+
import { introspectMysql } from '../mysql.js';
|
|
8
|
+
import { findConfigFile, mysqlDatabaseFromUrl, resolveCliEngine } from './config.js';
|
|
9
|
+
import { isWriteRefusal } from './no-follow.js';
|
|
10
|
+
import { banner, info, label, redactUrl, success } from './ui.js';
|
|
11
|
+
function checkConfig(config, args) {
|
|
12
|
+
if (resolveCliEngine(config.engine) !== 'mysql') {
|
|
13
|
+
throw new ValidationError('MySQL project commands require engine "mysql".');
|
|
14
|
+
}
|
|
15
|
+
let database;
|
|
16
|
+
try {
|
|
17
|
+
database = mysqlDatabaseFromUrl(config.url);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
throw new ValidationError(error.message);
|
|
21
|
+
}
|
|
22
|
+
if (config.schema !== database)
|
|
23
|
+
throw new ValidationError('MySQL CLI schema must match the database in its URL.');
|
|
24
|
+
if (config.adapter !== undefined)
|
|
25
|
+
throw new ValidationError('PostgreSQL adapters cannot be used with MySQL.');
|
|
26
|
+
for (const key of ['include', 'exclude']) {
|
|
27
|
+
if (!Array.isArray(config[key]) || !config[key].every((value) => typeof value === 'string' && value.length > 0)) {
|
|
28
|
+
throw new ValidationError(`MySQL config ${key} must be an array of nonempty table names.`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
for (const key of ['out', 'migrationsDir']) {
|
|
32
|
+
if (typeof config[key] !== 'string' || !config[key].trim() || config[key].includes('\0')) {
|
|
33
|
+
throw new ValidationError(`MySQL config ${key} must be a nonempty path.`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (!['auto', 'js', 'ts', 'none'].includes(config.importExtension)) {
|
|
37
|
+
throw new ValidationError('MySQL config importExtension must be auto, js, ts, or none.');
|
|
38
|
+
}
|
|
39
|
+
if (typeof config.keepColumnNames !== 'boolean' || typeof config.legacyToManyUniques !== 'boolean') {
|
|
40
|
+
throw new ValidationError('MySQL config keepColumnNames and legacyToManyUniques must be booleans.');
|
|
41
|
+
}
|
|
42
|
+
if (config.columnTypes !== undefined &&
|
|
43
|
+
(!config.columnTypes ||
|
|
44
|
+
typeof config.columnTypes !== 'object' ||
|
|
45
|
+
Array.isArray(config.columnTypes) ||
|
|
46
|
+
!Object.values(config.columnTypes).every((value) => typeof value === 'string' && value.trim()))) {
|
|
47
|
+
throw new ValidationError('MySQL config columnTypes must map database columns to nonempty TypeScript type strings.');
|
|
48
|
+
}
|
|
49
|
+
if (config.relationNames !== undefined &&
|
|
50
|
+
(!config.relationNames ||
|
|
51
|
+
typeof config.relationNames !== 'object' ||
|
|
52
|
+
Array.isArray(config.relationNames) ||
|
|
53
|
+
!Object.values(config.relationNames).every((names) => names &&
|
|
54
|
+
typeof names === 'object' &&
|
|
55
|
+
!Array.isArray(names) &&
|
|
56
|
+
Object.values(names).every((name) => typeof name === 'string' && name.length > 0)))) {
|
|
57
|
+
throw new ValidationError('MySQL config relationNames must map tables to relation rename maps.');
|
|
58
|
+
}
|
|
59
|
+
if (args.includeViews)
|
|
60
|
+
throw new ValidationError('MySQL CLI introspection does not support --include-views yet.');
|
|
61
|
+
if (args.withSchema || config.schemaFileConfigured) {
|
|
62
|
+
throw new ValidationError('MySQL CLI projects use SQL migrations, not schemaFile or --with-schema.');
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/** Refuse every unsupported command before reaching PostgreSQL handlers. */
|
|
66
|
+
export function assertMysqlProjectCommand(command) {
|
|
67
|
+
if (['init', 'generate', 'gen', 'g', 'pull', 'status', 'info', 'migrate', 'migration', 'm'].includes(command))
|
|
68
|
+
return;
|
|
69
|
+
throw new ValidationError(`Command "${command}" is not supported for MySQL. Supported commands: init, pull, generate, status, migrate.`);
|
|
70
|
+
}
|
|
71
|
+
/** Read the native MySQL catalog and release its short-lived pool on all paths. */
|
|
72
|
+
export async function introspectMysqlProject(config, args = {}) {
|
|
73
|
+
checkConfig(config, args);
|
|
74
|
+
const metadata = await introspectMysql({
|
|
75
|
+
connectionString: config.url,
|
|
76
|
+
schema: config.schema,
|
|
77
|
+
include: config.include,
|
|
78
|
+
legacyToManyUniques: config.legacyToManyUniques,
|
|
79
|
+
// The native migration runner journals partial DDL separately from history.
|
|
80
|
+
exclude: config.include.includes('_turbine_migration_state')
|
|
81
|
+
? config.exclude
|
|
82
|
+
: [...config.exclude, '_turbine_migration_state'],
|
|
83
|
+
});
|
|
84
|
+
const schema = config.relationNames ? applyRelationRenames(metadata, config.relationNames) : metadata;
|
|
85
|
+
assertSafeCatalogSchema(schema);
|
|
86
|
+
return schema;
|
|
87
|
+
}
|
|
88
|
+
/** Generate only after native introspection and validation succeed. */
|
|
89
|
+
export async function generateMysqlProject(config, args = {}) {
|
|
90
|
+
const schema = await introspectMysqlProject(config, args);
|
|
91
|
+
if (Object.keys(schema.tables).length === 0 && !args.allowEmpty) {
|
|
92
|
+
throw new ValidationError('MySQL introspection matched 0 tables; refusing an empty client. Apply SQL, check include/exclude, or pass --allow-empty.');
|
|
93
|
+
}
|
|
94
|
+
let columnTypes = config.columnTypes;
|
|
95
|
+
if (columnTypes && (config.include.length || config.exclude.length)) {
|
|
96
|
+
// Validate excluded overrides against the full catalog so genuine typos still fail.
|
|
97
|
+
const catalog = await introspectMysqlProject({ ...config, include: [], exclude: [], relationNames: undefined }, args);
|
|
98
|
+
columnTypes = Object.fromEntries(Object.entries(columnTypes).filter(([key]) => {
|
|
99
|
+
const table = key.slice(0, key.lastIndexOf('.'));
|
|
100
|
+
const column = key.slice(key.lastIndexOf('.') + 1);
|
|
101
|
+
return Object.hasOwn(schema.tables, table) || !catalog.tables[table]?.columns.some((c) => c.name === column);
|
|
102
|
+
}));
|
|
103
|
+
}
|
|
104
|
+
const result = generate({
|
|
105
|
+
target: 'mysql',
|
|
106
|
+
schema,
|
|
107
|
+
exactNativeIntegers: config.exactNativeIntegers,
|
|
108
|
+
outDir: config.out,
|
|
109
|
+
connectionString: config.url,
|
|
110
|
+
importExtension: config.importExtension,
|
|
111
|
+
keepColumnNames: config.keepColumnNames,
|
|
112
|
+
columnTypes,
|
|
113
|
+
noTimestamp: args.noTimestamp,
|
|
114
|
+
zod: args.zod,
|
|
115
|
+
});
|
|
116
|
+
return { schema, ...result };
|
|
117
|
+
}
|
|
118
|
+
/** Credentials always stay in the environment, never the tracked config. */
|
|
119
|
+
export function mysqlConfigTemplate(config) {
|
|
120
|
+
return `import type { TurbineCliConfig } from 'turbine-orm/cli';
|
|
121
|
+
|
|
122
|
+
const config: TurbineCliConfig = {
|
|
123
|
+
engine: 'mysql',
|
|
124
|
+
url: process.env.DATABASE_URL,
|
|
125
|
+
out: ${JSON.stringify(config.out)},
|
|
126
|
+
migrationsDir: ${JSON.stringify(config.migrationsDir)},
|
|
127
|
+
legacyToManyUniques: ${JSON.stringify(config.legacyToManyUniques)},
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
// Apply schema changes with native MySQL SQL tooling, then turbine generate.
|
|
131
|
+
export default config;
|
|
132
|
+
`;
|
|
133
|
+
}
|
|
134
|
+
function createFile(path, contents, created) {
|
|
135
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
136
|
+
try {
|
|
137
|
+
writeFileSync(path, contents, { encoding: 'utf8', flag: 'wx' });
|
|
138
|
+
created.push(path);
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
if (error.code !== 'EEXIST')
|
|
142
|
+
throw error;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Make `.gitignore` ignore `/.env`. Created only when nothing is at the name;
|
|
147
|
+
* otherwise read and appended through one descriptor, so the file read is the
|
|
148
|
+
* file appended to, and a `.gitignore` that appeared after a separate look is
|
|
149
|
+
* given the rule instead of being skipped before `.env` is written.
|
|
150
|
+
* @internal exported for tests.
|
|
151
|
+
*/
|
|
152
|
+
export function ignoreEnvFile(created) {
|
|
153
|
+
const rule = '# Local database credentials\n/.env\n';
|
|
154
|
+
try {
|
|
155
|
+
writeFileSync('.gitignore', rule, { encoding: 'utf8', flag: 'wx' });
|
|
156
|
+
created.push('.gitignore');
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
if (error.code !== 'EEXIST')
|
|
161
|
+
throw error;
|
|
162
|
+
}
|
|
163
|
+
const lacksRule = (fd) => !/(?:^|\n)\/\.env\s*$/.test(readFileSync(fd, 'utf8').trimEnd());
|
|
164
|
+
let fd;
|
|
165
|
+
try {
|
|
166
|
+
fd = openSync('.gitignore', constants.O_RDWR | constants.O_APPEND);
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
if (error.code === 'ENOENT') {
|
|
170
|
+
throw new ValidationError('.gitignore cannot be read or created (a dangling symlink?). Remove it and run the command again.');
|
|
171
|
+
}
|
|
172
|
+
// A .gitignore that cannot be written but already has the rule needs nothing.
|
|
173
|
+
if (!isWriteRefusal(error))
|
|
174
|
+
throw error;
|
|
175
|
+
const readOnly = openSync('.gitignore', constants.O_RDONLY);
|
|
176
|
+
try {
|
|
177
|
+
if (!lacksRule(readOnly))
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
finally {
|
|
181
|
+
closeSync(readOnly);
|
|
182
|
+
}
|
|
183
|
+
throw error;
|
|
184
|
+
}
|
|
185
|
+
try {
|
|
186
|
+
if (lacksRule(fd))
|
|
187
|
+
appendFileSync(fd, `\n${rule}`);
|
|
188
|
+
}
|
|
189
|
+
finally {
|
|
190
|
+
closeSync(fd);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
const STARTER_SQL = `-- UP
|
|
194
|
+
CREATE TABLE users (
|
|
195
|
+
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
|
196
|
+
email VARCHAR(255) NOT NULL UNIQUE,
|
|
197
|
+
display_name VARCHAR(255)
|
|
198
|
+
) COLLATE utf8mb4_0900_bin;
|
|
199
|
+
|
|
200
|
+
-- DOWN
|
|
201
|
+
DROP TABLE users;
|
|
202
|
+
`;
|
|
203
|
+
/** Additive scaffolding. Never creates a database or applies SQL, even with --force. */
|
|
204
|
+
export async function initMysqlProject(config, args = {}) {
|
|
205
|
+
// Probe before writing anything; inspect the complete catalog before choosing a starter.
|
|
206
|
+
const catalog = await introspectMysqlProject({ ...config, include: [], exclude: [], relationNames: undefined }, args);
|
|
207
|
+
const created = [];
|
|
208
|
+
if (!findConfigFile())
|
|
209
|
+
createFile('turbine.config.ts', mysqlConfigTemplate(config), created);
|
|
210
|
+
// Establish the ignore rule before writing a URL that might contain a password.
|
|
211
|
+
ignoreEnvFile(created);
|
|
212
|
+
createFile('.env', `DATABASE_URL=${JSON.stringify(config.url)}\n`, created);
|
|
213
|
+
createFile('.env.example', 'DATABASE_URL=mysql://user:password@localhost:3306/app\n', created);
|
|
214
|
+
mkdirSync(config.migrationsDir, { recursive: true });
|
|
215
|
+
if (!Object.keys(catalog.tables).length &&
|
|
216
|
+
!args.skipSchema &&
|
|
217
|
+
!readdirSync(config.migrationsDir).some((file) => file.endsWith('.sql'))) {
|
|
218
|
+
const timestamp = new Date().toISOString().replace(/\D/g, '').slice(0, 14);
|
|
219
|
+
createFile(join(config.migrationsDir, `${timestamp}_create_users.sql`), STARTER_SQL, created);
|
|
220
|
+
}
|
|
221
|
+
const occupied = ['index.ts', 'types.ts', 'metadata.ts', 'zod.ts'].some((file) => existsSync(resolve(config.out, file)));
|
|
222
|
+
const generated = Object.keys(catalog.tables).length && !args.skipGenerate && !occupied
|
|
223
|
+
? await generateMysqlProject(config, args)
|
|
224
|
+
: undefined;
|
|
225
|
+
return { created, ...(generated ? { generated } : {}) };
|
|
226
|
+
}
|
|
227
|
+
export async function cmdMysqlInit(args, config) {
|
|
228
|
+
banner();
|
|
229
|
+
const result = await initMysqlProject(config, args);
|
|
230
|
+
label('MySQL database', redactUrl(config.url));
|
|
231
|
+
for (const path of result.created)
|
|
232
|
+
success(`Created ${shown(path)}`);
|
|
233
|
+
if (result.generated)
|
|
234
|
+
success(`Generated ${result.generated.files.join(', ')} in ${shown(result.generated.outDir)}`);
|
|
235
|
+
info('Existing files are preserved, including with --force. Check DATABASE_URL in your environment or .env.');
|
|
236
|
+
info('Init never applies SQL. Apply schema changes with native MySQL tooling, then run turbine generate.');
|
|
237
|
+
}
|
|
238
|
+
export async function cmdMysqlGenerate(args, config) {
|
|
239
|
+
banner();
|
|
240
|
+
const result = await generateMysqlProject(config, args);
|
|
241
|
+
label('MySQL database', redactUrl(config.url));
|
|
242
|
+
success(`Found ${Object.keys(result.schema.tables).length} tables`);
|
|
243
|
+
success(`Generated ${result.files.join(', ')} in ${shown(result.outDir)}`);
|
|
244
|
+
}
|
|
245
|
+
export async function cmdMysqlStatus(args, config) {
|
|
246
|
+
banner();
|
|
247
|
+
const schema = await introspectMysqlProject(config, args);
|
|
248
|
+
label('MySQL database', redactUrl(config.url));
|
|
249
|
+
label('Tables', String(Object.keys(schema.tables).length));
|
|
250
|
+
for (const table of Object.values(schema.tables)) {
|
|
251
|
+
label(shown(table.name), `${table.columns.length} columns, ${Object.keys(table.relations).length} relations`);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
export function showMysqlHelp() {
|
|
255
|
+
console.log(`MySQL SQL-first project commands (mysql2 optional peer required):
|
|
256
|
+
turbine init --engine mysql --url mysql://user:password@host:3306/database
|
|
257
|
+
turbine pull --engine mysql
|
|
258
|
+
turbine generate --engine mysql [--include users] [--exclude audit] [--allow-empty]
|
|
259
|
+
turbine status --engine mysql
|
|
260
|
+
turbine push --engine mysql --dry-run [--exit-code]
|
|
261
|
+
turbine push --engine mysql --yes [--allow-destructive]
|
|
262
|
+
turbine seed --engine mysql
|
|
263
|
+
|
|
264
|
+
Config: engine: 'mysql', url: process.env.DATABASE_URL; database comes from the URL.
|
|
265
|
+
Generation: --out, --import-ext, --keep-column-names, --no-timestamp, --zod.
|
|
266
|
+
Init preserves files and never applies SQL. Use turbine migrate --engine mysql --help for native SQL migrations.
|
|
267
|
+
MySQL diff --schema-file path [--exit-code] compares a conservative SchemaDef subset without writes.
|
|
268
|
+
Use migrate create <name> --from-diff --schema-file path to scaffold reviewed native SQL.
|
|
269
|
+
Seeds are explicit trusted DML callbacks; use turbine seed --engine mysql --help for rollback limits.
|
|
270
|
+
Journaled push preserves a SQL migration before execution; use turbine push --engine mysql --help.
|
|
271
|
+
Views and automatic seeding are unavailable.`);
|
|
272
|
+
}
|
|
@@ -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,89 @@
|
|
|
1
|
+
/** MySQL push argument boundary and CLI presentation; shared dispatch supplies the loader. */
|
|
2
|
+
import { ValidationError } from '../errors.js';
|
|
3
|
+
import { printableCatalogName as shown } from '../introspect.js';
|
|
4
|
+
import { pushMysqlSchema } from './mysql-push.js';
|
|
5
|
+
import { assertMysqlSchemaConfig } from './mysql-schema-command.js';
|
|
6
|
+
import { info, label, success, warn } from './ui.js';
|
|
7
|
+
/** Validate original operands before a swallowed --dry-run can become an apply. */
|
|
8
|
+
export function assertMysqlPushArguments(args, argv) {
|
|
9
|
+
const keys = new Set([
|
|
10
|
+
'command',
|
|
11
|
+
'positional',
|
|
12
|
+
'engine',
|
|
13
|
+
'url',
|
|
14
|
+
'schema',
|
|
15
|
+
'schemaFile',
|
|
16
|
+
'dryRun',
|
|
17
|
+
'yes',
|
|
18
|
+
'allowDestructive',
|
|
19
|
+
'exitCode',
|
|
20
|
+
'help',
|
|
21
|
+
]);
|
|
22
|
+
for (const [key, value] of Object.entries(args))
|
|
23
|
+
if (value !== undefined && !keys.has(key))
|
|
24
|
+
throw new ValidationError(`Unsupported MySQL push option: ${key}.`);
|
|
25
|
+
if (args.command !== 'push' || args.positional.length)
|
|
26
|
+
throw new ValidationError('Usage: turbine push --engine mysql (--dry-run | --yes) [--allow-destructive].');
|
|
27
|
+
if (args.engine !== undefined && args.engine !== 'mysql')
|
|
28
|
+
throw new ValidationError('MySQL push requires engine mysql.');
|
|
29
|
+
const operands = new Set(['--engine', '--url', '-u', '--schema', '-s', '--schema-file']);
|
|
30
|
+
const flags = new Set(['--dry-run', '--yes', '-y', '--allow-destructive', '--exit-code', '--help', '-h']);
|
|
31
|
+
for (let i = 1; i < argv.length; i++) {
|
|
32
|
+
const token = argv[i];
|
|
33
|
+
if (operands.has(token)) {
|
|
34
|
+
const operand = argv[++i];
|
|
35
|
+
if (!operand?.trim() || operand.startsWith('-'))
|
|
36
|
+
throw new ValidationError(`MySQL push ${token} requires an explicit non-flag operand.`);
|
|
37
|
+
}
|
|
38
|
+
else if (token.startsWith('-') && !flags.has(token))
|
|
39
|
+
throw new ValidationError(`Unsupported MySQL push flag: ${shown(token)}.`);
|
|
40
|
+
else if (!token.startsWith('-'))
|
|
41
|
+
throw new ValidationError('Unexpected MySQL push operand.');
|
|
42
|
+
}
|
|
43
|
+
if (args.help)
|
|
44
|
+
return;
|
|
45
|
+
if ((args.dryRun === true) === (args.yes === true))
|
|
46
|
+
throw new ValidationError('MySQL push requires exactly one of --dry-run or --yes (explicit apply).');
|
|
47
|
+
if (args.yes && args.engine !== 'mysql')
|
|
48
|
+
throw new ValidationError('MySQL push --yes requires explicit --engine mysql.');
|
|
49
|
+
if (args.exitCode && !args.dryRun)
|
|
50
|
+
throw new ValidationError('MySQL push --exit-code requires --dry-run.');
|
|
51
|
+
}
|
|
52
|
+
export function showMysqlPushHelp() {
|
|
53
|
+
info(`MySQL conservative schema push:
|
|
54
|
+
turbine push --engine mysql --dry-run [--exit-code] [--schema-file path]
|
|
55
|
+
turbine push --engine mysql --yes [--allow-destructive] [--schema-file path]
|
|
56
|
+
Requires clean history and a complete supported schema. Preview writes nothing.
|
|
57
|
+
Apply preserves one ordinary SQL migration and uses the native partial-DDL journal.
|
|
58
|
+
Every ALTER requires separate --allow-destructive consent. DDL is not atomic.
|
|
59
|
+
Stop external schema changes; the cooperative runner lock is not a DDL lock.
|
|
60
|
+
Failures preserve files and dirty state; inspect and manually reconcile before migrate recover.`);
|
|
61
|
+
}
|
|
62
|
+
export async function cmdMysqlPush(args, config, loadSchema, argv = process.argv.slice(2)) {
|
|
63
|
+
assertMysqlPushArguments(args, argv);
|
|
64
|
+
if (args.help)
|
|
65
|
+
return showMysqlPushHelp();
|
|
66
|
+
if (config.engine !== 'mysql')
|
|
67
|
+
throw new ValidationError('MySQL push requires engine mysql.');
|
|
68
|
+
assertMysqlSchemaConfig(config);
|
|
69
|
+
const result = await pushMysqlSchema(config.url, config.migrationsDir, await loadSchema(config.schemaFile), {
|
|
70
|
+
dryRun: args.dryRun,
|
|
71
|
+
apply: args.yes,
|
|
72
|
+
allowDestructive: args.allowDestructive,
|
|
73
|
+
});
|
|
74
|
+
label('MySQL database', shown(result.plan.database));
|
|
75
|
+
label('Catalog fingerprint', result.plan.fingerprint);
|
|
76
|
+
if (!result.plan.steps.length)
|
|
77
|
+
return success('No supported schema changes; no migration file created.');
|
|
78
|
+
if (args.dryRun) {
|
|
79
|
+
console.log(result.plan.up);
|
|
80
|
+
info('Dry run: no files, history or schema changes made.');
|
|
81
|
+
if (result.plan.requiresAlterConsent)
|
|
82
|
+
info('Apply requires --yes and --allow-destructive for every ALTER.');
|
|
83
|
+
if (args.exitCode)
|
|
84
|
+
process.exitCode = 2;
|
|
85
|
+
}
|
|
86
|
+
else
|
|
87
|
+
success(`Applied journaled migration ${shown(result.file.filename)}.`);
|
|
88
|
+
warn('Catalog checks are advisory, not a DDL lock. MySQL DDL implicitly commits; partial effects may remain.');
|
|
89
|
+
}
|
|
@@ -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,95 @@
|
|
|
1
|
+
/** Conservative schema push through the ordinary native migration journal. */
|
|
2
|
+
import { createHash, randomBytes } from 'node:crypto';
|
|
3
|
+
import { closeSync, fsyncSync, openSync, readFileSync } from 'node:fs';
|
|
4
|
+
import { MigrationError, ValidationError } from '../errors.js';
|
|
5
|
+
import { createMigration, listIgnoredSqlFiles, listMigrationFiles, parseMigrationContent, } from './migrate.js';
|
|
6
|
+
import { withMysqlMigrationWorkspace } from './mysql-migrate.js';
|
|
7
|
+
import { inspectMysqlSchema, planMysqlSchema } from './mysql-schema.js';
|
|
8
|
+
import { modelMysqlSchema } from './mysql-schema-ddl.js';
|
|
9
|
+
import { MYSQL_SCHEMA_EXCLUDED } from './mysql-schema-snapshot.js';
|
|
10
|
+
const sha = (bytes) => createHash('sha256').update(bytes).digest('hex');
|
|
11
|
+
function inventory(dir) {
|
|
12
|
+
if (listIgnoredSqlFiles(dir).length)
|
|
13
|
+
throw new MigrationError('MySQL push refuses ignored SQL files in the migrations directory.');
|
|
14
|
+
return JSON.stringify(listMigrationFiles(dir).map((file) => [file.filename, sha(readFileSync(file.path))]));
|
|
15
|
+
}
|
|
16
|
+
function clean(history) {
|
|
17
|
+
if (history.dirty || history.pending.length || history.mismatches.length)
|
|
18
|
+
throw new MigrationError('MySQL push requires clean migration history: dirty, pending, drifted or missing files must be reconciled explicitly first.');
|
|
19
|
+
}
|
|
20
|
+
// Metadata tables may first appear when the runner initializes its journal.
|
|
21
|
+
function catalog(snapshot) {
|
|
22
|
+
const excluded = new Set(MYSQL_SCHEMA_EXCLUDED);
|
|
23
|
+
return JSON.stringify(Object.fromEntries(Object.entries(snapshot.facts).map(([key, rows]) => [
|
|
24
|
+
key,
|
|
25
|
+
rows.filter((row) => !excluded.has(String(row.TABLE_NAME))),
|
|
26
|
+
])));
|
|
27
|
+
}
|
|
28
|
+
function syncPath(path) {
|
|
29
|
+
const fd = openSync(path, 'r');
|
|
30
|
+
try {
|
|
31
|
+
fsyncSync(fd);
|
|
32
|
+
}
|
|
33
|
+
finally {
|
|
34
|
+
closeSync(fd);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/** No preview effects; apply persists one immutable SQL file before journaled execution. */
|
|
38
|
+
export async function pushMysqlSchema(url, migrationsDir, schema, options) {
|
|
39
|
+
if ((options.dryRun === true) === (options.apply === true))
|
|
40
|
+
throw new ValidationError('MySQL push requires exactly one of --dry-run or --yes (explicit apply).');
|
|
41
|
+
if (typeof migrationsDir !== 'string' || !migrationsDir.trim() || migrationsDir.includes('\0'))
|
|
42
|
+
throw new ValidationError('MySQL push requires a nonempty migrations directory path.');
|
|
43
|
+
modelMysqlSchema(schema);
|
|
44
|
+
return withMysqlMigrationWorkspace(url, migrationsDir, { allowDestructive: options.allowDestructive }, async (workspace) => {
|
|
45
|
+
const originalFiles = inventory(migrationsDir);
|
|
46
|
+
clean(await workspace.inspect());
|
|
47
|
+
const snapshot = await inspectMysqlSchema(url);
|
|
48
|
+
const plan = planMysqlSchema(schema, snapshot);
|
|
49
|
+
if (inventory(migrationsDir) !== originalFiles)
|
|
50
|
+
throw new MigrationError('MySQL push migration files changed during planning.');
|
|
51
|
+
clean(await workspace.inspect());
|
|
52
|
+
if (options.dryRun || !plan.steps.length)
|
|
53
|
+
return { plan };
|
|
54
|
+
if (plan.requiresAlterConsent && options.allowDestructive !== true)
|
|
55
|
+
throw new MigrationError('Every MySQL ALTER requires --allow-destructive, including additive ALTER.');
|
|
56
|
+
const before = await inspectMysqlSchema(url);
|
|
57
|
+
if (catalog(before) !== catalog(snapshot))
|
|
58
|
+
throw new MigrationError('MySQL push catalog changed before persistence; no migration was created.');
|
|
59
|
+
if (inventory(migrationsDir) !== originalFiles)
|
|
60
|
+
throw new MigrationError('MySQL push migration files changed before persistence.');
|
|
61
|
+
// Shared writer uses exclusive wx creation. Never overwrite or remove any file,
|
|
62
|
+
// including this one after a later failure. Random suffix avoids clock collisions.
|
|
63
|
+
const file = createMigration(migrationsDir, `schema_push_${randomBytes(6).toString('hex')}`, plan, {
|
|
64
|
+
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.`,
|
|
65
|
+
});
|
|
66
|
+
const content = readFileSync(file.path, 'utf8');
|
|
67
|
+
const sections = parseMigrationContent(content, file.path);
|
|
68
|
+
if (sections.up !== plan.up.trim() || sections.down !== plan.down.trim())
|
|
69
|
+
throw new MigrationError('MySQL push scaffold changed before it could be frozen.');
|
|
70
|
+
syncPath(file.path);
|
|
71
|
+
syncPath(migrationsDir);
|
|
72
|
+
const expectedFiles = JSON.parse(originalFiles);
|
|
73
|
+
const checksum = sha(content);
|
|
74
|
+
expectedFiles.push([file.filename, checksum]);
|
|
75
|
+
expectedFiles.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
|
|
76
|
+
const frozen = JSON.stringify(expectedFiles);
|
|
77
|
+
const result = await workspace.apply({ name: file.name, checksum }, async (completed) => {
|
|
78
|
+
if (inventory(migrationsDir) !== frozen)
|
|
79
|
+
throw new MigrationError('MySQL push migration files changed; preserved the scaffold for inspection.');
|
|
80
|
+
const current = await inspectMysqlSchema(url);
|
|
81
|
+
if (completed === 0 && catalog(current) !== catalog(snapshot))
|
|
82
|
+
throw new MigrationError('MySQL push catalog changed before execution.');
|
|
83
|
+
const remaining = planMysqlSchema(schema, current);
|
|
84
|
+
if (remaining.up !==
|
|
85
|
+
plan.steps
|
|
86
|
+
.slice(completed)
|
|
87
|
+
.map((step) => step.sql)
|
|
88
|
+
.join('\n'))
|
|
89
|
+
throw new MigrationError('MySQL push catalog no longer matches the remaining planned statements.');
|
|
90
|
+
});
|
|
91
|
+
if (result.errors.length)
|
|
92
|
+
throw new MigrationError(`${result.errors.map((entry) => entry.error).join('\n')} Preserved migration: ${file.filename}.`);
|
|
93
|
+
return { plan, file };
|
|
94
|
+
});
|
|
95
|
+
}
|
|
@@ -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,54 @@
|
|
|
1
|
+
/** CLI presentation for a read-only MySQL diff. Shared dispatch is injected by the CLI. */
|
|
2
|
+
import { ValidationError } from '../errors.js';
|
|
3
|
+
import { mysqlDatabaseFromUrl, resolveCliEngine, validateCliEngineUrl } from './config.js';
|
|
4
|
+
import { inspectMysqlSchema, planMysqlSchema } from './mysql-schema.js';
|
|
5
|
+
import { modelMysqlSchema } from './mysql-schema-ddl.js';
|
|
6
|
+
import { info, label, success } from './ui.js';
|
|
7
|
+
export function assertMysqlSchemaConfig(config) {
|
|
8
|
+
if (config.adapter || config.include.length || config.exclude.length)
|
|
9
|
+
throw new ValidationError('MySQL schema comparison requires engine mysql, no adapter and the complete schema without include/exclude filters.');
|
|
10
|
+
validateCliEngineUrl(resolveCliEngine(config.engine), config.url);
|
|
11
|
+
if (!config.url || mysqlDatabaseFromUrl(config.url) !== config.schema)
|
|
12
|
+
throw new ValidationError('MySQL schema comparison needs a URL selecting the configured database.');
|
|
13
|
+
if (!config.schemaFile?.trim() || config.schemaFile.includes('\0'))
|
|
14
|
+
throw new ValidationError('MySQL schema comparison requires a schema file path.');
|
|
15
|
+
}
|
|
16
|
+
export async function cmdMysqlSchema(args, config, loadSchema, argv = process.argv.slice(2)) {
|
|
17
|
+
const keys = new Set(['command', 'positional', 'engine', 'url', 'schema', 'schemaFile', 'exitCode', 'help']);
|
|
18
|
+
for (const [key, value] of Object.entries(args))
|
|
19
|
+
if (value !== undefined && !keys.has(key))
|
|
20
|
+
throw new ValidationError(`Unsupported MySQL diff option: ${key}.`);
|
|
21
|
+
if (args.command !== 'diff' || args.positional.length)
|
|
22
|
+
throw new ValidationError('Usage: turbine diff --engine mysql [--schema-file path] [--exit-code].');
|
|
23
|
+
const operands = new Set(['--engine', '--url', '-u', '--schema', '-s', '--schema-file']);
|
|
24
|
+
const flags = new Set(['--exit-code', '--help', '-h']);
|
|
25
|
+
for (let i = 1; i < argv.length; i++) {
|
|
26
|
+
const token = argv[i];
|
|
27
|
+
if (operands.has(token)) {
|
|
28
|
+
const value = argv[++i];
|
|
29
|
+
if (!value?.trim() || value.startsWith('-'))
|
|
30
|
+
throw new ValidationError(`MySQL diff ${token} requires an explicit operand.`);
|
|
31
|
+
}
|
|
32
|
+
else if (token.startsWith('-') && !flags.has(token))
|
|
33
|
+
throw new ValidationError(`Unsupported MySQL diff flag: ${token}.`);
|
|
34
|
+
}
|
|
35
|
+
assertMysqlSchemaConfig(config);
|
|
36
|
+
const schema = await loadSchema(config.schemaFile);
|
|
37
|
+
modelMysqlSchema(schema);
|
|
38
|
+
const plan = planMysqlSchema(schema, await inspectMysqlSchema(config.url));
|
|
39
|
+
label('MySQL database', plan.database);
|
|
40
|
+
label('Catalog fingerprint', plan.fingerprint);
|
|
41
|
+
if (!plan.steps.length)
|
|
42
|
+
success('No supported schema changes.');
|
|
43
|
+
else {
|
|
44
|
+
for (const step of plan.steps) {
|
|
45
|
+
info(`${step.kind}: ${step.table}`);
|
|
46
|
+
console.log(step.sql);
|
|
47
|
+
}
|
|
48
|
+
info('Read-only comparison. Create a reviewed SQL migration with migrate create <name> --from-diff --engine mysql.');
|
|
49
|
+
if (plan.requiresAlterConsent)
|
|
50
|
+
info('The native runner requires --allow-destructive for every ALTER, including additions.');
|
|
51
|
+
if (args.exitCode)
|
|
52
|
+
process.exitCode = 2;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -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;
|