Move wishlists to the profile
This commit is contained in:
parent
1589ebfd37
commit
a8ca9bfafe
|
|
@ -27,4 +27,9 @@ select created_by, updated_by, email, name, family_name, given_name from users;
|
|||
update users u set person_id = p.id from people p where p.email = u.email;
|
||||
|
||||
-- Move wishlist items from accounts to profiles
|
||||
update wishlist_items wi set user_id = p.person_id from users p where p.id = wi.user_id;
|
||||
update wishlist_items wi set user_id = p.person_id from users p where p.id = wi.user_id;
|
||||
|
||||
-- Copy normal role from accounts to profiles
|
||||
insert into user_roles (created_at, created_by, updated_at, updated_by, user_id, role_id)
|
||||
select ur.created_at, ur.created_by, ur.updated_at, ur.updated_by, u.person_id, ur.role_id from user_roles ur join roles r on r.id = ur.role_id join users u on u.id = ur.user_id where r.name = 'normal'
|
||||
on conflict do nothing;
|
||||
|
|
|
|||
|
|
@ -51,10 +51,10 @@ async fn main() {
|
|||
|
||||
static MIGRATOR: Migrator = sqlx::migrate!();
|
||||
|
||||
MIGRATOR
|
||||
/* MIGRATOR
|
||||
.run(&app_state.db_pool)
|
||||
.await
|
||||
.expect("Failed to run migrations");
|
||||
.expect("Failed to run migrations"); */
|
||||
|
||||
// Copy from old sqlite database if it exists
|
||||
if let Ok(source_db_url) = var("SOURCE_DB_URL") {
|
||||
|
|
|
|||
|
|
@ -57,7 +57,10 @@ pub async fn wishlists(
|
|||
let user = user_data.as_ref().unwrap().clone();
|
||||
let userid = user_data.as_ref().map(|s| s.id.clone()).unwrap_or_default();
|
||||
|
||||
let users = sqlx::query_as::<_, UserData>("SELECT * FROM people order by name")
|
||||
let users = sqlx::query_as::<_, UserData>(r#"SELECT p.* FROM people p
|
||||
left join user_roles ur on ur.user_id = p.id
|
||||
left join roles r on r.id = ur.role_id
|
||||
where r.name = 'normal' order by p.name;"#)
|
||||
.fetch_all(&db_pool)
|
||||
.await
|
||||
.unwrap();
|
||||
|
|
|
|||
Loading…
Reference in New Issue