Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command "goose validate" don't run #674

Open
darkoment opened this issue Dec 18, 2023 · 1 comment
Open

Command "goose validate" don't run #674

darkoment opened this issue Dec 18, 2023 · 1 comment
Labels

Comments

@darkoment
Copy link

goose version: v3.16.0

I have created migrations through the goose create command.
The migration files are created in the datetime_name.sql format.
When I run the goose validate command, nothing happens.

Example file.sql (sql query was specifically written with an error):

-- +goose Up
-- +goose StatementBegin
INSERTINTO `options` (
    `id`,`questions_id`,`text`,`image`,`type`
) VALUES
      ( 1, 4, 'танцую', NULL, 'regular'),
      ( 2, 4, 'вяжу крючком', NULL, 'regular')
;
-- +goose StatementEnd

-- +goose Down
-- +goose StatementBegin
DELETE FROM options id <= 2;
-- +goose StatementEnd

if you break annotation (for example, gooseStatementBegin instead of goose StatementBegin), a message will be displayed in the terminal:
2023/12/18 15:52:16 goose validate: failed to parse file "20231215150001_add_test_options.sql": '-- +goose StatementEnd' must be defined after '-- +goose StatementBegin', see https://github.com/pressly/goose#sql-migrations

The description of the command states: "Check migration files without running them"
however, no validation actually takes place.

@mfridman
Copy link
Collaborator

mfridman commented Dec 18, 2023

The validate command doesn't validate sql queries, only that the file is not malformed.

We should probably update the description to explicitly state that.

There's an opportunity here to spin up an ephemeral database and apply all migrations to exercise sql queries against a "real" database. But this isn't supported yet.

@mfridman mfridman added the docs label Feb 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants