* dialect/sql/builder: make sql.In() with empty args fallback to False()
* fix indent
* added comment
* remove the equilvalent logic in the codegen side
* comment fix, run go generate
Also, added additional example where an edge schema has another edge
to a type that holds an information about the relationship.
The only reason this example exists is to allow users to reduce the storage
occupied by the join-table and allow connect (via M2O) multiple edge-schemas
to an 'information'/'description' node.
* Add docs on using ExprP() for custom WHERE sql statement
* Add ExprP() examples using integration test
* move custom predicate example and show examples using both P() and ExprP()
* fix to greater or equal than
* rephrase wording and fix sql builder
* Update doc/md/predicates.md
Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>
* Update doc/md/predicates.md
* Update doc/md/predicates.md
* Update doc/md/predicates.md
* Update doc/md/predicates.md
Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>
* dialect/sql/schema: file based type store
This PR adds support for a file based type storage when using versioned migrations. The file called `.ent_types` is written to the migration directory alongside the migration files and will be kept in sync for every migration file generation run.
In order to not break existing code, where the type storage might differ for different deployment, global unique ID mut be enabled by using a new option. This will also be raised as an error to the user when attempting to use versioned migrations and global unique ID.
Documentation will be added to this PR once feedback on the code is gathered.
* apply CR
* fix tests
* change format of types file to exclude it from atlas.sum file
* docs and drift test
* apply CR
This will allow us to store information about pk ranges allocated per type in a different location thant the database. This is useful for deterministic pk range computation for things like generating atlas.hcl out of the Ent schema.
* dialect/sql: move FROM to inside switch
* dialect/sql: adds simple example of subquery usage
* dialect/sql: adds a more complex example with join
* Apply suggestions from code review
Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>
* dialect/sql: fix missing type and change modify to where
Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>
What's the problem: Under versioned migration on MySQL 8.0, unique string field would be generated as type varchar(191) instead of varchar(255). This is because in generating migration files by NamedDiff(), sqlDialect's init() method is not called.
Further concern: For init() function, MySQL and Postgres's implementation checks the database version which is what I want. But SQLite's implementation checks the foreign_keys support. So I think there might be a better may to check the database version before doing Diff().
* dialect/sql/schema: add method to create a named versioned migration file
* doc/md: documentation for named versioned migrations
* entc/gen/template/dialect/sql/feature: add NamedDiff method to create named versioned migration files
* all: go generate
* doc/md: apply CR
* dialect/sql/schema: fix no change condition in atlas
* dialect/sql/schema: fix bug in atlas integration when working WithDropIndex/WithDropColumn
Co-authored-by: Zeev Manilovich <zeevmanilovich@gmail.com>
* dialect/sql/schema: fix go doc
* all: update atlas
* dialect/sql/schema: diff connected DB and defined schema and write changes to migration file
* dialect/sql/schema: use migration directory and formatter directly instead of a planner
* all: update atlas
* cmd: add command to create a new migration file
* entc/gen: generate main.go with migrate diff example
* all: regenerate
* cmd/internal/base: make linter happy
* all: support Go 1.16 in versioned migrations main.go
* entc/gen: put versioned migrations behind feature flag
* all: regenerate
* cmd/ent: driver-prefixed dsn in migrate diff command
* cmd/internal/base: remove prefix from migrate import
* cmd/internal/base: use cobra.CheckErr
* cmd: remove diff command
* entc/gen/template/dialect/sql/feature: remove generated main.go
* all: rebase on master and go mod tidy
* all: regenerate