The application is trying to query email_verified and email_verification_deadline columns that don't exist in the database yet, causing SQL errors:
ERROR: column u1_0.email_verified does not exist
ERROR: column u1_0.email_verification_deadline does not exist
You need to run the migration script to add these columns to the PostgreSQL users table.
- Open PgAdmin
- Navigate to the
techtorquedatabase - Open the Query Editor
- Copy and paste the SQL from
Database/migrations/001_add_email_verification_fields.sql - Click "Execute" button
- Verify the operation completed successfully
# Connect to the database
psql -h localhost -U techtorque -d techtorque -f "Database/migrations/001_add_email_verification_fields.sql"
# When prompted, enter password: techtorque123# Copy the migration file to the container and execute
docker exec -i postgres_container psql -U techtorque -d techtorque < Database/migrations/001_add_email_verification_fields.sqlThe migration script performs the following operations:
ALTER TABLE users ADD COLUMN IF NOT EXISTS email_verified BOOLEAN NOT NULL DEFAULT false;- Type: BOOLEAN (true/false)
- Default: false (new users start as unverified)
- Not Null: Required field
ALTER TABLE users ADD COLUMN IF NOT EXISTS email_verification_deadline TIMESTAMP;- Type: TIMESTAMP (stores date and time)
- Default: NULL (set dynamically on registration)
- Can be NULL: For already verified users
UPDATE users
SET email_verification_deadline = NOW() + INTERVAL '7 days'
WHERE email_verification_deadline IS NULL AND email_verified = false;- Sets 7-day deadline for any existing unverified users
- Existing users who are already enabled are marked as verified
CREATE INDEX IF NOT EXISTS idx_users_email_verified ON users(email_verified);
CREATE INDEX IF NOT EXISTS idx_users_email_verification_deadline ON users(email_verification_deadline);- Improves query performance when filtering by verification status
- Helps with deadline-based queries
After running the migration, verify the columns exist:
- Go to Database → techtorque → Schemas → public → Tables → users
- Right-click and select "Properties"
- Look for
email_verifiedandemail_verification_deadlinecolumns
SELECT column_name, data_type, is_nullable
FROM information_schema.columns
WHERE table_name='users'
ORDER BY ordinal_position;You should see output similar to:
column_name | data_type | is_nullable
---------------------------------|-----------|-----------
id | bigint | NO
username | varchar | NO
email | varchar | NO
password | varchar | NO
enabled | boolean | NO
created_at | timestamp | NO
email_verified | boolean | NO
email_verification_deadline | timestamp | YES
...
-
Restart the Authentication Service
# If using Maven mvn spring-boot:run # If using Docker docker-compose restart auth-service
-
Test the Login Flow
- Register a new user
- Verify you can log in immediately
- Check profile page for verification status
- Test resend verification email button
-
Verify Email Link
- Check your email for verification link
- Click the link to verify email
- Confirm profile updates to "Email Verified ✓"
If you need to revert the migration:
-- Drop the indexes
DROP INDEX IF EXISTS idx_users_email_verified;
DROP INDEX IF EXISTS idx_users_email_verification_deadline;
-- Drop the columns
ALTER TABLE users DROP COLUMN IF EXISTS email_verified;
ALTER TABLE users DROP COLUMN IF EXISTS email_verification_deadline;The users table now has the following relevant columns:
| Column Name | Type | Nullable | Default | Purpose |
|---|---|---|---|---|
| id | BIGINT | NO | SERIAL | Primary key |
| username | VARCHAR | NO | User login name | |
| VARCHAR | NO | User email address | ||
| password | VARCHAR | NO | Encrypted password | |
| enabled | BOOLEAN | NO | true | Account active status |
| email_verified | BOOLEAN | NO | false | Email verification status |
| email_verification_deadline | TIMESTAMP | YES | NULL | 7-day verification deadline |
| created_at | TIMESTAMP | NO | NOW() | Account creation date |
This is normal if you've already run the migration. The IF NOT EXISTS clause prevents errors on re-runs.
Ensure you're using PostgreSQL syntax, not MySQL. The migration uses PostgreSQL-specific features like:
IF NOT EXISTSINTERVALfor date mathinformation_schemafor verification
- Verify the migration ran successfully
- Restart the application service
- Clear any database connection pools/caches
- Restart the entire application
- Apply immediately and test thoroughly
- Apply migration first
- Restart services
- Run full integration tests
- Verify user workflows
- Backup Database - Create a backup before migration
- Schedule Downtime - Plan during low-traffic period
- Apply Migration - Run the SQL script
- Restart Services - Restart all authentication services
- Monitor - Watch logs for errors
- Test - Verify registration and login flows
- Communicate - Notify users if needed
If you encounter issues:
- Check application logs for exact SQL error
- Verify PostgreSQL version (9.6+)
- Ensure user has ALTER TABLE permissions
- Verify column naming matches application code
- Check database connectivity and credentials