Add customer_id and order_id

This commit is contained in:
eraden 2022-04-18 08:08:55 +02:00
parent 8871f46738
commit b04f73cb51
3 changed files with 16 additions and 6 deletions

View File

@ -184,9 +184,18 @@ async fn server(opts: ServerOpts) -> Result<()> {
} }
async fn migrate(opts: MigrateOpts) -> Result<()> { async fn migrate(opts: MigrateOpts) -> Result<()> {
use sqlx::migrate::MigrateError;
let db = database::Database::build(&opts.db_url()).await?; let db = database::Database::build(&opts.db_url()).await?;
sqlx::migrate!("../db/migrate").run(db.pool()).await.expect("Failed to migrate"); let res: std::result::Result<(), MigrateError> =
Ok(()) sqlx::migrate!("../db/migrate").run(db.pool()).await;
match res {
Ok(()) => return Ok(()),
Err(e) => {
eprintln!("{e}");
std::process::exit(1);
}
};
} }
async fn generate_hash(_opts: GenerateHashOpts) -> Result<()> { async fn generate_hash(_opts: GenerateHashOpts) -> Result<()> {

View File

@ -1,5 +1,3 @@
BEGIN;
CREATE TYPE "Price" AS ( CREATE TYPE "Price" AS (
"value" integer, "value" integer,
"currency" varchar "currency" varchar
@ -10,5 +8,3 @@ ADD COLUMN "deliver_days_flag" int
NOT NULL NOT NULL
-- 0x1111111 -- 0x1111111
DEFAULT 127; DEFAULT 127;
COMMIT;

View File

@ -0,0 +1,5 @@
ALTER TABLE accounts
ADD COLUMN customer_id uuid not null default gen_random_uuid();
ALTER TABLE account_orders
ADD COLUMN order_id varchar unique;