fix: add user to auth user
This commit is contained in:
parent
583edfdb72
commit
768d683878
|
|
@ -9,11 +9,13 @@ pub async fn setup_db(pool: &PgPool) -> anyhow::Result<()> {
|
|||
// migration scripts.
|
||||
sqlx::query(r#"create schema auth"#).execute(pool).await?;
|
||||
sqlx::query(
|
||||
r#"create table auth.users(
|
||||
id uuid NOT NULL UNIQUE,
|
||||
deleted_at timestamptz null,
|
||||
CONSTRAINT users_pkey PRIMARY KEY (id)
|
||||
)"#,
|
||||
r#"
|
||||
CREATE TABLE auth.users(
|
||||
id uuid NOT NULL UNIQUE,
|
||||
deleted_at timestamptz null,
|
||||
CONSTRAINT users_pkey PRIMARY KEY (id)
|
||||
)
|
||||
"#,
|
||||
)
|
||||
.execute(pool)
|
||||
.await?;
|
||||
|
|
@ -26,6 +28,19 @@ CONSTRAINT users_pkey PRIMARY KEY (id)
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn insert_auth_user(pool: &PgPool, user_uuid: Uuid) -> anyhow::Result<()> {
|
||||
sqlx::query(
|
||||
r#"
|
||||
INSERT INTO auth.users (id)
|
||||
VALUES ($1)
|
||||
"#,
|
||||
)
|
||||
.bind(user_uuid)
|
||||
.execute(pool)
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
pub static ref ID_GEN: RwLock<Snowflake> = RwLock::new(Snowflake::new(1));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::pg_sql::util::{setup_db, test_create_user};
|
||||
use crate::pg_sql::util::{insert_auth_user, setup_db, test_create_user};
|
||||
use sqlx::PgPool;
|
||||
|
||||
#[sqlx::test(migrations = false)]
|
||||
|
|
@ -9,6 +9,7 @@ async fn basic_test(pool: PgPool) -> sqlx::Result<()> {
|
|||
let name = user_uuid.to_string();
|
||||
let email = format!("{}@appflowy.io", name);
|
||||
|
||||
insert_auth_user(&pool, user_uuid).await.unwrap();
|
||||
test_create_user(&pool, user_uuid, &email, &name)
|
||||
.await
|
||||
.unwrap();
|
||||
|
|
|
|||
Loading…
Reference in New Issue