Commit Graph

201 Commits

Author SHA1 Message Date
Ariel Mashraki
6e4e4da896 entc/integration/migrate: update atlas and test custom time precision (#2462) 2022-04-08 11:27:30 +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
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
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
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
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
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
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
dd6c034c2a dialect/sql/schema: support mediumtext field in migration
Fixed https://github.com/ent/ent/issues/2113
2021-11-07 15:37:06 +02:00
Alexander Melentyev
147b1f59ae all: small typo fixes (#2095) 2021-11-01 17:47:06 +02:00
Ariel Mashraki
f30a17edd4 all: fix linting issues before migrating to golangci v1.42 (#2019) 2021-10-07 19:54:43 +03:00
Shen Yang
65cf307b10 dialect/sql/schema: add support for tstzrange and interval and in postgres (#2013)
Fixes #1989
2021-10-06 21:46:34 +03:00
Ariel Mashraki
14cba0abb6 dialect/sql/schema: make Field.Unique and Index.Unique equal (#2004)
This will allow moving from:

	field.String(c).Unique()

To:

	index.Field(c).Unique()

And vice versa
2021-10-03 16:20:28 +03:00
Ariel Mashraki
4c2faf2282 entc/gen: allow spaces in enum fields 2021-09-23 23:23:28 +03:00
storyicon
779594f7da dialect/sql/schema: support mysql mediumtext type (#1972)
Signed-off-by: storyicon <yuanchao@bilibili.com>
2021-09-22 15:35:14 +03:00
Ariel Mashraki
5c7c36bf29 dialect/sql/schema: skip parsing expression default for postgres
Fixed https://github.com/ent/ent/issues/1962
2021-09-21 15:59:04 +03:00
Ariel Mashraki
38925b6134 dialect/sql/schema: revert #1547 for mariadb 2021-09-14 13:07:49 +03:00
dakimura
dac5ccaec9 dialect/sql/schema: fix error message for the missing fk constraints (#1861) 2021-08-22 22:05:40 +03:00
Ariel Mashraki
397b3e984d dialect/sql/schema: setup tables before execute hooks 2021-08-04 21:43:00 +03:00
Ariel Mashraki
79716e47d0 dialect/sql/schema: remove unneeded nolint rule 2021-07-16 14:07:40 +03:00
Ruben de Vries
1ea718f7bf dialect/sql/schema: add support for postgres and mysql numeric and decimal types in migrations (#1721)
* improve error message when failing to generate changeset

* support migrations for postgres and mysql numeric fields
2021-07-16 13:57:53 +03:00
bshihr
4066255641 dialect/sql/schema: add IndexBuilder.IfNotExists and use for Create() case. (#1666)
Append-only mode creates tables with the `IF NOT EXISTS` annotation.
Make indices case symmetric with this.
2021-06-30 09:09:48 +03:00
Ariel Mashraki
7ffdce4cef sql/schema: support custom char type for field.Other
Fixed #1664
2021-06-29 16:31:57 +03:00
Ariel Mashraki
c40ae45aee entc/gen: add support for summing custom Go numeric types 2021-06-25 17:30:17 +03:00
Ariel Mashraki
1d661deb50 dialect/sql/schema: add mysql tests for checks annotation 2021-06-18 10:30:07 +03:00
Ariel Mashraki
42a2c67cc4 dialect/entsql: add support for table checks in schema/migration 2021-06-17 23:22:37 +03:00
Ariel Mashraki
66871c9806 dialect/sql/schema: add support for index prefixes in mysql 2021-06-09 22:52:31 +03:00
Ariel Mashraki
7428167a14 dialect/sql/schema: add testcase for unsigned decimal types (#1628) 2021-06-08 11:22:55 +03:00
Ariel Mashraki
f7db15ccbb dialect/sql/schema: add field collation support for postgres 2021-05-10 20:32:45 +03:00
Mahmudul Haque
ba954ebeec dialect/sql/schema: add field collation support (#1548)
* specific field collation support

* go generate ./...
2021-05-09 18:09:08 +03:00
Ariel Mashraki
37d4b9e2cb dialect/sql/schema: do not set timestamp to nullable columns on MySQLv8.* (#1547)
Fixed #1541
2021-05-08 21:29:35 +03:00
陈杨文
be59ad6d3f dialect.sql/schema.Column ScanDefault allowed uuid default to function (#1537) 2021-05-07 16:15:29 +03:00
AlonDavidBehr
110bfd97ca dialect/sql/schema: fixed spelling mistakes in schema.go (#1532) 2021-05-03 21:02:52 +03:00