Commit Graph

416 Commits

Author SHA1 Message Date
Jannik Clausen
bfa9c963cb dialect/sql/schema: introduce type store interface (#2636)
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.
2022-06-10 10:08:33 +02:00
Ariel Mashraki
5b81d7d832 dialect/sql/sqlgraph: better support for update nodes with predicates (#2574) 2022-05-29 16:23:52 +03:00
Ariel Mashraki
e1c5277483 ent: initial support for edge schemas (#2560) 2022-05-25 15:46:00 +03:00
Jannik Clausen
4142108d62 doc/website/blog: external tools and sum file (#2489)
* doc/website/blog: external tools and sum file

* Apply suggestions from code review

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>

* doc/website/blog: apply CR

* Apply suggestions from code review

Co-authored-by: Hila Kashai <73284641+hilakashai@users.noreply.github.com>

* doc/website/blog: minor fixes

* doc/website/blog: invoke atlas command by calling go run

* doc/website/blog: It's-a me, Jannik!

* Apply suggestions from code review

Co-authored-by: Rotem Tamir <rotemtamir@gmail.com>

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>
Co-authored-by: Hila Kashai <73284641+hilakashai@users.noreply.github.com>
Co-authored-by: Rotem Tamir <rotemtamir@gmail.com>
2022-05-09 15:23:51 +02:00
Pedro Henrique
4d1c0af20d entc/integration: add examples for sub-queries + minor fixed for selector builder (#2509)
* 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>
2022-05-05 22:46:13 +03:00
MasseElch
12b6659c72 dialect/sql/schema: respect sumfile when present and do not operate on checksum mismatch (#2522) 2022-05-05 10:43:20 +02:00
Ariel Mashraki
dab95be855 doc/md: example and test for migration apply hooks (#2514) 2022-05-02 14:25:22 +03:00
MasseElch
e50d335c30 dialect/sql: support string based pk for mysql56 indexes (prevent err… (#2506)
* dialect/sql: support string based pk for mysql56 indexes (prevent error 1071)

* Update entc/integration/customid/ent/schema/revision.go

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>
2022-04-29 08:57:22 +02:00
MasseElch
4db0c544c2 dialect/sql: add New method to pass in a river without opening a *sql.DB before (#2504) 2022-04-28 13:12:34 +02:00
MasseElch
c1175719a2 dialect/sql/schema: option to enable atlas sum file (#2470)
* dialect/sql/schema: option to enable atlas checksum file

* entc/integration/migrate: add integration tests for versioned migrations

* entc/integration/migrate: apply CR
2022-04-13 21:36:57 +02:00
MasseElch
89dc83887c doc/md: document usage of atlas supported migration tools (#2467)
* doc/md: document usage of atlas supported migration tools

* dialect/sql/schema: fix tests
2022-04-13 12:47:00 +02:00
Ariel Mashraki
6e4e4da896 entc/integration/migrate: update atlas and test custom time precision (#2462) 2022-04-08 11:27:30 +03:00
Carlos González
5dd5acc08d dialect/sql: fixed a small typo in docs (#2459) 2022-04-07 19:54:43 +03:00
Ariel Mashraki
89c339209e entc/gen: add the sql/execquery feature flag (#2447) 2022-04-06 13:34:22 +03:00
Charles Ge
e463cbca55 init db version before executing diff (#2440)
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().
2022-04-06 09:43:13 +02:00
Ariel Mashraki
345d3d1783 dialect/sql: support for order by expressions in window functions (#2442) 2022-04-01 21:31:00 +03:00
Ariel Mashraki
317594ec80 dialect/sql/schema: prefix sqlite unique indexes with table name (#2433)
Fixed https://github.com/ent/ent/issues/2421
2022-03-28 12:54:39 +03:00
Ariel Mashraki
92ff734815 dialect/sql: add support for window functions (#2431) 2022-03-27 20:53:36 +03:00
Ariel Mashraki
6c30ca7d4f dialect/sql/schema: skip creating unique key for primary keys (#2425) 2022-03-24 18:53:36 +02:00
Zeev Manilovich
b1abbd3d65 dialect/sql/schema: without foreign keys option for atlas (#2404)
* dialect/sql: without foreign key option for atlas

* handle fks in modifytables

* add tests

* tests

* Update dialect/sql/schema/atlas.go

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>

* ct and tests

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>
2022-03-16 17:27:23 +02:00
Ariel Mashraki
412947d274 dialect/sql: avoid passing bool arguments on bool predicates (#2405) 2022-03-15 22:52:49 +02:00
MasseElch
db1617bb29 dialect/sql/schema: upgrade atlas and disable sum file creation (#2400)
* dialect/sql/schema: upgrade atlas and disable sum file creation

* dialect/sql/schema: linter
2022-03-15 17:40:56 +01:00
MasseElch
2853afc1dc dialect/sql/schema: add method to create a named versioned migration … (#2385)
* 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
2022-03-10 16:40:57 +01:00
Ariel Mashraki
78a0fd9716 schema/field: expose RType.Implements method (#2379)
Also, add both (T) and (*T) methods for RType
2022-03-07 22:33:50 +02:00
Huy TQ
ddddc1d92a dialect/sql/schema: add name to versioned migration files (#2375)
* add name to versioned migration files

* Skip writing migration files if the plan has no changes
2022-03-07 10:18:07 +01:00
Ariel Mashraki
3aab4d91c2 all: update atlasgo.io to latest (#2376) 2022-03-04 22:53:37 +02:00
Ariel Mashraki
35a098fdbb dialect/sql/schema: fix bug in atlas integration when working WithDropIndex/WithDropColumn (#2374)
* 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>
2022-03-03 21:52:44 +02:00
Ariel Mashraki
36a1063c7e entc/integration/migrate: add FULLTEXT usage example 2022-02-22 16:24:30 +02:00
Ariel Mashraki
fe2511fc8d dialect/entsql: add support for index-type annotation 2022-02-22 16:24:30 +02:00
MasseElch
0239daca7b dialect/sql/schema: versioned migrations (#2337)
* 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
2022-02-21 12:15:17 +02:00
Thomas Prebble
ce9641e1ae dialect/sql/schema: support postgres geometric types (#2340) 2022-02-18 17:08:25 +02:00
Ariel Mashraki
51663407cf dialect/sql/schema: support DESC indexes using atlasgo.io 2022-01-31 15:18:09 +02:00
Ariel Mashraki
898991ac79 entc/gen: set foreign-key columns non-nullable for required edges (#1703)
Note, this only applies to edges without circular references.
Fixed #1688 and #1374
2022-01-23 22:23:37 +02:00
Ariel Mashraki
60e03285d0 dialect/sql/schema: hello ariga.io/atlas (#2279) 2022-01-20 17:20:50 +02:00
Ariel Mashraki
b70754d12f dialect/sql/sqlgraph: avoid creating tx blocks for single statement batch-create operation (#2272)
For example, in PostgreSQL, every statement is executed within a transaction. Therefore, we can avoid creating transaction
blocks manually (group of statements surrounded by BEGIN and COMMIT) for CreateNode operation with single SQL statement.

Benchmark was improved from:

	(4000 BatchInserts)    17.16s      4289178 ns/op  412893 B/op   4913 allocs/op

To:

	(4000 BatchInserts)   9.16s      2288807 ns/op  412142 B/op   4899 allocs/op
2022-01-15 23:04:37 +02:00
s-takehana
0fd6143979 dialect/sql/schema: support time with time zone and time without time zone (#2257)
* dialect/sql/schema: support `time with time zone` and `time without time zone`

* fix test

* fix test
2022-01-12 14:33:26 +02:00
Ariel Mashraki
6848f3fc7b dialect/sql/schema: do not sort primary-key columns before diff (#2254)
PKs are indexes and therefore, the order does matter.
Thanks to ariga.io/atlas we found this issue.
2022-01-09 15:37:21 +02:00
Ariel Mashraki
deb63d0292 dialect/sql: support passing selectors to basic predicates
Closed https://github.com/ent/ent/issues/2236
2021-12-25 15:02:49 +02:00
Mehmet Yılmaz
4d01a56b8d dialect/sql/schema: allow adding DEFAULT to columns on migration #1758 (#2199)
* add feature to SET DEFAULT value when add new default value to a existing column

* refactoring unit tests

* correct misspells

* code review refactors

* refactors

* Update dialect/sql/schema/postgres.go

* Update dialect/sql/schema/postgres.go

* Update dialect/sql/schema/postgres.go

* Update dialect/sql/schema/postgres.go

* Update dialect/sql/schema/postgres.go

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>
2021-12-20 11:29:07 +02:00
Mehmet Yılmaz
8a6ff230c8 dialect/sql/schema: convert column type string to lower case (#2222)
Fixed #2209

* convert column type string to lower case

* Update dialect/sql/schema/sqlite.go

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>
2021-12-19 21:02:06 +02:00
Ariel Mashraki
1c263c7abd dialect/sql: add support for SelectExpr (#2220) 2021-12-16 13:50:03 +02:00
Yoni Davidson
b8149f2768 dialect/schema: support float for mysql on inspection (#2191)
* dialect/schema: support float for mysql

* add tests
2021-12-07 12:45:46 +02:00
Ariel Mashraki
475e237937 dialect/sql/schema: fix bug when using multiple table CHECK constraints (#2188)
Fixed https://github.com/ent/ent/issues/2185
2021-12-01 12:00:06 +02:00
Naor Matania
8847a1ac55 dialect/sql/schema: fix migrating Postgres fields with max character varchar custom type (#2162)
* Support migration of varying length varchar postgres

* update type

* fix type

* improve type

* remove not needed change

* fix failing test

* add inspect test

* add more tests

* go fmt

* fix pr comment
2021-11-28 07:57:57 +02:00
Ariel Mashraki
b99ce66f40 dialect/sql: calling Update.Add after Update.Set should append expression (#2168) 2021-11-25 12:03:12 +02:00
Ariel Mashraki
6402fc7fe2 Merge pull request #2137 from ent/getoutreach-grevych/sqljson-pattern-matching-predicates
Getoutreach grevych/sqljson pattern matching predicates
2021-11-16 10:21:08 +02:00
Ariel Mashraki
77701d4db6 dialect/sql/sqljson: use the builtin string predciates in sqljson and improve tests 2021-11-16 10:07:34 +02:00
Ariel Mashraki
a5fea077a9 dialect/sql: use identifier qualifiers for WHERE clause on upsert
Fixed https://github.com/ent/ent/issues/2126
2021-11-12 23:46:46 +02:00
Ariel Mashraki
0dd7b0d7c3 dialect/sql/sqljson: fix sqlite haskey and add docs 2021-11-11 18:58:28 +02:00
Ariel Mashraki
3ba2b4e173 entc/integration/json: add tests for null literals 2021-11-10 17:24:51 +02:00