Giter Club home page Giter Club logo

Comments (9)

VojtechVitek avatar VojtechVitek commented on May 17, 2024

Sure, I'm totally fine with the below for example:

-- +goose Up
-- +goose StatementBegin
SELECT 1;
-- +goose StatementEnd

-- +goose Down
-- +goose StatementBegin
SELECT 1;
-- +goose StatementEnd

from goose.

joelpresence avatar joelpresence commented on May 17, 2024

from goose.

VojtechVitek avatar VojtechVitek commented on May 17, 2024

I thought you'd just change the string in the code.

I don't think it's worth passing the template via CLI - it'd be easier to create the file manually, or am I missing anything?

from goose.

joelpresence avatar joelpresence commented on May 17, 2024

Sure, changing the string in code would be even easier! I'll do that ...

Would you object to the following:

-- +goose Up
-- +goose StatementBegin
-- +goose StatementEnd

-- +goose Down
-- +goose StatementBegin
-- +goose StatementEnd

I removed the SELECT 1; because if it's in the template, people are just going to have to remove it before adding their own sql, so I'd rather just omit it if it's ok?

Thanks.

from goose.

VojtechVitek avatar VojtechVitek commented on May 17, 2024

go for it

from goose.

VojtechVitek avatar VojtechVitek commented on May 17, 2024

I think I'm gonna drop StatementBegin/StatementEnd if possible

from goose.

VojtechVitek avatar VojtechVitek commented on May 17, 2024

Hey @joelpresence, any update on this issue? I tried to get rid of StatementBegin/StatementEnd for good, but it's not that simple as I expected.

Note that both StatementBegin and StatementEnd are only needed when you have a advanced/complex statements containing ; within it.

We don't really need it otherwise and I tend to keep the template simple.

from goose.

eaglemoor avatar eaglemoor commented on May 17, 2024

Any update?

from goose.

VojtechVitek avatar VojtechVitek commented on May 17, 2024

Please, go ahead and create a PR with the proposed changes. We can discuss there.

goose/create.go

Lines 61 to 88 in 58aa6a8

var sqlMigrationTemplate = template.Must(template.New("goose.sql-migration").Parse(`-- +goose Up
-- SQL in this section is executed when the migration is applied.
-- +goose Down
-- SQL in this section is executed when the migration is rolled back.
`))
var goSQLMigrationTemplate = template.Must(template.New("goose.go-migration").Parse(`package migration
import (
"database/sql"
"github.com/pressly/goose"
)
func init() {
goose.AddMigration(Up{{.}}, Down{{.}})
}
func Up{{.}}(tx *sql.Tx) error {
// This code is executed when the migration is applied.
return nil
}
func Down{{.}}(tx *sql.Tx) error {
// This code is executed when the migration is rolled back.
return nil
}
`))

from goose.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.