text: CREATE DATABASE "simple_bank";
  
  CREATE TABLE IF NOT EXISTS "accounts" (
    "id" bigserial PRIMARY KEY,
    "owner" varchar NOT NULL,
    "balance" bigint NOT NULL,
    "currency" varchar NOT NULL,
    "created_at" timestamptz NOT NULL DEFAULT (now())
  );
  
  CREATE TABLE IF NOT EXISTS "entries" (
    "id" bigserial PRIMARY KEY,
    "account_id" bigint NOT NULL,
    "amount" bigint NOT NULL,
    "created_at" timestamptz NOT NULL DEFAULT (now())
  );
  
  CREATE TABLE IF NOT EXISTS "transfers" (
    "id" bigserial PRIMARY KEY,
    "from_account_id" bigint NOT NULL,
    "to_account_id" bigint NOT NULL,
    "amount" bigint NOT NULL,
    "created_at" timestamptz NOT NULL DEFAULT (now())
  );
  
  ALTER TABLE "entries" ADD FOREIGN KEY ("account_id") REFERENCES "accounts" ("id");
  
  ALTER TABLE "transfers" ADD FOREIGN KEY ("from_account_id") REFERENCES "accounts" ("id");
  
  ALTER TABLE "transfers" ADD FOREIGN KEY ("to_account_id") REFERENCES "accounts" ("id");
  
  CREATE INDEX ON "accounts" ("owner");
  
  CREATE INDEX ON "entries" ("account_id");
  
  CREATE INDEX ON "transfers" ("from_account_id");
  
  CREATE INDEX ON "transfers" ("to_account_id");
  
  CREATE INDEX ON "transfers" ("from_account_id", "to_account_id");
  
  COMMENT ON TABLE "accounts" IS '账户表';
  
  COMMENT ON COLUMN "accounts"."id" IS '账户Id';
  
  COMMENT ON COLUMN "accounts"."balance" IS '数额';
  
  COMMENT ON COLUMN "accounts"."currency" IS '币种';
  
  COMMENT ON COLUMN "entries"."amount" IS '转账数量';
  