Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions install-database.sql
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,11 @@ CREATE TRIGGER update_qsl_images_updated_at
FOR EACH ROW EXECUTE FUNCTION update_updated_at_column();

-- Create LoTW credentials table for certificate management
-- Create LoTW credentials table
CREATE TABLE lotw_credentials (
id SERIAL PRIMARY KEY,
station_id INTEGER NOT NULL REFERENCES stations(id) ON DELETE CASCADE,
name VARCHAR(255) NOT NULL,
callsign VARCHAR(50) NOT NULL,
p12_cert BYTEA NOT NULL,
cert_created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
Expand All @@ -424,6 +426,9 @@ CREATE TABLE lotw_credentials (
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- Create index for active certificates lookup
CREATE INDEX idx_lotw_credentials_station_active ON lotw_credentials(station_id, is_active);

-- Create LoTW upload logs table
CREATE TABLE lotw_upload_logs (
id SERIAL PRIMARY KEY,
Expand Down
13 changes: 13 additions & 0 deletions migrations/add_name_to_lotw_credentials.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-- Migration: Add name column to lotw_credentials table
-- This migration adds the 'name' column to the lotw_credentials table

-- Add name column (allow NULL initially for existing records)
ALTER TABLE lotw_credentials ADD COLUMN IF NOT EXISTS name VARCHAR(255);

-- Update existing records with a default name
UPDATE lotw_credentials
SET name = 'old K1AF Certificate ' || id
WHERE name IS NULL;

-- Make the column NOT NULL after populating existing records
ALTER TABLE lotw_credentials ALTER COLUMN name SET NOT NULL;
Loading