Skip to content

Commit

Permalink
Use a static SQL dump to seed the ffs_postgres database
Browse files Browse the repository at this point in the history
  • Loading branch information
joshleecreates committed Jan 7, 2024
1 parent 3895edc commit 07b6493
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 53 deletions.
7 changes: 6 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -540,9 +540,14 @@ services:
# ******************
# Postgres used by Feature Flag service
ffs_postgres:
image: postgres:16.1
image: ${IMAGE_NAME}:${IMAGE_VERSION}-ffs_postgres
container_name: postgres
user: postgres
build:
context: ./
dockerfile: ./src/ffs_postgres/Dockerfile
cache_from:
- ${IMAGE_NAME}:${IMAGE_VERSION}-ffs_postgres
deploy:
resources:
limits:
Expand Down

This file was deleted.

2 changes: 0 additions & 2 deletions src/featureflagservice/rel/overlays/bin/server
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@

cd -P -- "$(dirname -- "$0")"

./featureflagservice eval Featureflagservice.Release.migrate || { echo "Database setup or migrations failed."; exit 1; }

PHX_SERVER=true exec ./featureflagservice start
4 changes: 4 additions & 0 deletions src/ffs_postgres/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM postgres:16.1
WORKDIR /app
COPY ./src/ffs_postgres/init.sh /docker-entrypoint-initdb.d
COPY ./src/ffs_postgres/dump.sql ./dump.sql
106 changes: 106 additions & 0 deletions src/ffs_postgres/dump.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
--
-- PostgreSQL database dump
--

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

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: featureflags; Type: TABLE; Schema: public; Owner: ffs
--

CREATE TABLE public.featureflags (
id bigint NOT NULL,
name character varying(255),
description character varying(255),
enabled double precision DEFAULT 0.0 NOT NULL,
inserted_at timestamp(0) without time zone NOT NULL,
updated_at timestamp(0) without time zone NOT NULL
);


ALTER TABLE public.featureflags OWNER TO ffs;

--
-- Name: featureflags_id_seq; Type: SEQUENCE; Schema: public; Owner: ffs
--

CREATE SEQUENCE public.featureflags_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;


ALTER SEQUENCE public.featureflags_id_seq OWNER TO ffs;

--
-- Name: featureflags_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: ffs
--

ALTER SEQUENCE public.featureflags_id_seq OWNED BY public.featureflags.id;


ALTER TABLE public.schema_migrations OWNER TO ffs;

--
-- Name: featureflags id; Type: DEFAULT; Schema: public; Owner: ffs
--

ALTER TABLE ONLY public.featureflags ALTER COLUMN id SET DEFAULT nextval('public.featureflags_id_seq'::regclass);


--
-- Data for Name: featureflags; Type: TABLE DATA; Schema: public; Owner: ffs
--

COPY public.featureflags (id, name, description, enabled, inserted_at, updated_at) FROM stdin;
1 productCatalogFailure Fail product catalog service on a specific product 0 2024-01-07 20:06:29 2024-01-07 20:06:29
2 recommendationCache Cache recommendations 0 2024-01-07 20:06:29 2024-01-07 20:06:29
3 adServiceFailure Fail ad service requests sporadically 0 2024-01-07 20:06:29 2024-01-07 20:06:29
4 cartServiceFailure Fail cart service requests sporadically 0 2024-01-07 20:06:29 2024-01-07 20:06:29
\.


--
-- Name: featureflags_id_seq; Type: SEQUENCE SET; Schema: public; Owner: ffs
--

SELECT pg_catalog.setval('public.featureflags_id_seq', 4, true);


--
-- Name: featureflags featureflags_pkey; Type: CONSTRAINT; Schema: public; Owner: ffs
--

ALTER TABLE ONLY public.featureflags
ADD CONSTRAINT featureflags_pkey PRIMARY KEY (id);


--
-- Name: featureflags_name_index; Type: INDEX; Schema: public; Owner: ffs
--

CREATE UNIQUE INDEX featureflags_name_index ON public.featureflags USING btree (name);


--
-- PostgreSQL database dump complete
--

4 changes: 4 additions & 0 deletions src/ffs_postgres/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

psql -U $POSTGRES_USER -d $POSTGRES_DB -a -f /app/dump.sql

0 comments on commit 07b6493

Please sign in to comment.