This documentation provides all the manual commands from the SnailyCAD administration scripts. You can execute these commands directly using PostgreSQL command line tools or any database client.
Warning
Always backup your database before running these commands. Some operations are irreversible.
# Set environment variable for password
export PGPASSWORD="your_password"
# Connect to database
psql -U your_username -d your_database -h localhost -p 5432
# Navigate to PostgreSQL bin directory
cd "C:\Program Files\PostgreSQL\pgAdmin\ie-15-16V\bin"
# Set password for this session
set PGPASSWORD=your_password
# Connect to PostgreSQL database
psql -U your_username ^
-d your_database ^
-h localhost ^
-p 5432
Display all users with their ID, username, and Discord ID.
SELECT row_number() OVER () AS num, id, username, "discordId"
FROM public."User"
ORDER BY username;
Find users associated with a specific Discord ID.
SELECT id, username, "discordId"
FROM public."User"
WHERE "discordId" = 'REPLACE_WITH_DISCORD_ID';
Remove Discord ID association from a user account.
UPDATE public."User"
SET "discordId" = NULL
WHERE "discordId" = 'REPLACE_WITH_DISCORD_ID';
Show users who don't have a Discord ID linked (first 10).
SELECT id, username
FROM public."User"
WHERE "discordId" IS NULL AND username IS NOT NULL
LIMIT 10;
Required for password encryption. Run this first.
CREATE EXTENSION IF NOT EXISTS pgcrypto;
Reset a user's password using their username.
UPDATE public."User"
SET password = crypt('NEW_PASSWORD_HERE', gen_salt('bf'))
WHERE username = 'USERNAME_HERE';
Reset password using the row number from the user list.
UPDATE public."User"
SET password = crypt('NEW_PASSWORD_HERE', gen_salt('bf'))
WHERE username = (
SELECT username FROM (
SELECT row_number() OVER () AS num, username
FROM public."User"
WHERE username IS NOT NULL
ORDER BY username
) t WHERE num = ROW_NUMBER_HERE
);
Check current whitelist status for all CADs.
SELECT id, name, whitelisted
FROM public."cad";
Disable whitelist for ALL CADs (allows open registration).
UPDATE public."cad"
SET whitelisted = false;
Enable whitelist for a specific CAD by name.
UPDATE public."cad"
SET whitelisted = true
WHERE name = 'CAD_NAME_HERE';
Check the status of all CAD features.
SELECT feature, "isEnabled"
FROM public."CadFeature"
ORDER BY feature;
Allow users to login with username and password.
UPDATE public."CadFeature"
SET "isEnabled" = true
WHERE feature = 'ALLOW_REGULAR_LOGIN';
Disable forced Discord authentication.
UPDATE public."CadFeature"
SET "isEnabled" = false
WHERE feature = 'DISCORD_AUTH';
Enable Steam login authentication.
UPDATE public."CadFeature"
SET "isEnabled" = true
WHERE feature = 'STEAM_OAUTH';
Check the status of a specific feature.
SELECT "isEnabled"
FROM public."CadFeature"
WHERE feature = 'FEATURE_NAME_HERE';
Clean up dead rows and update statistics.
VACUUM ANALYZE;
Update query planner statistics.
ANALYZE;
Check database statistics and integrity.
SELECT schemaname, tablename, attname, n_distinct, correlation
FROM pg_stats
WHERE schemaname = 'public'
LIMIT 10;
Display the current database size.
SELECT pg_size_pretty(pg_database_size(current_database())) as database_size;
Display currently active database connections.
SELECT pid, usename, application_name, client_addr, state, query_start
FROM pg_stat_activity
WHERE state = 'active';
When Discord authentication is broken and you need to enable regular login.
-- Enable regular login
UPDATE public."CadFeature" SET "isEnabled" = true WHERE feature = 'ALLOW_REGULAR_LOGIN';
-- Disable Discord authentication
UPDATE public."CadFeature" SET "isEnabled" = false WHERE feature = 'DISCORD_AUTH';
-- Optional: Reset password for admin user
CREATE EXTENSION IF NOT EXISTS pgcrypto;
UPDATE public."User" SET password = crypt('newpassword', gen_salt('bf')) WHERE username = 'admin';
When you need to allow new users to register freely.
-- Disable CAD whitelist (allow open registration)
UPDATE public."cad" SET whitelisted = false;
-- Verify the change
SELECT id, name, whitelisted FROM public."cad";
When Discord accounts are causing login problems.
-- Find users with Discord issues
SELECT id, username, "discordId" FROM public."User" WHERE "discordId" IS NOT NULL;
-- Unlink specific Discord ID
UPDATE public."User" SET "discordId" = NULL WHERE "discordId" = 'PROBLEMATIC_DISCORD_ID';
-- Enable regular login as backup
UPDATE public."CadFeature" SET "isEnabled" = true WHERE feature = 'ALLOW_REGULAR_LOGIN';
If you prefer to use the full interactive scripts instead of individual commands:
# Make the script executable
chmod +x full-snailycad-recovery.sh
# Run the script
./full-snailycad-recovery.sh
REM Run the script
recover.bat