Commit Graph

57 Commits

Author SHA1 Message Date
Ariel Mashraki
98d00a35b5 go: update atlas and test global-unique-id migration (#2661) 2022-06-18 21:50:44 +03:00
Jannik Clausen
7017cbc898 dialect/sql/schema: file based type store (#2644)
* 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
2022-06-15 16:10:15 +02:00
Ariel Mashraki
6e4e4da896 entc/integration/migrate: update atlas and test custom time precision (#2462) 2022-04-08 11:27:30 +03:00
Ariel Mashraki
fe2511fc8d dialect/entsql: add support for index-type annotation 2022-02-22 16:24:30 +02:00
Thomas Prebble
ce9641e1ae dialect/sql/schema: support postgres geometric types (#2340) 2022-02-18 17:08:25 +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
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
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
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
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
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
42a2c67cc4 dialect/entsql: add support for table checks in schema/migration 2021-06-17 23:22:37 +03:00
Ariel Mashraki
f7db15ccbb dialect/sql/schema: add field collation support for postgres 2021-05-10 20:32:45 +03:00
Ciaran Liedeman
b20d521593 dialect/sql/schema: added foreign keys to postgres inspect (#1493)
* Added foreign keys to postgres inspect

* Update dialect/sql/schema/inspect.go

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

* Update dialect/sql/schema/inspect.go

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

* added unit test

* fixed interface

* moved import back

* fixing tests

* Update dialect/sql/schema/inspect.go

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

* Update dialect/sql/schema/postgres.go

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

* Update dialect/sql/schema/postgres.go

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

* pr feedback

* added m2m test case

* converted to unit tests

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>
2021-04-26 15:32:12 +03:00
Ariel Mashraki
fd1f2df150 dialect/sql/schema: add support for pg arrays in migration 2021-04-14 14:25:28 +03:00
Matthew Gabeler-Lee
c53b45ddb0 all: use %w instead of %v to wrap errors (#1275)
* all: use %w instead of %v for nested errors with fmt.Errorf

* all: update generated code to use %w instead of %v for error wrapping
2021-03-03 20:05:33 +02:00
Ariel Mashraki
dd4792f5b3 go: rename module from github.com/facebook/ent => entgo.io/ent (#1226) 2021-02-02 23:03:04 +02:00
Ariel Mashraki
cc8da8fbf7 dialect/sql/schema: schema match from predicate 2021-01-18 12:38:39 +02:00
Ariel Mashraki
8b798d2714 dialect/sql/schema: add tables inspection capabilities (#1178) 2021-01-17 16:41:07 +02:00
Ariel Mashraki
91f7e3363a dialect/sql/schema: support providing alternate schema for postgres (#1172) 2021-01-14 16:55:37 +02:00
Ariel Mashraki
93e6a6cebd dialect/sql/schema: minor style changes (#1088) 2020-12-27 20:12:55 +02:00
Ciaran Liedeman
7320b0d16c dialect/sql/schema: add pg user defined type for schema introspect (#994)
* Added user defined fields

* pr feedback

* added integration test

* run generate

* Update dialect/sql/schema/postgres_test.go

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

* Update dialect/sql/schema/postgres_test.go

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

* Update dialect/sql/schema/postgres_test.go

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

* Update dialect/sql/schema/postgres_test.go

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

* Update dialect/sql/schema/postgres_test.go

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

* Update dialect/sql/schema/postgres_test.go

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

* Update dialect/sql/schema/postgres_test.go

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

* Update dialect/sql/schema/postgres_test.go

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

* Update dialect/sql/schema/postgres_test.go

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

* Update dialect/sql/schema/postgres_test.go

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

* Update dialect/sql/schema/postgres_test.go

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

* Update dialect/sql/schema/postgres_test.go

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

* Update dialect/sql/schema/postgres_test.go

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

* Update dialect/sql/schema/postgres_test.go

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

* Update dialect/sql/schema/postgres_test.go

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

* Update dialect/sql/schema/postgres_test.go

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

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>
2020-12-27 20:00:47 +02:00
Ariel Mashraki
ed4a8fe010 dialect/sql/schema: replace all unquote for postgres dialect (#1019) 2020-12-06 11:49:02 +02:00
Ariel Mashraki
3d2feec5e2 dialect/sql/schema: initial support for postgres net-types (#964) 2020-11-20 15:30:54 +02:00
Ariel Mashraki
77eaad0df6 dialect/sql/schema: skip default value parsing on pg functions (#951)
Closes #934
2020-11-15 22:55:52 +02:00
ssoor
d5b69da9e0 dialect/sql/schema: add postgres type 'timestamp without time zone' to the scan column (#949) 2020-11-14 19:52:37 +02:00
Ariel Mashraki
13b379d07c dialect/sql/schema: properly handle indexes of tables with uncountable name (#828) 2020-10-08 23:24:54 +03:00
Ariel Mashraki
b18716931d dialect/sql: change boolean operators wrapping (#678)
The reason is to parentheses only when it's necessary.
2020-08-20 10:08:31 +03:00
Ariel Mashraki
fd0a7f9f02 all: facebookincubator/ent => facebook/ent (#660)
ent repository is going to be migrated to facebook organization
2020-08-18 11:05:08 +03:00
Ariel Mashraki
d26fbaeb54 dialect/postgres: fix postgres naming prefix and detection for indexes (#543) 2020-06-10 22:24:16 +03:00
Ariel Mashraki
cfee55e514 schema/field: add an option to configure the database type (#484) 2020-05-11 15:07:33 +03:00
Alex Snast
68db86be76 avoid multiple rows.Err calls on error path
Signed-off-by: Alex Snast <alexsn@fb.com>
2020-05-11 14:26:40 +03:00
Ciaran Liedeman
f59abad425 fix: checks for error after rows.Next call (#480) 2020-05-09 16:23:47 +03:00
Ariel Mashraki
f384701c04 dialect/sql/schemma: ignore pgtime default value on scanning (#468) 2020-05-06 22:34:01 +03:00
Ariel Mashraki
196a764691 dialect/sql/schema: use the postgres column type if exists (#466) 2020-05-06 21:54:21 +03:00
Ariel Mashraki
51cdda421f dialect/sql/schema: add optional schema-type to column spec (#461) 2020-05-04 20:16:43 +03:00
Ariel Mashraki
2208b243db dialect/sql/schema: initial work for incremental migration (#428)
This is a WIP PR and should be ignored this moment.
It's based on PR #221 created by Erik Hollensbe (He should
get his credit for his work before we land this).
2020-04-12 19:12:33 +03:00
Ariel Mashraki
b1eb999097 dialect/sql/schema: comment changes (#415) 2020-03-31 22:51:50 +03:00
Ariel Mashraki
26440c2bc9 dialect/sql/schema: setrange on custom column name of pks (#333) 2020-02-09 09:41:26 +02:00
Ariel Mashraki
b4255998bf entc/gen: change name format for edge fks (#286)
* entc/gen: change name format for edge fks

* dialect/sql/schema: add fixture support for mysql and postgres

* sql/dialect: merge fkcolumn queries to one for the 2 dialects
2020-02-03 15:41:55 +02:00
Ariel Mashraki
6819c01906 dialect/sql: allow nil values for exec commands (#313)
In most cases, the sql.Result is not needed.
2020-01-22 22:43:45 +02:00
Ariel Mashraki
3425754c8e dialect/sql/schema: scan multi-column indexes with their correct position (#308) 2020-01-22 04:43:01 -05:00
Ariel Mashraki
6bb834612c dialect/sql/schema: drop unique constraint on pg migration
Fixes #235
2019-12-15 18:52:05 +02:00
Ariel Mashraki
db7b05ad04 dialect/sql/schema: postgres support for uuid type
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/178

Reviewed By: alexsn

Differential Revision: D18615561

fbshipit-source-id: 8244189186bf35d78cfdb991ee4f8cecd6411cee
2019-11-20 09:49:54 -08:00
Ariel Mashraki
d5c111b35a dialect/sql/schema: univerdal id support for postgres
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/122

Reviewed By: alexsn

Differential Revision: D18113754

fbshipit-source-id: 1050f0c2b823db6ba1bc37c36f6749cfcffa982d
2019-10-24 08:45:09 -07:00
Ariel Mashraki
88bfbc38df dialect/sql/schema: index builders per dialect
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/118

Reviewed By: alexsn

Differential Revision: D18092371

fbshipit-source-id: 02b85724b1e00d10c930112b9e2c8d07c8727216
2019-10-24 02:23:33 -07:00
Ariel Mashraki
c414cd9a82 dialect/sql/schema: alter column for postgres
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/117

Reviewed By: alexsn

Differential Revision: D18083914

fbshipit-source-id: a5f6993cfe9a260a84c0d4ab868e3e797b3a5776
2019-10-23 05:39:17 -07:00