Skip to content

Instantly share code, notes, and snippets.

View stalcottsmith's full-sized avatar

Steven Talcott Smith stalcottsmith

View GitHub Profile
@ak4zh
ak4zh / accounting.sql
Last active October 21, 2023 04:03 — forked from NYKevin/accounting.sql
Basic double-entry bookkeeping system, for PostgreSQL.
CREATE TABLE account_groups
(
id bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 9223372036854775807 CACHE 1 ),
name text COLLATE pg_catalog."default" NOT NULL,
account_group_id bigint,
CONSTRAINT account_types_pkey PRIMARY KEY (id),
CONSTRAINT account_groups_account_group_id_fkey FOREIGN KEY (account_group_id)
REFERENCES public.account_groups (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION,
@NYKevin
NYKevin / accounting.sql
Last active April 3, 2024 15:46
Basic double-entry bookkeeping system, for PostgreSQL.
CREATE TABLE accounts(
id serial PRIMARY KEY,
name VARCHAR(256) NOT NULL
);
CREATE TABLE entries(
id serial PRIMARY KEY,
description VARCHAR(1024) NOT NULL,
amount NUMERIC(20, 2) NOT NULL CHECK (amount > 0.0),
-- Every entry is a credit to one account...