Skip to content

Commit b2b7b88

Browse files
committed
Use more consistent naming for terms version data
1 parent 88e5b37 commit b2b7b88

9 files changed

Lines changed: 55 additions & 55 deletions

.sqlx/query-fcafcbd1c2e15f5a68d716e8f4fcfe36cc1181a5d2a31e34394d2d65188e8116.json renamed to .sqlx/query-1cdb91bdbd9b211559099ac1255b0a10fb2adbab14c872cdded57a0f6afd70c1.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.sqlx/query-3e7070853b6aa56a6748441df8ed6667f5bbdad38771be894c88c9f8800ae437.json

Lines changed: 0 additions & 14 deletions
This file was deleted.

.sqlx/query-59cfce5b939fc4c356842fe8307596cd4538ac41b30c99d47391af874c068660.json

Lines changed: 0 additions & 14 deletions
This file was deleted.

.sqlx/query-72eb1e45d1850cd0153a267519db593ad16b788486628a4089f06a2026d98d00.json

Lines changed: 0 additions & 15 deletions
This file was deleted.

.sqlx/query-b2bf692e4f8b177b109043bfa58dee718e0e8440ccade6ffdf87894e6c9e089c.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.sqlx/query-e330bdea2fc8b5b96b873ded8ef50e16eb9b2fc0a2eb53c265d1fbba162adc0e.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.sqlx/query-edab79efbe723f6aac26cc17ef9e788e2a969899fdb78ffdacc223f22ee290eb.json

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/db.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub(super) async fn initialize(db_url: &str) -> sqlx::Result<()> {
3838
.set(pool)
3939
.expect("database pool shouldn't already be initialized");
4040

41-
sync_terms_updates_to_db().await?;
41+
sync_terms_version_to_db().await?;
4242

4343
Ok(())
4444
}
@@ -49,7 +49,7 @@ pub(super) async fn initialize(db_url: &str) -> sqlx::Result<()> {
4949
/// # Errors
5050
///
5151
/// Returns an error if the database operations fail.
52-
async fn sync_terms_updates_to_db() -> Result<(), sqlx::Error> {
52+
async fn sync_terms_version_to_db() -> Result<(), sqlx::Error> {
5353
let mut hasher = Sha256::new();
5454
hasher.update(include_bytes!("../frontend/components/TermsOfService.md"));
5555
let terms_hash = hasher.finalize();
@@ -61,13 +61,13 @@ async fn sync_terms_updates_to_db() -> Result<(), sqlx::Error> {
6161
let privacy_hash = privacy_hash.as_slice();
6262

6363
transaction!(async |tx| -> TxResult<_, sqlx::Error> {
64-
let Some(user_agreement) =
65-
sqlx::query!("SELECT terms_hash, privacy_hash FROM user_agreement")
64+
let Some(terms_version) =
65+
sqlx::query!("SELECT terms_hash, privacy_hash FROM terms_version")
6666
.fetch_optional(tx.as_mut())
6767
.await?
6868
else {
6969
sqlx::query!(
70-
"INSERT INTO user_agreement (terms_hash, privacy_hash)
70+
"INSERT INTO terms_version (terms_hash, privacy_hash)
7171
VALUES ($1, $2)",
7272
terms_hash,
7373
privacy_hash,
@@ -78,9 +78,9 @@ async fn sync_terms_updates_to_db() -> Result<(), sqlx::Error> {
7878
return Ok(());
7979
};
8080

81-
if user_agreement.terms_hash != terms_hash {
81+
if terms_version.terms_hash != terms_hash {
8282
sqlx::query!(
83-
"UPDATE user_agreement
83+
"UPDATE terms_version
8484
SET terms_hash = $1,
8585
terms_updated_at = now()",
8686
terms_hash,
@@ -89,9 +89,9 @@ async fn sync_terms_updates_to_db() -> Result<(), sqlx::Error> {
8989
.await?;
9090
}
9191

92-
if user_agreement.privacy_hash != privacy_hash {
92+
if terms_version.privacy_hash != privacy_hash {
9393
sqlx::query!(
94-
"UPDATE user_agreement
94+
"UPDATE terms_version
9595
SET privacy_hash = $1,
9696
privacy_updated_at = now()",
9797
privacy_hash,

migrations/20240522023049_initialize.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CREATE EXTENSION citext;
22

3-
CREATE TABLE user_agreement (
3+
CREATE TABLE terms_version (
44
constrain_table_to_one_row boolean NOT NULL UNIQUE DEFAULT TRUE
55
CHECK (constrain_table_to_one_row),
66
updated_at timestamptz PRIMARY KEY

0 commit comments

Comments
 (0)