Compare commits

..

No commits in common. "f7e643ffbd092e51daaa654f82b56bd68bdc851e" and "d09b28006112dffe7f72a2f5817ea9374974638e" have entirely different histories.

7 changed files with 14 additions and 53 deletions

View File

@ -1,10 +1,11 @@
use askama::Template; use askama::Template;
use axum::{ use axum::{
extract::{Path, Query, State}, response::{Html, IntoResponse, Redirect, Response}, Extension body::Body, extract::{Path, Query, Request, State}, response::{Html, IntoResponse, Redirect, Response}, Extension
}; };
use http::StatusCode; use http::StatusCode;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use sqlx::{PgPool, Row}; use serde_json::json;
use sqlx::{types::Json, PgPool, Row};
use crate::{ use crate::{
middlewares::is_authorized, middlewares::is_authorized,

View File

@ -5,7 +5,7 @@ use axum::{
}; };
use dotenvy::var; use dotenvy::var;
use secret_gift_exchange::{giftexchange, giftexchange_save, giftexchanges}; use secret_gift_exchange::{giftexchange, giftexchange_save, giftexchanges};
use sqlx::{migrate::Migrator, sqlite::SqlitePoolOptions, Row, SqlitePool}; use sqlx::{migrate::Migrator, sqlite::SqlitePoolOptions, sqlite::SqliteRow, Row, SqlitePool};
use sqlx::{postgres::PgPoolOptions, PgPool}; use sqlx::{postgres::PgPoolOptions, PgPool};
use std::net::SocketAddr; use std::net::SocketAddr;
use tower_http::services::ServeDir; use tower_http::services::ServeDir;
@ -25,7 +25,7 @@ use error_handling::AppError;
use google_oauth::{google_auth_return, login, logout}; use google_oauth::{google_auth_return, login, logout};
use middlewares::inject_user_data; use middlewares::inject_user_data;
use routes::{about, contact, dashboard, index, profile, user_profile, user_profile_account, useradmin}; use routes::{about, contact, dashboard, index, profile, user_profile, user_profile_account, useradmin};
use user::{add_user_role, delete_user_role, UserData}; use user::{add_user_role, delete_user_role, user_account, UserData};
use wishlist::{ use wishlist::{
user_wishlist, user_wishlist_add, user_wishlist_add_item, user_wishlist_bought_item, user_wishlist, user_wishlist_add, user_wishlist_add_item, user_wishlist_bought_item,
user_wishlist_delete_item, user_wishlist_edit_item, user_wishlist_received_item, user_wishlist_delete_item, user_wishlist_edit_item, user_wishlist_received_item,
@ -51,10 +51,10 @@ async fn main() {
static MIGRATOR: Migrator = sqlx::migrate!(); static MIGRATOR: Migrator = sqlx::migrate!();
MIGRATOR /* MIGRATOR
.run(&app_state.db_pool) .run(&app_state.db_pool)
.await .await
.expect("Failed to run migrations"); .expect("Failed to run migrations"); */
// Copy from old sqlite database if it exists // Copy from old sqlite database if it exists
if let Ok(source_db_url) = var("SOURCE_DB_URL") { if let Ok(source_db_url) = var("SOURCE_DB_URL") {
@ -315,45 +315,4 @@ async fn copy_database(sdb_pool: &SqlitePool, db_pool: &PgPool) {
println!("Error: {}", e); println!("Error: {}", e);
} }
} }
// Run migration scripts again
// Copy accounts(users) to profiles(people)
let result =sqlx::query(r#"insert into people (created_by, updated_by, email, name, family_name, given_name)
select created_by, updated_by, email, name, family_name, given_name from users
on conflict do nothing;"#)
.execute(db_pool)
.await;
if let Err(e) = result {
println!("Error: {}", e);
}
// Link accounts to profiles
let result = sqlx::query(r#"update users u set person_id = p.id from people p where p.email = u.email;"#)
.execute(db_pool)
.await;
if let Err(e) = result {
println!("Error: {}", e);
}
// Move wishlist items from accounts to profiles
let result = sqlx::query(r#"update wishlist_items wi set user_id = p.person_id from users p where p.id = wi.user_id;"#)
.execute(db_pool)
.await;
if let Err(e) = result {
println!("Error: {}", e);
}
// Copy normal role from accounts to profiles
let result = sqlx::query(r#"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;"#)
.execute(db_pool)
.await;
if let Err(e) = result {
println!("Error: {}", e);
}
} }

View File

@ -5,6 +5,7 @@ use axum::{
Extension, Extension,
}; };
use http::StatusCode; use http::StatusCode;
use reqwest::redirect;
use sqlx::PgPool; use sqlx::PgPool;
use uuid::Uuid; use uuid::Uuid;

View File

@ -1,9 +1,9 @@
use askama::Template; use askama::Template;
use axum::{ use axum::{
body::{self, Body}, body::{self, Body},
extract::{Path, Request, State}, extract::{FromRequest, Path, Request, State},
response::{Html, IntoResponse, Redirect, Response}, response::{Html, IntoResponse, Redirect, Response},
Extension, Extension, Form, Json, RequestExt,
}; };
use http::{header::CONTENT_TYPE, StatusCode}; use http::{header::CONTENT_TYPE, StatusCode};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};

View File

@ -72,7 +72,7 @@
<div class="row fixed-bottom sticky-bottom"> <div class="row fixed-bottom sticky-bottom">
<div class="container-fluid text-center bg-light"> <div class="container-fluid text-center bg-light">
<footer> <footer>
<p>© 2025 Jean-Marie family</p> <p>© 2024 Jean-Marie family</p>
</footer> </footer>
</div><!-- /.container --> </div><!-- /.container -->
</div> </div>

View File

@ -2,6 +2,6 @@ cargo build --release
ssh www@192.168.59.11 'pkill jean-marie' ssh www@192.168.59.11 'pkill jean-marie'
scp target/release/jean-marie www@192.168.59.11:/opt/jean-marie scp target/release/jean-marie www@192.168.59.11:/opt/jean-marie
scp runsite.sh www@192.168.59.11:/opt/jean-marie scp runsite.sh www@192.168.59.11:/opt/jean-marie
scp prod.env www@192.168.59.11:/opt/jean-marie scp .env www@192.168.59.11:/opt/jean-marie
scp -r templates www@192.168.59.11:/opt/jean-marie scp -r templates www@192.168.59.11:/opt/jean-marie
#ssh www@192.168.59.11 '/opt/jean-marie/runsite.sh' ssh www@192.168.59.11 '/opt/jean-marie/runsite.sh'

View File

@ -2,6 +2,6 @@ cargo build --release
ssh chris@192.168.59.31 'pkill jean-marie' ssh chris@192.168.59.31 'pkill jean-marie'
scp target/release/jean-marie chris@192.168.59.31:/opt/jean-marie scp target/release/jean-marie chris@192.168.59.31:/opt/jean-marie
scp runsite.sh chris@192.168.59.31:/opt/jean-marie scp runsite.sh chris@192.168.59.31:/opt/jean-marie
scp test.env chris@192.168.59.31:/opt/jean-marie/.env #scp .env chris@192.168.59.31:/opt/jean-marie
scp -r templates chris@192.168.59.31:/opt/jean-marie scp -r templates chris@192.168.59.31:/opt/jean-marie
ssh chris@192.168.59.31 '/opt/jean-marie/runsite.sh' ssh chris@192.168.59.31 '/opt/jean-marie/runsite.sh'