Skip to content

Commit a9e5120

Browse files
committed
fix github workflow lint
1 parent 25e8350 commit a9e5120

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

internal/database/connection.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"os"
77
"time"
88

9+
"github.com/jackc/pgx/v5/pgconn"
910
"github.com/jackc/pgx/v5/pgxpool"
1011
)
1112

@@ -42,6 +43,10 @@ func InitSchema(ctx context.Context, pool *pgxpool.Pool, schemaPath string) erro
4243

4344
_, err = pool.Exec(ctx, string(schema))
4445
if err != nil {
46+
// Ignore "already exists" errors (42P07) to allow idempotency
47+
if pgErr, ok := err.(*pgconn.PgError); ok && pgErr.Code == "42P07" {
48+
return nil
49+
}
4550
return fmt.Errorf("failed to execute schema: %w", err)
4651
}
4752

schema.sql

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22
-- Database Schema for CAPY (Club Assistant in Python)
33

44
-- 1. ENUMs & Functions
5-
DO $$ BEGIN
6-
CREATE TYPE user_role AS ENUM ('student', 'alumni', 'faculty', 'external');
7-
EXCEPTION
8-
WHEN duplicate_object THEN null;
9-
END $$;
5+
CREATE TYPE user_role AS ENUM ('student', 'alumni', 'faculty', 'external');
106

117
CREATE OR REPLACE FUNCTION update_modified_column()
128
RETURNS TRIGGER AS $$

0 commit comments

Comments
 (0)