-
-
Notifications
You must be signed in to change notification settings - Fork 532
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Poem example * 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 * Add `max_lifetime` connection option * Remove `r#` prefix from column name when field has a raw identifier * Fix FromQueryResult when Result is redefined Macros should only ever use absolute import paths. Shorthands can clash (as they have in my case). * Support the use of chrono::DateTime<Utc> in sea-orm Add documentation for this Temporarily use a fork to include new Sea-query code Add tests for DateTimeUtc Solve Github actions error by add the code to create a table Assertion accuracy tests Rectify incorrect format * 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` * Update sea-query dependency * Fully quantity `std::result::Result` in proc_maros * Migration (#335) * Refactor `ConnectionTrait` * Refactoring * Build index & foreign key statements * Fix imports * Fixup * Rocket example with migration * async-std compatible with the tokio 1.0 runtime * Use reexported dependency * Compile without selecting any db backend * Updating sea-orm-cli dep * sea-orm-cli migrate commands * cargo fmt * Test [cli] * Refactoring * Clap app name should be "sea-orm-cli" * Correctly capture MIGRATION_DIR * Rename README * Add `sea-orm-cli migrate init` command * Update README * Try restructured sea-query dependency (SeaQL/sea-schema#41) * Set `DATABASE_URL` environment variable * Fix sea-schema dependency * Codegen `column_name` proc_macro attribute (#433) * feat: codegen `column_name` proc_macro attribute * test: codegen `column_name` * Temporary fix * Fix sea-orm dependency * Insert Default - Inserting `ActiveModel` with all attributes `NotSet` (#432) * feat: apply alias on `ColumnRef::SchemaTableColumn` * build: update sea-query dependency * feat: insert default * Use sea-query 0.21 Co-authored-by: Billy Chan <[email protected]> * Easy joins with MockDatabase #447 (#455) * Easy joins with MockDatabase #447 * fix MR * add unit test * Add test cases * Cargo fmt Co-authored-by: Bastian Schubert <[email protected]> Co-authored-by: Billy Chan <[email protected]> Co-authored-by: Chris Tsang <[email protected]> * cargo fmt * Revert "Insert Default - Inserting `ActiveModel` with all attributes `NotSet` (#432)" This reverts commit 33a87d7. * Prepare release * sea-orm-codegen 0.6.0 * sea-orm-cli 0.6.0 * sea-orm-macros 0.6.0 * 0.6.0 * Optimize GitHub actions * Update examples sea-orm version Update example sea-schema version Update [cli] sea-schema version * Fix [cli] cargo publish failed * Update CHANGELOG * Use sea-schema 0.5.1 * use sea_schema::migration::prelude * Use caret requirements * Fix build error * Examples with migration (#509) * Update examples sea-orm version * Update example sea-schema version * Update [cli] sea-schema version * Fix [cli] cargo publish failed * Update CHANGELOG * Edit rocket example * Poem example with migration * Axum example with migration * Refactoring * Actix4 example with migration * Actix example with migration * Use sea_schema::migration::prelude Co-authored-by: Sunli <[email protected]> Co-authored-by: Billy Chan <[email protected]> Co-authored-by: Billy Chan <[email protected]> Co-authored-by: Szepesi Tibor <[email protected]> Co-authored-by: Tom Hacohen <[email protected]> Co-authored-by: Charles Chege <[email protected]> Co-authored-by: Bastian <[email protected]> Co-authored-by: Bastian Schubert <[email protected]>
- Loading branch information
1 parent
ccd0d97
commit 566c8c6
Showing
139 changed files
with
2,928 additions
and
396 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ members = [".", "sea-orm-macros", "sea-orm-codegen"] | |
|
||
[package] | ||
name = "sea-orm" | ||
version = "0.5.0" | ||
version = "0.6.0" | ||
authors = ["Chris Tsang <[email protected]>"] | ||
edition = "2021" | ||
description = "🐚 An async & dynamic ORM for Rust" | ||
|
@@ -29,8 +29,8 @@ futures = { version = "^0.3" } | |
futures-util = { version = "^0.3" } | ||
tracing = { version = "0.1", features = ["log"] } | ||
rust_decimal = { version = "^1", optional = true } | ||
sea-orm-macros = { version = "^0.5.0", path = "sea-orm-macros", optional = true } | ||
sea-query = { version = "^0.20.0", features = ["thread-safe"] } | ||
sea-orm-macros = { version = "^0.6.0", path = "sea-orm-macros", optional = true } | ||
sea-query = { version = "^0.21.0", features = ["thread-safe"] } | ||
sea-strum = { version = "^0.23", features = ["derive", "sea-orm"] } | ||
serde = { version = "^1.0", features = ["derive"] } | ||
serde_json = { version = "^1", optional = true } | ||
|
@@ -43,7 +43,7 @@ once_cell = "1.8" | |
[dev-dependencies] | ||
smol = { version = "^1.2" } | ||
smol-potat = { version = "^1.1" } | ||
async-std = { version = "^1.9", features = ["attributes"] } | ||
async-std = { version = "^1.9", features = ["attributes", "tokio1"] } | ||
tokio = { version = "^1.6", features = ["full"] } | ||
actix-rt = { version = "2.2.0" } | ||
maplit = { version = "^1" } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
HOST=127.0.0.1 | ||
PORT=8000 | ||
DATABASE_URL="mysql://root:@localhost/actix_example" | ||
DATABASE_URL="mysql://root:root@localhost/actix_example" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
[package] | ||
name = "entity" | ||
version = "0.1.0" | ||
edition = "2021" | ||
publish = false | ||
|
||
[lib] | ||
name = "entity" | ||
path = "src/lib.rs" | ||
|
||
[dependencies] | ||
serde = { version = "1", features = ["derive"] } | ||
|
||
[dependencies.sea-orm] | ||
# path = "../../../" # remove this line in your own project | ||
version = "^0.6.0" | ||
features = [ | ||
"macros", | ||
"debug-print", | ||
"runtime-actix-native-tls", | ||
"sqlx-mysql", | ||
# "sqlx-postgres", | ||
# "sqlx-sqlite", | ||
] | ||
default-features = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub mod post; | ||
|
||
pub use sea_orm; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[package] | ||
name = "migration" | ||
version = "0.1.0" | ||
edition = "2021" | ||
publish = false | ||
|
||
[lib] | ||
name = "migration" | ||
path = "src/lib.rs" | ||
|
||
[dependencies] | ||
sea-schema = { version = "^0.5.0", default-features = false, features = [ "migration", "debug-print" ] } | ||
entity = { path = "../entity" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Running Migrator CLI | ||
|
||
- Apply all pending migrations | ||
```sh | ||
cargo run | ||
``` | ||
```sh | ||
cargo run -- up | ||
``` | ||
- Apply first 10 pending migrations | ||
```sh | ||
cargo run -- up -n 10 | ||
``` | ||
- Rollback last applied migrations | ||
```sh | ||
cargo run -- down | ||
``` | ||
- Rollback last 10 applied migrations | ||
```sh | ||
cargo run -- down -n 10 | ||
``` | ||
- Drop all tables from the database, then reapply all migrations | ||
```sh | ||
cargo run -- fresh | ||
``` | ||
- Rollback all applied migrations, then reapply all migrations | ||
```sh | ||
cargo run -- refresh | ||
``` | ||
- Rollback all applied migrations | ||
```sh | ||
cargo run -- reset | ||
``` | ||
- Check the status of all migrations | ||
```sh | ||
cargo run -- status | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
pub use sea_schema::migration::prelude::*; | ||
|
||
mod m20220120_000001_create_post_table; | ||
|
||
pub struct Migrator; | ||
|
||
#[async_trait::async_trait] | ||
impl MigratorTrait for Migrator { | ||
fn migrations() -> Vec<Box<dyn MigrationTrait>> { | ||
vec![Box::new(m20220120_000001_create_post_table::Migration)] | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
examples/actix4_example/migration/src/m20220120_000001_create_post_table.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use entity::post::*; | ||
use sea_schema::migration::prelude::*; | ||
|
||
pub struct Migration; | ||
|
||
impl MigrationName for Migration { | ||
fn name(&self) -> &str { | ||
"m20220120_000001_create_post_table" | ||
} | ||
} | ||
|
||
#[async_trait::async_trait] | ||
impl MigrationTrait for Migration { | ||
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { | ||
manager | ||
.create_table( | ||
Table::create() | ||
.table(Entity) | ||
.if_not_exists() | ||
.col( | ||
ColumnDef::new(Column::Id) | ||
.integer() | ||
.not_null() | ||
.auto_increment() | ||
.primary_key(), | ||
) | ||
.col(ColumnDef::new(Column::Title).string().not_null()) | ||
.col(ColumnDef::new(Column::Text).string().not_null()) | ||
.to_owned(), | ||
) | ||
.await | ||
} | ||
|
||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { | ||
manager | ||
.drop_table(Table::drop().table(Entity).to_owned()) | ||
.await | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
use migration::Migrator; | ||
use sea_schema::migration::*; | ||
|
||
#[async_std::main] | ||
async fn main() { | ||
cli::run_cli(Migrator).await; | ||
} |
Oops, something went wrong.