Code cleanup
Moved migrations/ into entity/ MessageIds now return errors except for API ones
This commit is contained in:
@ -10,4 +10,9 @@ workspace = true
|
||||
|
||||
[dependencies]
|
||||
futures = "0.3"
|
||||
sqlx = "0.7"
|
||||
sqlx = { version = "0.7", features = [
|
||||
"mysql",
|
||||
"runtime-tokio-rustls",
|
||||
"macros",
|
||||
"migrate",
|
||||
], default-features = false }
|
||||
|
5
entity/build.rs
Normal file
5
entity/build.rs
Normal file
@ -0,0 +1,5 @@
|
||||
// generated by `sqlx migrate build-script`
|
||||
fn main() {
|
||||
// trigger recompilation when a new migration is added
|
||||
println!("cargo:rerun-if-changed=migrations");
|
||||
}
|
3
entity/migrations/0001_init.down.sql
Normal file
3
entity/migrations/0001_init.down.sql
Normal file
@ -0,0 +1,3 @@
|
||||
DROP TABLE account;
|
||||
|
||||
DROP TABLE master_pass;
|
16
entity/migrations/0001_init.up.sql
Normal file
16
entity/migrations/0001_init.up.sql
Normal file
@ -0,0 +1,16 @@
|
||||
CREATE TABLE
|
||||
master_pass (
|
||||
user_id BIGINT UNSIGNED NOT NULL PRIMARY KEY,
|
||||
salt BINARY(64) NOT NULL,
|
||||
password_hash BINARY(64) NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE
|
||||
account (
|
||||
user_id BIGINT UNSIGNED NOT NULL,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
salt BINARY(64) NOT NULL,
|
||||
enc_login VARBINARY(256) NOT NULL,
|
||||
enc_password VARBINARY(256) NOT NULL,
|
||||
PRIMARY KEY (user_id, name)
|
||||
);
|
@ -5,6 +5,8 @@ pub mod account;
|
||||
pub mod master_pass;
|
||||
pub mod prelude;
|
||||
|
||||
pub use sqlx::Result;
|
||||
pub use sqlx::{mysql::MySqlPool as Pool, Result};
|
||||
|
||||
pub type Pool = sqlx::mysql::MySqlPool;
|
||||
pub async fn migrate(pool: &Pool) -> Result<(), sqlx::migrate::MigrateError> {
|
||||
sqlx::migrate!().run(pool).await
|
||||
}
|
||||
|
@ -1,2 +1 @@
|
||||
pub use crate::account::Account;
|
||||
pub use crate::master_pass::MasterPass;
|
||||
pub use crate::{account::Account, master_pass::MasterPass, Pool};
|
||||
|
Reference in New Issue
Block a user