mirror of
https://github.com/storytold/artcraft-services.git
synced 2026-11-25 12:01:11 +01:00
remove the desktop app from the repo
This commit is contained in:
1 parent
889f6c3a4c
commit
cb1bea9d0a
1520 files changed
+507
-101087
No files matched your search
@@ -1,29 +1,23 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Regenerates the workspace-root `.sqlx/` offline query cache for BOTH query
|
||||
# crates:
|
||||
#
|
||||
# 1. `sqlite_tasks` — desktop app "tasks" queries, checked against a scratch
|
||||
# SQLite database migrated from `_database/sql/artcraft_migrations`.
|
||||
# 2. `mysql_queries` — backend queries, checked against the local dev MySQL
|
||||
# (the `DATABASE_URL` in the repo root `.env`, overridable via env).
|
||||
# Regenerates the workspace-root `.sqlx/` offline query cache for
|
||||
# `mysql_queries`, checked against the local development MySQL database.
|
||||
# Uses DATABASE_URL from the environment or the repository-root `.env`.
|
||||
#
|
||||
# Requirements:
|
||||
# - sqlx-cli matching the workspace sqlx version, with both drivers:
|
||||
# - sqlx-cli matching the workspace sqlx version, with the MySQL driver:
|
||||
# cargo install sqlx-cli --version 0.7.4 --no-default-features \
|
||||
# --features mysql,sqlite,rustls --locked
|
||||
# --features mysql,rustls --locked
|
||||
# - A running local MySQL with the migrated dev database.
|
||||
#
|
||||
# The new cache is staged in a temp directory and only replaces the old
|
||||
# `.sqlx/*.json` files after BOTH prepares succeed, so a failure part-way
|
||||
# `.sqlx/*.json` files after preparation succeeds, so a failure part-way
|
||||
# never leaves the repo without a query cache.
|
||||
|
||||
set -euxo pipefail
|
||||
set -euo pipefail
|
||||
|
||||
root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
|
||||
sqlite_db_file="/tmp/tasks.sqlite"
|
||||
sqlite_package_path="${root_dir}/crates/schema/database/sqlite_tasks"
|
||||
mysql_package_path="${root_dir}/crates/schema/database/mysql_queries"
|
||||
|
||||
query_cache_dir="${root_dir}/.sqlx"
|
||||
@@ -33,25 +27,6 @@ staging_dir="$(mktemp -d /tmp/sqlx_codegen.XXXXXX)"
|
||||
# .env so the script works from any directory.
|
||||
mysql_database_url="${DATABASE_URL:-$(grep -m1 '^DATABASE_URL=mysql' "${root_dir}/.env" | cut -d= -f2-)}"
|
||||
|
||||
prepare_sqlite_tasks() {
|
||||
echo "Creating a fresh Tauri SQLite tasks database..."
|
||||
rm -f "${sqlite_db_file}"
|
||||
touch "${sqlite_db_file}"
|
||||
|
||||
echo "Migrating the SQLite tasks database..."
|
||||
cargo sqlx migrate run \
|
||||
--database-url "sqlite:${sqlite_db_file}" \
|
||||
--source "${root_dir}/_database/sql/artcraft_migrations"
|
||||
|
||||
echo "Preparing the SQLite tasks query cache..."
|
||||
pushd "${sqlite_package_path}"
|
||||
cargo sqlx prepare \
|
||||
--database-url "sqlite:${sqlite_db_file}"
|
||||
popd
|
||||
|
||||
mv "${sqlite_package_path}/.sqlx/"*.json "${staging_dir}/"
|
||||
}
|
||||
|
||||
prepare_mysql() {
|
||||
echo "Preparing the MySQL query cache..."
|
||||
pushd "${mysql_package_path}"
|
||||
@@ -69,21 +44,20 @@ replace_query_cache() {
|
||||
mv "${staging_dir}/"*.json "${query_cache_dir}/"
|
||||
rmdir "${staging_dir}"
|
||||
|
||||
# Remove the (now empty) per-package cache dirs so sqlx never resolves
|
||||
# Remove the (now empty) per-package cache directory so sqlx never resolves
|
||||
# offline queries against a stale crate-local cache instead of the
|
||||
# workspace root one.
|
||||
rmdir "${sqlite_package_path}/.sqlx" "${mysql_package_path}/.sqlx" 2>/dev/null || true
|
||||
rmdir "${mysql_package_path}/.sqlx" 2>/dev/null || true
|
||||
}
|
||||
|
||||
# The sqlx macros only emit query metadata when the crates actually
|
||||
# recompile; a fresh (cached) build would yield an EMPTY cache. Force both
|
||||
# query crates to rebuild.
|
||||
cargo clean -p sqlite_tasks -p mysql_queries
|
||||
# recompile; a fresh (cached) build would yield an EMPTY cache. Force the
|
||||
# query crate to rebuild.
|
||||
cargo clean -p mysql_queries
|
||||
|
||||
# Prepare must expand the macros against the live databases.
|
||||
export SQLX_OFFLINE=false
|
||||
|
||||
prepare_sqlite_tasks
|
||||
prepare_mysql
|
||||
replace_query_cache
|
||||
|
||||
|
||||
Reference in new issue
Block a user