Postgres notes - NamelessMC/Nameless-Link GitHub Wiki

Using psql

docker compose exec postgres psql -U postgres

Creating table

CREATE TABLE connections (
  id SERIAL PRIMARY KEY,
  guild_id BIGINT UNIQUE NOT NULL,
  api_url TEXT NOT NULL,
  api_key TEXT NOT NULL, 
  last_use BIGINT NOT NULL,
  username_sync BOOLEAN NULL DEFAULT false,
  UNIQUE(api_url, api_key)
);

Reindexing

postgres=# REINDEX INDEX connections_api_url_key;
REINDEX
postgres=# REINDEX INDEX connections_guild_id_key;
REINDEX
postgres=# REINDEX INDEX connections_pkey;
REINDEX