23 Commits

Author SHA1 Message Date
mohs8421
1f27837f49
refactoring Schema to expose functions for database updates (#1256)
* extracting get_column_def from create_table_from_entity to make it available for database upgrade processes.

* Align code example formatting

* Converting the foreign key related code from create_table_from_entity into From<RelationDef> implementations to make its usage easier in different context, like updating a database.

* Refactor

* Fixup

Co-authored-by: Billy Chan <ccw.billy.123@gmail.com>
2022-12-19 17:24:11 +08:00
Billy Chan
671d79469a
Fixup 2022-10-17 17:25:35 +08:00
Billy Chan
77bddd85a5
Fixup 2022-09-22 15:07:37 +08:00
Billy Chan
6091629adb
cargo fmt 2022-03-25 15:25:49 +08:00
Nick Burrett
a09790ef81
Allow for creation of indexes for PostgeSQL and SQLite (#593)
* Allow for creation of indexes for PostgeSQL and SQLite

PostgreSQL and SQLite do not allow creation of general indexes within a `CREATE TABLE` statement, so a method is required to generate `CREATE INDEX` statements for these.

`create_table_from_entity` avoids creating invalid statements for non-MySQL backends,
forcing uses to explicitly run `create_index_from_entity`.  Ideally creating indexes would be removed from `create_table_from_entity` entirely, but this would introduce a breaking change for MySQL use.

* Remove index creation from create_table_from_entity

Use `create_index_from_entity` for all index creation for consistency across all backends.  This is a backwards incompatible change, affecting those using MySQL backend when creating the schema only.

* Revert change to join_8 test after migration to new indexes entity
2022-03-21 00:45:08 +08:00
Chris Tsang
e63d463155
Merge pull request #489 from SeaQL/date-time-utc-local
Support `DateTime<Utc>` & `DateTime<Local>`
2022-02-01 15:25:39 +08:00
Billy Chan
8145088814 Refactoring
`ColumnDef` with default value

Cargo fmt

Update docs

Fixup

Support `DateTimeLocal`

Update docs

Codegen write db timestamp column as `DateTimeUtc` type

Update dependency

Merge branch 'sea-query/add-new-column-ref' into pr/429

feat: apply alias on `ColumnRef::SchemaTableColumn`
2022-02-01 14:29:03 +08:00
Billy Chan
76c0d7fff5
Name conflict of foreign key constraints when two entities have more than one foreign keys (#417)
* fix: name conflict of foreign key constraints when two entities have more than one fk

* test: update test case's foreign keys

* feat: override default name of foreign key constraint
2022-01-28 01:03:24 +08:00
Billy Chan
f5f6a6774f
Codegen ActiveEnum & Create Enum From ActiveEnum (#348) 2021-12-15 00:52:50 +08:00
Billy Chan
66a005237c
Update sea-orm to depends on sea-query 0.20.0 2021-12-12 23:03:11 +08:00
Billy Chan
f72f65a4d4
Refactor test case 2021-11-18 18:07:09 +08:00
Billy Chan
36886e74cd
Testing & fixup 2021-11-16 12:04:21 +08:00
Josh
2b87a8ba32 Pass the argument entity.table_ref() instead of just entity. 2021-11-15 17:10:02 +08:00
Billy Chan
f504ad1eef
Refactor Schema 2021-11-11 15:11:52 +08:00
Billy Chan
6018d3f1b9
Merge remote-tracking branch 'origin/master' into active-enum 2021-11-02 12:18:37 +08:00
Charles Chege
69d5c701ee Documetation for the schema module 2021-10-29 10:37:54 +03:00
Billy Chan
e21af53374
Fix clippy warnings 2021-10-27 15:23:21 +08:00
Billy Chan
55de1968bb
Add create_enum_from_entity 2021-10-27 12:37:35 +08:00
Billy Chan
f20c64988d
Tests all DB 2021-10-25 16:52:02 +08:00
Billy Chan
8858d64dd0
create_table_from_entity with DB backend 2021-10-25 15:48:01 +08:00
Chris Tsang
558cf5904a Test suite: drop table if exists, instead of create table if not exists 2021-09-18 15:40:47 +08:00
Chris Tsang
6c810673c4 Move entity_to_table_create_statement 2021-09-07 15:55:58 +08:00
Billy Chan
b100e32ffd Rename entity_to_table_create_statement 2021-09-07 15:47:04 +08:00