db to user_id
Some checks failed
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Failing after 40s

This commit is contained in:
2025-11-24 11:54:06 -08:00
parent 11049b3c6b
commit 1c08d2dab1
31 changed files with 868 additions and 854 deletions

View File

@@ -0,0 +1,32 @@
<#
.SYNOPSIS
SQL ROLLUP GENERATION SCRIPT (POWERSHELL)
.DESCRIPTION
This script automatically generates the 'master_schema_rollup.sql' file by
concatenating the individual SQL component files in the correct order.
WARNING: This will overwrite the existing master_schema_rollup.sql file.
.EXAMPLE
From the root of the project, run:
.\sql\generate_rollup.ps1
#>
# Set the script to stop on errors
$ErrorActionPreference = "Stop"
# Define file paths relative to the script's location
$PSScriptRoot = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition
$ProjectRoot = Resolve-Path -Path (Join-Path $PSScriptRoot "..")
$MasterFile = Join-Path $ProjectRoot "sql\master_schema_rollup.sql"
# The individual files to concatenate, IN ORDER.
$SourceFiles = @(
(Join-Path $ProjectRoot "sql\initial_schema.sql"),
(Join-Path $ProjectRoot "sql\initial_data.sql"),
(Join-Path $ProjectRoot "sql\initial_triggers_and_functions.sql")
)
Write-Host "Generating '$MasterFile' from source files..."
Get-Content -Path $SourceFiles | Set-Content -Path $MasterFile -Encoding UTF8
Write-Host "✅ Success: '$MasterFile' has been generated." -ForegroundColor Green

View File

@@ -0,0 +1,33 @@
#!/bin/bash
# ============================================================================
# SQL ROLLUP GENERATION SCRIPT (BASH)
# ============================================================================
# Purpose:
# This script automatically generates the 'master_schema_rollup.sql' file by
# concatenating the individual SQL component files in the correct order.
#
# WARNING: This will overwrite the existing master_schema_rollup.sql file.
#
# Usage:
# From the root of the project, run:
# bash sql/generate_rollup.sh
# ============================================================================
# Set the script to exit immediately if a command fails
set -e
# Define file paths relative to the project root
SQL_DIR="sql"
MASTER_FILE="$SQL_DIR/master_schema_rollup.sql"
# The individual files to concatenate, IN ORDER.
SOURCE_FILES=(
"$SQL_DIR/initial_schema.sql"
"$SQL_DIR/initial_data.sql"
"$SQL_DIR/initial_triggers_and_functions.sql"
)
echo "Generating '$MASTER_FILE' from source files..."
cat "${SOURCE_FILES[@]}" > "$MASTER_FILE"
echo "✅ Success: '$MASTER_FILE' has been generated."

View File

@@ -0,0 +1,52 @@
<#
.SYNOPSIS
SQL ROLLUP VERIFICATION SCRIPT (POWERSHELL)
.DESCRIPTION
This script verifies that the 'master_schema_rollup.sql' file is an exact
concatenation of the individual SQL component files. This helps ensure
that all database setup scripts are synchronized.
The script will exit with code 0 if they match, and 1 if they don't.
.EXAMPLE
From the root of the project, run:
.\sql\verify_rollup.ps1
#>
# Set the script to stop on errors
$ErrorActionPreference = "Stop"
# Define file paths relative to the script's location
$PSScriptRoot = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition
$ProjectRoot = Resolve-Path -Path (Join-Path $PSScriptRoot "..")
$MasterFile = Join-Path $ProjectRoot "sql\master_schema_rollup.sql"
# The individual files to concatenate, IN ORDER.
$SourceFiles = @(
(Join-Path $ProjectRoot "sql\initial_schema.sql"),
(Join-Path $ProjectRoot "sql\initial_data.sql"),
(Join-Path $ProjectRoot "sql\initial_triggers_and_functions.sql")
)
Write-Host "Comparing concatenated content with '$MasterFile'..."
# Compare the master file with the concatenated content of the source files.
$Difference = Compare-Object -ReferenceObject (Get-Content $MasterFile) -DifferenceObject (Get-Content $SourceFiles)
if ($null -eq $Difference) {
Write-Host "✅ Success: '$MasterFile' is up to date with the individual SQL files." -ForegroundColor Green
exit 0
} else {
Write-Host "❌ Error: '$MasterFile' is out of sync. Differences found." -ForegroundColor Red
Write-Host "--- $MasterFile"
Write-Host "+++ Concatenated Source Files"
# Format the output to look like a diff
foreach ($diffLine in $Difference) {
if ($diffLine.SideIndicator -eq "<=") {
Write-Host ("- " + $diffLine.InputObject) -ForegroundColor Red
} elseif ($diffLine.SideIndicator -eq "=>") {
Write-Host ("+ " + $diffLine.InputObject) -ForegroundColor Green
}
}
exit 1
}

View File

@@ -0,0 +1,53 @@
#!/bin/bash
# ============================================================================
# SQL ROLLUP VERIFICATION SCRIPT
# ============================================================================
# Purpose:
# This script verifies that the 'master_schema_rollup.sql' file is an exact
# concatenation of the individual SQL component files. This helps ensure
# that all database setup scripts are synchronized.
#
# Usage:
# From the root of the project, run:
# bash sql/verify_rollup.sh
#
# The script will exit with code 0 if they match, and 1 if they don't.
# ============================================================================
# Set the script to exit immediately if a command fails
set -e
# Define file paths relative to the project root
SQL_DIR="sql"
MASTER_FILE="$SQL_DIR/master_schema_rollup.sql"
# The individual files to concatenate, IN ORDER.
SOURCE_FILES=(
"$SQL_DIR/initial_schema.sql"
"$SQL_DIR/initial_data.sql"
"$SQL_DIR/initial_triggers_and_functions.sql"
)
# Create a temporary file to hold the concatenated content
TEMP_FILE=$(mktemp)
# Ensure the temporary file is removed when the script exits
trap 'rm -f "$TEMP_FILE"' EXIT
# Concatenate all source files into the temp file
echo "Concatenating source files into a temporary file..."
cat "${SOURCE_FILES[@]}" > "$TEMP_FILE"
echo "Comparing concatenated content with '$MASTER_FILE'..."
# Use 'diff' to compare the master file with the temporary concatenated file.
# The '-q' flag makes diff quiet and just exit with a status code.
if diff -q "$MASTER_FILE" "$TEMP_FILE"; then
echo "✅ Success: '$MASTER_FILE' is up to date with the individual SQL files."
exit 0
else
echo "❌ Error: '$MASTER_FILE' is out of sync. Differences found."
echo "To see the differences, run: diff -u \"$MASTER_FILE\" <(cat ${SOURCE_FILES[@]})"
exit 1
fi