+
Skip to content

Pr/471 #583

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 39 commits into from
Mar 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
2110293
Add Poem example
sunli829 Jan 13, 2022
946a03b
Merge pull request #446 from sunli829/master
tyt2y3 Jan 23, 2022
76c0d7f
Name conflict of foreign key constraints when two entities have more …
billy1624 Jan 27, 2022
15dc957
Add `max_lifetime` connection option
billy1624 Jan 28, 2022
660f233
Remove `r#` prefix from column name when field has a raw identifier
smrtrfszm Jan 29, 2022
30e7625
Fix FromQueryResult when Result is redefined
tasn Jan 30, 2022
52f38a1
Support the use of chrono::DateTime<Utc> in sea-orm
charleschege Jan 5, 2022
8145088
Refactoring
billy1624 Jan 26, 2022
7f3ad2e
Update sea-query dependency
tyt2y3 Feb 1, 2022
e63d463
Merge pull request #489 from SeaQL/date-time-utc-local
tyt2y3 Feb 1, 2022
5a2ccf5
Fully quantity `std::result::Result` in proc_maros
billy1624 Feb 1, 2022
8eb0953
Migration (#335)
billy1624 Feb 5, 2022
646990e
Merge pull request #495 from tasn/patch-1
tyt2y3 Feb 5, 2022
e305c66
Merge pull request #493 from SeaQL/max-lifetime-connection-opt
tyt2y3 Feb 5, 2022
3cde517
Fix sea-schema dependency
tyt2y3 Feb 5, 2022
21216f3
Codegen `column_name` proc_macro attribute (#433)
billy1624 Feb 5, 2022
cf793aa
Merge pull request #494 from smrtrfszm/master
tyt2y3 Feb 5, 2022
d7cdc4f
Temporary fix
tyt2y3 Feb 5, 2022
09e2ac8
Fix sea-orm dependency
tyt2y3 Feb 5, 2022
33a87d7
Insert Default - Inserting `ActiveModel` with all attributes `NotSet`…
tyt2y3 Feb 6, 2022
47f2f4c
Easy joins with MockDatabase #447 (#455)
cemoktra Feb 6, 2022
8b928a9
Merge pull request #505 from SeaQL/pull/455
tyt2y3 Feb 6, 2022
645a420
cargo fmt
tyt2y3 Feb 6, 2022
b8a7ae7
Revert "Insert Default - Inserting `ActiveModel` with all attributes …
tyt2y3 Feb 6, 2022
89f1b7f
Prepare release
tyt2y3 Feb 6, 2022
377205d
sea-orm-codegen 0.6.0
tyt2y3 Feb 6, 2022
0e2ea83
sea-orm-cli 0.6.0
tyt2y3 Feb 6, 2022
0c06831
sea-orm-macros 0.6.0
tyt2y3 Feb 6, 2022
c2ee25a
0.6.0
tyt2y3 Feb 6, 2022
d541f9e
Optimize GitHub actions
billy1624 Feb 7, 2022
cd98137
Update examples sea-orm version
billy1624 Feb 7, 2022
0a06892
Fix [cli] cargo publish failed
billy1624 Feb 7, 2022
2788833
Update CHANGELOG
billy1624 Feb 7, 2022
f8ab11d
Use sea-schema 0.5.1
tyt2y3 Feb 7, 2022
ea0342a
use sea_schema::migration::prelude
tyt2y3 Feb 7, 2022
54b1f4a
Use caret requirements
tyt2y3 Feb 7, 2022
e9a460b
Fix build error
tyt2y3 Feb 7, 2022
f418c4e
Examples with migration (#509)
billy1624 Feb 9, 2022
4bf35b4
Merge branch 'master' into pr/471
billy1624 Feb 12, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
runtime: [async-std, actix, tokio]
runtime: [async-std]
tls: [native-tls, rustls]
steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -165,7 +165,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
runtime: [async-std, actix, tokio]
runtime: [actix]
tls: [native-tls, rustls]
steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -204,7 +204,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
runtime: [async-std, actix, tokio]
runtime: [tokio]
tls: [native-tls, rustls]
steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -293,7 +293,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
path: [basic, actix_example, actix4_example, axum_example, rocket_example]
path: [basic, actix_example, actix4_example, axum_example, rocket_example, poem_example]
steps:
- uses: actions/checkout@v2

Expand Down Expand Up @@ -356,7 +356,7 @@ jobs:
strategy:
fail-fast: false
matrix:
runtime: [async-std, actix, tokio]
runtime: [async-std]
tls: [native-tls, rustls]
steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -400,7 +400,7 @@ jobs:
fail-fast: false
matrix:
version: [8.0, 5.7]
runtime: [async-std, actix, tokio]
runtime: [actix]
tls: [native-tls]
services:
mysql:
Expand Down Expand Up @@ -461,7 +461,7 @@ jobs:
fail-fast: false
matrix:
version: [10.6, 10.5, 10.4]
runtime: [async-std, actix, tokio]
runtime: [actix]
tls: [native-tls]
services:
mysql:
Expand Down
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,40 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## 0.6.0 - 2022-02-07

### New Features
* Migration Support by @billy1624 in https://github.com/SeaQL/sea-orm/pull/335
* Support `DateTime<Utc>` & `DateTime<Local>` by @billy1624 in https://github.com/SeaQL/sea-orm/pull/489
* Add `max_lifetime` connection option by @billy1624 in https://github.com/SeaQL/sea-orm/pull/493

### Enhancements
* Model with Generics by @billy1624 in https://github.com/SeaQL/sea-orm/pull/400
* Add Poem example by @sunli829 in https://github.com/SeaQL/sea-orm/pull/446
* Codegen `column_name` proc_macro attribute by @billy1624 in https://github.com/SeaQL/sea-orm/pull/433
* Easy joins with MockDatabase #447 by @cemoktra in https://github.com/SeaQL/sea-orm/pull/455

### Bug Fixes
* CLI allow generate entity with url without password by @billy1624 in https://github.com/SeaQL/sea-orm/pull/436
* Support up to 6-ary composite primary key by @billy1624 in https://github.com/SeaQL/sea-orm/pull/423
* Fix FromQueryResult when Result is redefined by @tasn in https://github.com/SeaQL/sea-orm/pull/495
* Remove `r#` prefix when deriving `FromQueryResult` by @smrtrfszm in https://github.com/SeaQL/sea-orm/pull/494

### Breaking Changes
* Name conflict of foreign key constraints when two entities have more than one foreign keys by @billy1624 in https://github.com/SeaQL/sea-orm/pull/417

### Fixed Issues
* Is it possible to have 4 values Composite Key? https://github.com/SeaQL/sea-orm/issues/352
* Support `DateTime<Utc>` & `DateTime<Local>` https://github.com/SeaQL/sea-orm/issues/381
* Codegen `column_name` proc_macro attribute if column name isn't in snake case https://github.com/SeaQL/sea-orm/issues/395
* Model with Generics https://github.com/SeaQL/sea-orm/issues/402
* Foreign key constraint collision when multiple keys exist between the same two tables https://github.com/SeaQL/sea-orm/issues/405
* sea-orm-cli passwordless database user causes "No password was found in the database url" error https://github.com/SeaQL/sea-orm/issues/435
* Testing joins with MockDatabase https://github.com/SeaQL/sea-orm/issues/447
* Surface max_lifetime connection option https://github.com/SeaQL/sea-orm/issues/475

**Full Changelog**: https://github.com/SeaQL/sea-orm/compare/0.5.0...0.6.0

## 0.5.0 - 2022-01-01

### Fixed Issues
Expand Down
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <tyt2y7@gmail.com>"]
edition = "2021"
description = "🐚 An async & dynamic ORM for Rust"
Expand All @@ -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 }
Expand All @@ -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" }
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Join our Discord server to chat with others in the SeaQL community!
+ [Rocket Example](https://github.com/SeaQL/sea-orm/tree/master/examples/rocket_example)
+ [Actix Example](https://github.com/SeaQL/sea-orm/tree/master/examples/actix_example)
+ [Axum Example](https://github.com/SeaQL/sea-orm/tree/master/examples/axum_example)
+ [Poem Example](https://github.com/SeaQL/sea-orm/tree/master/examples/poem_example)

## Features

Expand Down
2 changes: 1 addition & 1 deletion build-tools/cargo-publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ cd sea-orm-cli
sed -i 's/^version.*$/'"version = \"$1\"/" Cargo.toml
sed -i 's/^sea-orm-codegen [^,]*,/sea-orm-codegen = { version = "\^'$1'",/' Cargo.toml
git commit -am "sea-orm-cli $1"
cargo publish
# cargo publish
cd ..
sleep 30
cd sea-orm-macros
Expand Down
2 changes: 1 addition & 1 deletion examples/actix4_example/.env
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"
14 changes: 3 additions & 11 deletions examples/actix4_example/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ edition = "2021"
publish = false

[workspace]
members = [".", "entity", "migration"]

[dependencies]
actix-files = "0.6.0-beta.4"
Expand All @@ -19,14 +20,5 @@ dotenv = "0.15"
listenfd = "0.3.3"
serde = "1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }

[dependencies.sea-orm]
path = "../../" # remove this line in your own project
version = "^0.5.0"
features = ["macros", "runtime-actix-native-tls", "debug-print"]
default-features = false

[features]
default = ["sqlx-mysql"]
sqlx-mysql = ["sea-orm/sqlx-mysql"]
sqlx-postgres = ["sea-orm/sqlx-postgres"]
entity = { path = "entity" }
migration = { path = "migration" }
13 changes: 7 additions & 6 deletions examples/actix4_example/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
![screenshot](Screenshot.png)

# Actix 4 Beta with SeaORM example app

Edit `Cargo.toml` to use `sqlx-mysql` or `sqlx-postgres`.
1. Modify the `DATABASE_URL` var in `.env` to point to your chosen database

```toml
[features]
default = ["sqlx-$DATABASE"]
```
1. Turn on the appropriate database feature for your chosen db in `entity/Cargo.toml` (the `"sqlx-mysql",` line)

1. Execute `cargo run` to start the server

Edit `.env` to point to your database.
1. Visit [localhost:8000](http://localhost:8000) in browser

Run server with auto-reloading:

Expand Down
Binary file added examples/actix4_example/Screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions examples/actix4_example/entity/Cargo.toml
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
3 changes: 3 additions & 0 deletions examples/actix4_example/entity/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub mod post;

pub use sea_orm;
13 changes: 13 additions & 0 deletions examples/actix4_example/migration/Cargo.toml
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" }
37 changes: 37 additions & 0 deletions examples/actix4_example/migration/README.md
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
```
12 changes: 12 additions & 0 deletions examples/actix4_example/migration/src/lib.rs
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)]
}
}
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
}
}
7 changes: 7 additions & 0 deletions examples/actix4_example/migration/src/main.rs
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;
}
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载