使用sea-orm-cli生成数据库,sea-orm-cli migrate但这给出了错误
Result::unwrap()线程“main”在“调用一个值”时惊慌失措Err:Conn(“连接字符串‘sqlite://test.db’没有支持驱动程序。”)’, .../.cargo/registry/src/github.com -1ecc6299db9ec823/sea-orm-migration-0.8.3/src/cli.rs:17:45
这里有什么遗漏吗?Cargo.toml 包含 sqlite 功能,因此我认为这应该可行。
sea-orm = { version = "0.8.0", features = [ "sqlx-mysql", "sqlx-sqlite", "runtime-tokio-rustls", "macros", "debug-print", "mock" ] }
Run Code Online (Sandbox Code Playgroud) 使用 SeaOrm,我想创建一个没有关系的模型。本质上是一个带有一张表的数据库。
这看起来应该非常简单,但是文档没有涵盖这一点,并且DeriveEntityModel宏需要存在实体关系的所有样板。
我想要的是:
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "device")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
#[sea_orm(column_name = "uuid")]
pub uuid: Uuid,
#[sea_orm(column_name = "location")]
pub location: Option<String>,
#[sea_orm(column_name = "lastHeard")]
pub lastHeard: Option<DateTime>
}
Run Code Online (Sandbox Code Playgroud)
我得到的错误是:
cannot find type `Relation` in this scope
help: you might have meant to use the associated type: `Self::Relation`rustc(E0412)
the trait bound `models::device::ActiveModel: sea_orm::ActiveModelBehavior` is not satisfied
the trait `sea_orm::ActiveModelBehavior` is not implemented for `models::device::ActiveModel`
Run Code Online (Sandbox Code Playgroud)
我想必须有另一个宏可以使用,一个不需要关系的宏,但我在文档中找不到它。
我在 SeaORM、Rust 和 Postgres 上遇到了错误,我是数据库领域的新手,如果这是一个新手问题,那么很抱歉。我想使用 sea-orm-cli 刷新迁移,但出现此错误Execution Error: error returned from database: column "owner_id" referenced in foreign key constraint does not exist。
该命令的完整输出如下:
Running `cargo run --manifest-path ./migration/Cargo.toml -- fresh -u postgres://postgres@localhost:5432/task_manager`
Finished dev [unoptimized + debuginfo] target(s) in 0.54s
Running `migration/target/debug/migration fresh -u 'postgres://postgres@localhost:5432/task_manager'`
Dropping table 'seaql_migrations'
Table 'seaql_migrations' has been dropped
Dropping table 'owner'
Table 'owner' has been dropped
Dropping all types
Applying all pending migrations
Applying migration 'm20221106_182043_create_owner_table'
Migration 'm20221106_182043_create_owner_table' has been applied
Applying migration …Run Code Online (Sandbox Code Playgroud)