diff --git a/.env b/.env
index f54a4c2..07b8778 100644
--- a/.env
+++ b/.env
@@ -1 +1 @@
-DATABASE_URL="sqlite://dolltags.sqlite"
+DATABASE_URL="postgres://postgres:woofwoof@localhost/dolltags"
diff --git a/.gitignore b/.gitignore
index 51b0e40..be8553b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,2 @@
# built binary
-cap
/target
-*.sqlite*
diff --git a/Cargo.toml b/Cargo.toml
index af42855..e253010 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -6,9 +6,9 @@ edition = "2021"
[dependencies]
rocket = "0.5.1"
rocket_dyn_templates = { version = "0.2.0", features = ["tera"] }
-rocket_db_pools = { version = "0.2.0", features = ["sqlx_sqlite"] }
+rocket_db_pools = { version = "0.2.0", features = ["sqlx_postgres"] }
sqlx = { version = "0.7", default-features = false, features = [
- "sqlite",
+ "postgres",
"macros",
"chrono",
"migrate",
diff --git a/README.md b/README.md
index a9bd536..c9f4705 100644
--- a/README.md
+++ b/README.md
@@ -29,4 +29,3 @@ a profile is
- ability to delete a tag (remove all data except the ID to lock the ID)
- ability to delete the whole account (incl. all registered tags)
- deleting a tag keeping the account allows to re-use the tag later on. no one else can use it still
-- pgsql migration? may make hosting easier for me as well as cleaner migrations and types
diff --git a/Rocket.toml b/Rocket.toml
index d115462..686ac52 100644
--- a/Rocket.toml
+++ b/Rocket.toml
@@ -1,2 +1,2 @@
[default.databases.dolltags]
-url = "dolltags.sqlite"
+url = "postgres://postgres:woofwoof@localhost/dolltags"
diff --git a/migrations/1_base.sql b/migrations/1_base.sql
index 835baae..39623f1 100644
--- a/migrations/1_base.sql
+++ b/migrations/1_base.sql
@@ -1,26 +1,23 @@
--- base schema
+create table doll_profiles (
+ id integer not null primary key,
+ microchip_id varchar(32) unique,
+ created_at timestamptz not null default current_timestamp,
+ updated_at timestamptz,
--- notnulls are tmp till i deal with proper validation
-create table if not exists doll_profiles (
- id integer not null primary key, -- 000000 format
- created_at text not null default current_timestamp,
- updated_at text,
+ name varchar(256) not null,
+ pronoun_subject varchar(32) not null,
+ pronoun_object varchar(32) not null,
+ pronoun_possessive varchar(32) not null,
- -- base info
- name text not null,
- pronouns text not null, -- format as `{subject}/{object}/{possessive}` eg `she/her/hers`
- handler_name text not null,
- handler_url text,
+ handler_name varchar(256) not null,
+ handler_link varchar(2048),
- -- customisation options for various entities
- description text,
- kind text,
- breed text,
- chassis_type text,
- chassis_id text,
- chassis_color text,
+ kind varchar(256),
+ breed varchar(256),
+ behaviour varchar(256),
+ description varchar(2048),
- -- ID'ing
- behaviour text,
- microchip_id text unique
-) strict;
+ chassis_type varchar(256),
+ chassis_id varchar(256),
+ chassis_color varchar(256)
+);
diff --git a/shell.nix b/shell.nix
index 90b8777..e472d0e 100644
--- a/shell.nix
+++ b/shell.nix
@@ -9,7 +9,7 @@ pkgs.mkShell {
# native dependencies
# pkg-config
# Dev env
- sqlite sqlitebrowser sqlx-cli
+ sqlx-cli
]
);
@@ -19,5 +19,4 @@ pkgs.mkShell {
# Rust
# See https://discourse.nixos.org/t/rust-src-not-found-and-other-misadventures-of-developing-rust-on-nixos/11570/3?u=samuela. for more details.
RUST_SRC_PATH = pkgs.rust.packages.stable.rustPlatform.rustLibSrc;
- DATABASE_URL = "sqlite://dolltags.sqlite";
}
diff --git a/src/db/doll.rs b/src/db/doll.rs
index ccbe3fa..29c5918 100644
--- a/src/db/doll.rs
+++ b/src/db/doll.rs
@@ -1,51 +1,41 @@
use crate::db::schema::DollProfile;
-use sqlx::{pool::PoolConnection, types::chrono, Sqlite};
+use sqlx::{pool::PoolConnection, Postgres};
use super::schema::{CreateDollProfile, DollTagsDb};
pub async fn get(
mut db: DollTagsDb,
- ident: i64,
+ ident: i32,
microchip_id: &str,
) -> sqlx::Result
- {{ macros::pretty_pronouns(pronouns=profile.pronouns) }}
+
+ {{profile.pronoun_subject}} /
+ {{profile.pronoun_object}} /
+ {{profile.pronoun_possessive}}
+
{{profile.name}}