S SmartDocs
Série: Go sql 18 lignes · Mis à jour 2026-04-18

create_tables.sql

Go/payment-gateway-challenge/scripts/create_tables.sql

-- Optional explicit DDL (the Go app also runs GORM AutoMigrate on startup).
-- UUID primary keys use PostgreSQL built-in gen_random_uuid() (PG 13+).

CREATE TABLE IF NOT EXISTS payments (
    id                 uuid PRIMARY KEY,
    status             varchar(20)  NOT NULL,
    card_last_four     varchar(4)   NOT NULL,
    card_number_length integer      NOT NULL,
    expiry_month       integer      NOT NULL,
    expiry_year        integer      NOT NULL,
    currency           varchar(3)   NOT NULL,
    amount             bigint       NOT NULL,
    authorization_code varchar(64),
    created_at         timestamptz  NOT NULL DEFAULT now()
);

CREATE INDEX IF NOT EXISTS idx_payments_status ON payments (status);
CREATE INDEX IF NOT EXISTS idx_payments_created_at ON payments (created_at);

Articles liés