CREATE TABLE public.channels (
	id bigserial NOT NULL,
	"uuid" int8 NOT NULL,
	username varchar(120) DEFAULT ''::character varying NOT NULL,
	title varchar(120) DEFAULT ''::character varying NOT NULL,
	created_at timestamptz(3) NULL,
	updated_at timestamptz(3) NULL,
	"offset" int8 DEFAULT 0 NOT NULL,
	min_id int8 DEFAULT 0 NOT NULL,
	CONSTRAINT channels_pk PRIMARY KEY (id)
);

CREATE TABLE public.channel_messages (
	id bigserial NOT NULL,
	channel_id int8 NOT NULL,
	"uuid" int8 NOT NULL,
	"content" text NULL,
	media jsonb DEFAULT '{}'::jsonb NOT NULL,
	published_at timestamptz(3) NOT NULL,
	created_at timestamptz(3) NOT NULL,
	group_id int8 DEFAULT 0 NOT NULL,
	published bool DEFAULT false NOT NULL,
	CONSTRAINT channel_messages_pk PRIMARY KEY (id),
	CONSTRAINT channel_messages_unique_channel_uuid UNIQUE (channel_id, uuid)
);
CREATE INDEX channel_messages_group_id_idx ON public.channel_messages USING btree (group_id);