Skip to content

Commit

Permalink
Merge pull request #420 from billy1624/sea-orm-v1.0
Browse files Browse the repository at this point in the history
SeaORM v1.0.0-rc.1
  • Loading branch information
kaplanelad authored Feb 8, 2024
2 parents a15d354 + 50b5e14 commit e485624
Show file tree
Hide file tree
Showing 19 changed files with 83 additions and 109 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ clap = { version = "4.4.7", features = ["derive"], optional = true }
colored = "2"


sea-orm = { version = "0.12.4", features = [
sea-orm = { version = "1.0.0-rc.1", features = [
"sqlx-postgres", # `DATABASE_DRIVER` feature
"sqlx-sqlite",
"runtime-tokio-rustls",
Expand Down Expand Up @@ -134,7 +134,7 @@ axum = { version = "0.7.1", features = ["macros"] }

[dependencies.sea-orm-migration]
optional = true
version = "0.12.4"
version = "1.0.0-rc.1"
features = [
# Enable at least one `ASYNC_RUNTIME` and `DATABASE_DRIVER` feature if you want to run migration via CLI.
# View the list of supported features at https://www.sea-ql.org/SeaORM/docs/install-and-config/database-and-async-runtime.
Expand Down
8 changes: 4 additions & 4 deletions docs-site/content/docs/getting-started/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,9 @@ impl MigrationTrait for Migration {
manager
.create_table(
table_auto(Articles::Table)
.col(pk_auto(Articles::Id).borrow_mut())
.col(string_null(Articles::Title).borrow_mut())
.col(text(Articles::Content).borrow_mut())
.col(pk_auto(Articles::Id))
.col(string_null(Articles::Title))
.col(text(Articles::Content))
.to_owned(),
)
.await
Expand Down Expand Up @@ -649,7 +649,7 @@ If you peek into the new migration, you'll discover a new database relation in t
```rust
..
..
.col(integer(Comments::ArticleId).borrow_mut())
.col(integer(Comments::ArticleId))
.foreign_key(
ForeignKey::create()
.name("fk-comments-articles")
Expand Down
2 changes: 1 addition & 1 deletion docs-site/content/docs/the-app/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Adding a column:
.alter_table(
Table::alter()
.table(Movies::Table)
.add_column_if_not_exists(integer(Movies::Rating).borrow_mut())
.add_column_if_not_exists(integer(Movies::Rating))
.to_owned(),
)
.await
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async-trait = "0.1.74"
tracing = "0.1.40"
chrono = "0.4"
validator = { version = "0.16" }
sea-orm = { version = "0.12.4", features = [
sea-orm = { version = "1.0.0-rc.1", features = [
"sqlx-sqlite",
"sqlx-postgres",
"runtime-tokio-rustls",
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/migration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ async-std = { version = "1", features = ["attributes", "tokio1"] }
loco-rs = { version = "*", path = "../../../" }

[dependencies.sea-orm-migration]
version = "0.12.6"
version = "1.0.0-rc.1"
features = [
# Enable at least one `ASYNC_RUNTIME` and `DATABASE_DRIVER` feature if you want to run migration via CLI.
# View the list of supported features at https://www.sea-ql.org/SeaORM/docs/install-and-config/database-and-async-runtime.
Expand Down
27 changes: 12 additions & 15 deletions examples/demo/migration/src/m20220101_000001_users.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use std::borrow::BorrowMut;

use loco_rs::schema::*;
use sea_orm_migration::prelude::*;
use sea_orm_migration::{prelude::*, schema::*};

#[derive(DeriveMigrationName)]
pub struct Migration;
Expand All @@ -10,17 +7,17 @@ pub struct Migration;
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
let table = table_auto(Users::Table)
.col(pk_auto(Users::Id).borrow_mut())
.col(uuid(Users::Pid).borrow_mut())
.col(string_uniq(Users::Email).borrow_mut())
.col(string(Users::Password).borrow_mut())
.col(string(Users::ApiKey).borrow_mut().unique_key())
.col(string(Users::Name).borrow_mut())
.col(string_null(Users::ResetToken).borrow_mut())
.col(timestamp_null(Users::ResetSentAt).borrow_mut())
.col(string_null(Users::EmailVerificationToken).borrow_mut())
.col(timestamp_null(Users::EmailVerificationSentAt).borrow_mut())
.col(timestamp_null(Users::EmailVerifiedAt).borrow_mut())
.col(pk_auto(Users::Id))
.col(uuid(Users::Pid))
.col(string_uniq(Users::Email))
.col(string(Users::Password))
.col(string(Users::ApiKey).unique_key())
.col(string(Users::Name))
.col(string_null(Users::ResetToken))
.col(timestamp_null(Users::ResetSentAt))
.col(string_null(Users::EmailVerificationToken))
.col(timestamp_null(Users::EmailVerificationSentAt))
.col(timestamp_null(Users::EmailVerifiedAt))
.to_owned();
manager.create_table(table).await?;
Ok(())
Expand Down
11 changes: 4 additions & 7 deletions examples/demo/migration/src/m20231103_114510_notes.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use std::borrow::BorrowMut;

use loco_rs::schema::*;
use sea_orm_migration::prelude::*;
use sea_orm_migration::{prelude::*, schema::*};

#[derive(DeriveMigrationName)]
pub struct Migration;
Expand All @@ -12,9 +9,9 @@ impl MigrationTrait for Migration {
manager
.create_table(
table_auto(Notes::Table)
.col(pk_auto(Notes::Id).borrow_mut())
.col(string_null(Notes::Title).borrow_mut())
.col(string_null(Notes::Content).borrow_mut())
.col(pk_auto(Notes::Id))
.col(string_null(Notes::Title))
.col(string_null(Notes::Content))
.to_owned(),
)
.await
Expand Down
7 changes: 2 additions & 5 deletions src/gen/templates/migration.t
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ injections:
before: "pub struct Migrator"
content: "mod {{module_name}};"
---
use std::borrow::BorrowMut;

use loco_rs::schema::*;
use sea_orm_migration::prelude::*;
use sea_orm_migration::{prelude::*, schema::*};

#[derive(DeriveMigrationName)]
pub struct Migration;
Expand All @@ -37,7 +34,7 @@ impl MigrationTrait for Migration {
.alter_table(
Table::alter()
.table(Movies::Table)
.add_column_if_not_exists(integer(Movies::Rating).borrow_mut())
.add_column_if_not_exists(integer(Movies::Rating))
.to_owned(),
)
.await
Expand Down
11 changes: 4 additions & 7 deletions src/gen/templates/model.t
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ injections:
before: "pub struct Migrator"
content: "mod {{module_name}};"
---
use std::borrow::BorrowMut;

use loco_rs::schema::*;
use sea_orm_migration::prelude::*;
use sea_orm_migration::{prelude::*, schema::*};

#[derive(DeriveMigrationName)]
pub struct Migration;
Expand All @@ -35,13 +32,13 @@ impl MigrationTrait for Migration {
{% for ref in references -%}
.col({{model}}::{{ref.1 | pascal_case}})
{% endfor -%}
.borrow_mut(),
,
)
{% else -%}
.col(pk_auto({{model}}::Id).borrow_mut())
.col(pk_auto({{model}}::Id))
{% endif -%}
{% for column in columns -%}
.col({{column.1}}({{model}}::{{column.0 | pascal_case}}).borrow_mut())
.col({{column.1}}({{model}}::{{column.0 | pascal_case}}))
{% endfor -%}
{% for ref in references -%}
.foreign_key(
Expand Down
18 changes: 8 additions & 10 deletions src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
//! the schema helpers to create the Db fields.
//!
//! ```rust
//! use loco_rs::schema::*;
//! use sea_orm_migration::prelude::*;
//! use std::borrow::BorrowMut;
//! use sea_orm_migration::{prelude::*, schema::*};
//!
//! #[derive(DeriveMigrationName)]
//! pub struct Migration;
Expand All @@ -20,13 +18,13 @@
//! impl MigrationTrait for Migration {
//! async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
//! let table = table_auto(Users::Table)
//! .col(pk_auto(Users::Id).borrow_mut())
//! .col(uuid(Users::Pid).borrow_mut())
//! .col(string_uniq(Users::Email).borrow_mut())
//! .col(string(Users::Password).borrow_mut())
//! .col(string(Users::Name).borrow_mut())
//! .col(string_null(Users::ResetToken).borrow_mut())
//! .col(timestamp_null(Users::ResetSentAt).borrow_mut())
//! .col(pk_auto(Users::Id))
//! .col(uuid(Users::Pid))
//! .col(string_uniq(Users::Email))
//! .col(string(Users::Password))
//! .col(string(Users::Name))
//! .col(string_null(Users::ResetToken))
//! .col(timestamp_null(Users::ResetSentAt))
//! .to_owned();
//! manager.create_table(table).await?;
//! Ok(())
Expand Down
4 changes: 2 additions & 2 deletions starters/lightweight-service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition = "2021"

[dependencies]

loco-rs = { version = "0.2.3", default-features = false, features = ["cli"] }
loco-rs = { version = "*", path = "../../", default-features = false, features = ["cli"] }
serde = "*"
serde_json = "*"
eyre = "*"
Expand All @@ -28,7 +28,7 @@ required-features = []
[dev-dependencies]
serial_test = "*"
rstest = "*"
loco-rs = { version = "0.2.3", default-features = false, features = [
loco-rs = { version = "*", path = "../../", default-features = false, features = [
"testing",
"cli",
] }
Expand Down
6 changes: 3 additions & 3 deletions starters/rest-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition = "2021"

[dependencies]

loco-rs = { version = "0.2.3" }
loco-rs = { version = "*", path = "../../" }
migration = { path = "migration" }

serde = { version = "1", features = ["derive"] }
Expand All @@ -20,7 +20,7 @@ async-trait = "0.1.74"
tracing = "0.1.40"
chrono = "0.4"
validator = { version = "0.16" }
sea-orm = { version = "0.12.4", features = [
sea-orm = { version = "1.0.0-rc.1", features = [
"sqlx-sqlite",
"sqlx-postgres",
"runtime-tokio-rustls",
Expand All @@ -40,5 +40,5 @@ required-features = []
[dev-dependencies]
serial_test = "2.0.0"
rstest = "0.18.2"
loco-rs = { version = "0.2.3", features = ["testing"] }
loco-rs = { version = "*", path = "../../", features = ["testing"] }
insta = { version = "1.34.0", features = ["redactions", "yaml", "filters"] }
4 changes: 2 additions & 2 deletions starters/rest-api/migration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ path = "src/lib.rs"

[dependencies]
async-std = { version = "1", features = ["attributes", "tokio1"] }
loco-rs = { version = "0.2.3" }
loco-rs = { version = "*", path = "../../../" }

[dependencies.sea-orm-migration]
version = "0.12.4"
version = "1.0.0-rc.1"
features = [
# Enable at least one `ASYNC_RUNTIME` and `DATABASE_DRIVER` feature if you want to run migration via CLI.
# View the list of supported features at https://www.sea-ql.org/SeaORM/docs/install-and-config/database-and-async-runtime.
Expand Down
27 changes: 12 additions & 15 deletions starters/rest-api/migration/src/m20220101_000001_users.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use std::borrow::BorrowMut;

use loco_rs::schema::*;
use sea_orm_migration::prelude::*;
use sea_orm_migration::{prelude::*, schema::*};

#[derive(DeriveMigrationName)]
pub struct Migration;
Expand All @@ -10,17 +7,17 @@ pub struct Migration;
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
let table = table_auto(Users::Table)
.col(pk_auto(Users::Id).borrow_mut())
.col(uuid(Users::Pid).borrow_mut())
.col(string_uniq(Users::Email).borrow_mut())
.col(string(Users::Password).borrow_mut())
.col(string(Users::ApiKey).borrow_mut().unique_key())
.col(string(Users::Name).borrow_mut())
.col(string_null(Users::ResetToken).borrow_mut())
.col(timestamp_null(Users::ResetSentAt).borrow_mut())
.col(string_null(Users::EmailVerificationToken).borrow_mut())
.col(timestamp_null(Users::EmailVerificationSentAt).borrow_mut())
.col(timestamp_null(Users::EmailVerifiedAt).borrow_mut())
.col(pk_auto(Users::Id))
.col(uuid(Users::Pid))
.col(string_uniq(Users::Email))
.col(string(Users::Password))
.col(string(Users::ApiKey).unique_key())
.col(string(Users::Name))
.col(string_null(Users::ResetToken))
.col(timestamp_null(Users::ResetSentAt))
.col(string_null(Users::EmailVerificationToken))
.col(timestamp_null(Users::EmailVerificationSentAt))
.col(timestamp_null(Users::EmailVerifiedAt))
.to_owned();
manager.create_table(table).await?;
Ok(())
Expand Down
11 changes: 4 additions & 7 deletions starters/rest-api/migration/src/m20231103_114510_notes.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use std::borrow::BorrowMut;

use loco_rs::schema::*;
use sea_orm_migration::prelude::*;
use sea_orm_migration::{prelude::*, schema::*};

#[derive(DeriveMigrationName)]
pub struct Migration;
Expand All @@ -12,9 +9,9 @@ impl MigrationTrait for Migration {
manager
.create_table(
table_auto(Notes::Table)
.col(pk_auto(Notes::Id).borrow_mut())
.col(string_null(Notes::Title).borrow_mut())
.col(string_null(Notes::Content).borrow_mut())
.col(pk_auto(Notes::Id))
.col(string_null(Notes::Title))
.col(string_null(Notes::Content))
.to_owned(),
)
.await
Expand Down
6 changes: 3 additions & 3 deletions starters/saas/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition = "2021"

[dependencies]

loco-rs = { version = "0.2.3" }
loco-rs = { version = "*", path = "../../" }
migration = { path = "migration" }

serde = { version = "1", features = ["derive"] }
Expand All @@ -20,7 +20,7 @@ async-trait = "0.1.74"
tracing = "0.1.40"
chrono = "0.4"
validator = { version = "0.16" }
sea-orm = { version = "0.12.4", features = [
sea-orm = { version = "1.0.0-rc.1", features = [
"sqlx-sqlite",
"sqlx-postgres",
"runtime-tokio-rustls",
Expand All @@ -40,5 +40,5 @@ required-features = []
[dev-dependencies]
serial_test = "2.0.0"
rstest = "0.18.2"
loco-rs = { version = "0.2.3", features = ["testing"] }
loco-rs = { version = "*", path = "../../", features = ["testing"] }
insta = { version = "1.34.0", features = ["redactions", "yaml", "filters"] }
4 changes: 2 additions & 2 deletions starters/saas/migration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ path = "src/lib.rs"

[dependencies]
async-std = { version = "1", features = ["attributes", "tokio1"] }
loco-rs = { version = "0.2.3" }
loco-rs = { version = "*", path = "../../../" }

[dependencies.sea-orm-migration]
version = "0.12.4"
version = "1.0.0-rc.1"
features = [
# Enable at least one `ASYNC_RUNTIME` and `DATABASE_DRIVER` feature if you want to run migration via CLI.
# View the list of supported features at https://www.sea-ql.org/SeaORM/docs/install-and-config/database-and-async-runtime.
Expand Down
Loading

0 comments on commit e485624

Please sign in to comment.