Comments (3)
Ye this is a bit unfortunate, I suppose you could move the semicolon to a new line, or wrap that statement in a +goose StatementBegin
/ +goose StatementEnd
.
The SQL parser is quite basic and does the bare minimum. Open to suggestions on how this could be improved.
from goose.
Certainly, I can manually adjust the SQL, but for my scenario, which involves programmatically generating migrations from mysqldump
, the task becomes more challenging.
For now, my temporary workaround is to regex my arrows from -->
to ->
, but this is obviously not a universal fix for --
.
I don't really see any solutions that doesn't require complicating ParseSQLMigration
.
Maybe we can track whether or not we are inside a string by looking for the '
character? But there are many edge cases...
from goose.
Certainly, I can manually adjust the SQL, but for my scenario, which involves programmatically generating migrations from mysqldump, the task becomes more challenging.
Yep, that's an excellent example.
I don't really see any solutions that doesn't require complicating ParseSQLMigration.
Pretty much. Which gets us into the territory of writing a full-blown SQL parser, otherwise we're always fighting a new edge case. To make matters worse, there's always some subtle dialect-specific difference.
I'll keep this issue open and continue to think this through in the background.
I wonder if you could wrap your entire dumped schema with all statements within:
-- +goose Up
-- +goose StatementBegin
... your entire schema here
-- +goose StatementEnd
This tells goose
to send the entire set of querie(s) as a single semicolon-separated query. And usually this just works unless you have an extensive schema, exceed the database limit or a specific query can't be run in the same transaction.
A bit more background on these annotations can be found here:
https://pressly.github.io/goose/blog/2022/overview-sql-file/#multiple-statements
from goose.
Related Issues (20)
- fail when there is a pending migration and out of order migrations are not allowed HOT 2
- NO TRANSACTION annotation is case sensitive HOT 7
- Feature request: explore WASM-based migrations
- Question about providing our own Logger implementation HOT 3
- Modular dependencies architecture HOT 4
- Running `go run goose` produces go mod error on @latest HOT 6
- Add support for ssl ca-cert for clickhouse HOT 5
- Local scope for provider go migrations HOT 3
- Migration with multiline comments failed HOT 1
- Migration version mismatch when running `goose fix` in CI HOT 1
- Feature: always migration(s)
- Improve Goose Migration Handling for Interleaved Migration Files HOT 1
- Does Goose support exporting the final SQL schema? HOT 2
- `CREATE INDEX CONCURRENTLY` with `GoMigrationNoTx` failing HOT 2
- Goose returns incorrect error when multiple DB users try to up migrations HOT 2
- mistyped migration file name causing goose to skip future migrations HOT 3
- Suspicious Virus Alert On Windows: Operation did not complete successfully because the file contains a virus or potentially unwanted software. HOT 2
- goose validate: no such command HOT 3
- Command line issue: goose run: ERROR: relation "_db_migrations" already exists (SQLSTATE 42P07) HOT 4
- Dialect Support - Starrocks HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from goose.