create extension if not exists "pgcrypto";

create table if not exists finance__invoices (
  id uuid primary key default gen_random_uuid(),
  customer_name text not null,
  amount numeric(12,2) not null,
  status text not null default 'draft',
  created_at timestamptz not null default now()
);

create table if not exists users__accounts (
  id uuid primary key default gen_random_uuid(),
  email text not null unique,
  full_name text not null,
  is_active boolean not null default true,
  created_at timestamptz not null default now()
);

create table if not exists logs__events (
  id uuid primary key default gen_random_uuid(),
  source text not null,
  level text not null,
  message text not null,
  created_at timestamptz not null default now()
);

insert into finance__invoices (customer_name, amount, status)
values
  ('Acme Corp', 1200.50, 'paid'),
  ('Northwind', 340.00, 'draft')
on conflict do nothing;

insert into users__accounts (email, full_name, is_active)
values
  ('root@example.com', 'Root Operator', true),
  ('analyst@example.com', 'Financial Analyst', true)
on conflict do nothing;

insert into logs__events (source, level, message)
values
  ('system', 'info', 'Bootstrap completed'),
  ('postgres', 'warn', 'Autovacuum threshold reached')
on conflict do nothing;
