8000 entc/gen: singularize feature flag name for versioned migrations by masseelch · Pull Request #2350 · ent/ent · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

entc/gen: singularize feature flag name for versioned migrations #2350

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

Merged
merged 1 commit into from
Feb 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions doc/md/migrate_versioned.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ tool you like (like golang-migrate, Flyway, liquibase).
In order to have Ent make the necessary changes to your code, you have to enable this feature with one of the two
options:

1. If you are using the default go generate configuration, simply add the `--feature sql/versioned-migrations` to
1. If you are using the default go generate configuration, simply add the `--feature sql/versioned-migration` to
the `ent/generate.go` file as follows:

```go
package ent

//go:generate go run -mod=mod entgo.io/ent/cmd/ent generate --feature sql/versioned-migrations ./schema
//go:generate go run -mod=mod entgo.io/ent/cmd/ent generate --feature sql/versioned-migration ./schema
```

2. If you are using the code generation package (e.g. if you are using an Ent extension), add the feature flag as
Expand All @@ -40,7 +40,7 @@ import (
)

func main() {
err := entc.Generate("./schema", &gen.Config{}, entc.FeatureNames("sql/versioned-migrations"))
err := entc.Generate("./schema", &gen.Config{}, entc.FeatureNames("sql/versioned-migration"))
if err != nil {
log.Fatalf("running ent codegen: %v", err)
}
Expand Down
6 changes: 3 additions & 3 deletions entc/gen/feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ var (
Description: "Allows users to configure the `ON CONFLICT`/`ON DUPLICATE KEY` clause for `INSERT` statements",
}

FeatureVersionedMigrations = Feature{
Name: "sql/versioned-migrations",
FeatureVersionedMigration = Feature{
Name: "sql/versioned-migration",
Stage: Experimental,
Default: false,
Description: "Allows users to work with versioned migrations / migration files",
Expand All @@ -108,7 +108,7 @@ var (
FeatureLock,
FeatureModifier,
FeatureUpsert,
FeatureVersionedMigrations,
FeatureVersionedMigration,
}
)

Expand Down
2 changes: 1 addition & 1 deletion entc/gen/template/migrate/migrate.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error
return migrate.Create(ctx, Tables...)
}

{{ if $.Config.FeatureEnabled "sql/versioned-migrations" }}{{ template "migrate/diff" $ }}{{ end }}
{{ if $.Config.FeatureEnabled "sql/versioned-migration" }}{{ template "migrate/diff" $ }}{{ end }}

// WriteTo writes the schema changes to w instead of running them against the database.
//
Expand Down
2 changes: 1 addition & 1 deletion entc/integration/migrate/versioned/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

package versioned

//go:generate go run -mod=mod entgo.io/ent/cmd/ent generate --feature sql/versioned-migrations --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema
//go:generate go run -mod=mod entgo.io/ent/cmd/ent generate --feature sql/versioned-migration --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema
0