Adds scripts for automatic database log cleanup, schema migration application, and cron job setup. Modifies the update script to apply SQL migrations before pushing Drizzle schema. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 7a657272-55ba-4a79-9a2e-f1ed9bc7a528 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: 9a659f15-d68a-4b7d-99f8-3eccc59afebe Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/449cf7c4-c97a-45ae-8234-e5c5b8d6a84f/7a657272-55ba-4a79-9a2e-f1ed9bc7a528/4LjHWWz
36 lines
946 B
SQL
36 lines
946 B
SQL
-- Migration 001: Add missing columns to routers table
|
|
-- Date: 2025-11-21
|
|
-- Description: Adds api_port and last_sync columns if missing
|
|
|
|
-- Add api_port column if not exists
|
|
ALTER TABLE routers
|
|
ADD COLUMN IF NOT EXISTS api_port integer NOT NULL DEFAULT 8728;
|
|
|
|
-- Add last_sync column if not exists
|
|
ALTER TABLE routers
|
|
ADD COLUMN IF NOT EXISTS last_sync timestamp;
|
|
|
|
-- Add created_at if missing (fallback for older schemas)
|
|
ALTER TABLE routers
|
|
ADD COLUMN IF NOT EXISTS created_at timestamp DEFAULT now() NOT NULL;
|
|
|
|
-- Verify columns exist
|
|
DO $$
|
|
BEGIN
|
|
IF EXISTS (
|
|
SELECT 1 FROM information_schema.columns
|
|
WHERE table_name = 'routers'
|
|
AND column_name = 'api_port'
|
|
) THEN
|
|
RAISE NOTICE 'Column api_port exists';
|
|
END IF;
|
|
|
|
IF EXISTS (
|
|
SELECT 1 FROM information_schema.columns
|
|
WHERE table_name = 'routers'
|
|
AND column_name = 'last_sync'
|
|
) THEN
|
|
RAISE NOTICE 'Column last_sync exists';
|
|
END IF;
|
|
END $$;
|