Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Events table #46

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ log
1
projects/**/target
development/resources/system.edn

/tmp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP TABLE IF EXISTS events;
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CREATE TABLE IF NOT EXISTS events (
id UUID PRIMARY KEY NOT NULL DEFAULT gen_random_uuid(),
tenant_id BIGINT NOT NULL,
processed BOOLEAN NOT NULL DEFAULT false,
type TEXT NOT NULL,
payload JSONB NOT NULL
);

--;;

CREATE INDEX IF NOT EXISTS idx_events_tenant_processed ON events (tenant_id, processed);
76 changes: 76 additions & 0 deletions components/database/resources/database/migrations/schema.sql
Original file line number Diff line number Diff line change
@@ -1 +1,77 @@
--
-- PostgreSQL database dump
--

-- Dumped from database version 16.5 (Debian 16.5-1.pgdg120+1)
-- Dumped by pg_dump version 16.3

SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;

SET default_tablespace = '';

SET default_table_access_method = heap;

--
-- Name: events; Type: TABLE; Schema: public; Owner: venn
--

CREATE TABLE public.events (
id uuid DEFAULT gen_random_uuid() NOT NULL,
tenant_id bigint NOT NULL,
processed boolean DEFAULT false NOT NULL,
type text NOT NULL,
payload jsonb NOT NULL
);


ALTER TABLE public.events OWNER TO venn;

--
-- Name: schema_migrations; Type: TABLE; Schema: public; Owner: venn
--

CREATE TABLE public.schema_migrations (
id bigint NOT NULL,
applied timestamp without time zone,
description character varying(1024)
);


ALTER TABLE public.schema_migrations OWNER TO venn;

--
-- Name: events events_pkey; Type: CONSTRAINT; Schema: public; Owner: venn
--

ALTER TABLE ONLY public.events
ADD CONSTRAINT events_pkey PRIMARY KEY (id);


--
-- Name: schema_migrations schema_migrations_id_key; Type: CONSTRAINT; Schema: public; Owner: venn
--

ALTER TABLE ONLY public.schema_migrations
ADD CONSTRAINT schema_migrations_id_key UNIQUE (id);


--
-- Name: idx_events_tenant_processed; Type: INDEX; Schema: public; Owner: venn
--

CREATE INDEX idx_events_tenant_processed ON public.events USING btree (tenant_id, processed);


--
-- PostgreSQL database dump complete
--

6 changes: 4 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
services:
venn_development_db:
container_name: venn_development_db
image: postgres
image: postgres:16
restart: always
environment:
POSTGRES_USER: venn
Expand All @@ -11,11 +11,13 @@ services:
- 5432:5432
venn_test_db:
container_name: venn_test_db
image: postgres
image: postgres:16
restart: always
environment:
POSTGRES_USER: venn
POSTGRES_DB: venn_test
POSTGRES_PASSWORD: password
volumes:
- ./tmp/data:/var/lib/postgrsql/data
ports:
- 5433:5432
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{:hooks
{:analyze-call
{next.jdbc/with-transaction
hooks.com.github.seancorfield.next-jdbc/with-transaction
next.jdbc/with-transaction+options
hooks.com.github.seancorfield.next-jdbc/with-transaction+options}}
:lint-as {next.jdbc/on-connection clojure.core/with-open
next.jdbc/on-connection+options clojure.core/with-open}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
(ns hooks.com.github.seancorfield.next-jdbc
(:require [clj-kondo.hooks-api :as api]))

(defn with-transaction

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[clj-kondo] reported by reviewdog 🐶
redefined var #'hooks.com.github.seancorfield.next-jdbc/with-transaction

"Expands (with-transaction [tx expr opts] body)
to (let [tx expr] opts body) per clj-kondo examples."
[{:keys [:node]}]
(let [[binding-vec & body] (rest (:children node))
[sym val opts] (:children binding-vec)]
(when-not (and sym val)
(throw (ex-info "No sym and val provided" {})))
(let [new-node (api/list-node
(list*
(api/token-node 'let)
(api/vector-node [sym val])
opts
body))]
{:node new-node})))

(defn with-transaction+options

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[clj-kondo] reported by reviewdog 🐶
redefined var #'hooks.com.github.seancorfield.next-jdbc/with-transaction+options

"Expands (with-transaction+options [tx expr opts] body)
to (let [tx expr] opts body) per clj-kondo examples."
[{:keys [:node]}]
(let [[binding-vec & body] (rest (:children node))
[sym val opts] (:children binding-vec)]
(when-not (and sym val)
(throw (ex-info "No sym and val provided" {})))
(let [new-node (api/list-node
(list*
(api/token-node 'let)
(api/vector-node [sym val])
opts
body))]
{:node new-node})))
Loading