Skip to content

Commit

Permalink
Make the server runnable in production env
Browse files Browse the repository at this point in the history
Don't autoload templates. These are just used as generators and will
fail with syntax errors at autoload time in the production env.

Don't add environmnet-specific encrypted credentials keys to the repo.
- Also, we needed to check in config/credentials/production.yml.enc.

Fix the schema dumps for the solid trifecta to use *_structure.sql, as
expected in this app (as per the application config:
`config.active_record.schema_format = :sql`).
- This was required to get the database tables built when running e.g.
  `RAILS_ENV=production DB_PASSWORD=<password> rails db:create`
  ... and friends.
  - Basically, there's no other way that the databases for the solid_*
    gems can be created/added (we don't have their migration files).
- See: rails/solid_cache#228
  • Loading branch information
pdobb committed Dec 27, 2024
1 parent f888f88 commit be5d94a
Show file tree
Hide file tree
Showing 10 changed files with 1,098 additions and 200 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

# Ignore master key for decrypting credentials and more.
/config/master.key
/config/credentials/*.key

/app/assets/builds/*
!/app/assets/builds/.keep
Expand Down
2 changes: 1 addition & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Application < Rails::Application
# Please, add to the `ignore` list any other `lib` subdirectories that do
# not contain `.rb` files, or that should not be reloaded or eager loaded.
# Common ones are `templates`, `generators`, or `middleware`, for example.
config.autoload_lib(ignore: %w[assets tasks])
config.autoload_lib(ignore: %w[assets tasks templates])

# Configuration for the application, engines, and railties goes here.
#
Expand Down
1 change: 1 addition & 0 deletions config/credentials/production.yml.enc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yDaM7cxL47Q/z3xc+I9Izm/LoSyele5jMaPT33ugHbeLNOvwx+gGh2D6TzIdKVcjO/L3M1S8GGT209kqntJcAs0/iNPO04IKstcPYdDc4pqzaw5xq8ND+hMQ+o42luaoXBNwE0yqxsX0E+4Aq4jyU2uPn7lm0XRCbykee1KENlFX7lwbuvDAHyUFMRkaxhNeNHFQotp+tw+HBhYmSXDpfzpC2DdmsncOXX68chtIE9/kirecF5yV1VW7d6N88gZRmiK60jHdPR/DriDvCNBGLyCgnuPabW870CckmAiTJKFf/nsGUh4Fq4e908oxrR0LoY2ItP1DXHdlq4Pgp1+fkt7jrDzaNwnjx4OqLmx+y+wzIXXF0LaQ0Hix5tADmETXfRNNV67sJZ34UNn/0tQ5vPAy4JqHTLv2pLJHbpw3d7WyXeDmj4hCMJSK2vNililgXSGXtmMUjoXYFwTQ1+UfoAbl1u3sXv1Mg6srzq1J9ZHdPRNn1oZyPz1q--pZqoLx0eufR0I5a3--7n4oId0EAaQAtUYeuRfhRg==
2 changes: 1 addition & 1 deletion config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ production:
<<: *default
database: minesweeper_alliance_production
username: minesweeper_alliance
password: <%= ENV["MINESWEEPER_ALLIANCE_DATABASE_PASSWORD"] %>
password: <%= ENV["DB_PASSWORD"] %>
cache:
<<: *primary_production
database: minesweeper_alliance_production_cache
Expand Down
13 changes: 0 additions & 13 deletions db/cable_schema.rb

This file was deleted.

130 changes: 130 additions & 0 deletions db/cable_structure.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET transaction_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: ar_internal_metadata; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.ar_internal_metadata (
key character varying NOT NULL,
value character varying,
created_at timestamp(6) with time zone NOT NULL,
updated_at timestamp(6) with time zone NOT NULL
);


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

CREATE TABLE public.schema_migrations (
version character varying NOT NULL
);


--
-- Name: solid_cable_messages; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.solid_cable_messages (
id bigint NOT NULL,
channel bytea NOT NULL,
payload bytea NOT NULL,
created_at timestamp(6) with time zone NOT NULL,
channel_hash bigint NOT NULL
);


--
-- Name: solid_cable_messages_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: solid_cable_messages_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.solid_cable_messages_id_seq OWNED BY public.solid_cable_messages.id;


--
-- Name: solid_cable_messages id; Type: DEFAULT; Schema: public; Owner: -
--

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


--
-- Name: ar_internal_metadata ar_internal_metadata_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ar_internal_metadata
ADD CONSTRAINT ar_internal_metadata_pkey PRIMARY KEY (key);


--
-- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.schema_migrations
ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version);


--
-- Name: solid_cable_messages solid_cable_messages_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.solid_cable_messages
ADD CONSTRAINT solid_cable_messages_pkey PRIMARY KEY (id);


--
-- Name: index_solid_cable_messages_on_channel; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_solid_cable_messages_on_channel ON public.solid_cable_messages USING btree (channel);


--
-- Name: index_solid_cable_messages_on_channel_hash; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_solid_cable_messages_on_channel_hash ON public.solid_cable_messages USING btree (channel_hash);


--
-- Name: index_solid_cable_messages_on_created_at; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_solid_cable_messages_on_created_at ON public.solid_cable_messages USING btree (created_at);


--
-- PostgreSQL database dump complete
--

SET search_path TO "$user", public;

INSERT INTO "schema_migrations" (version) VALUES
('1');

16 changes: 0 additions & 16 deletions db/cache_schema.rb

This file was deleted.

131 changes: 131 additions & 0 deletions db/cache_structure.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET transaction_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: ar_internal_metadata; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.ar_internal_metadata (
key character varying NOT NULL,
value character varying,
created_at timestamp(6) with time zone NOT NULL,
updated_at timestamp(6) with time zone NOT NULL
);


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

CREATE TABLE public.schema_migrations (
version character varying NOT NULL
);


--
-- Name: solid_cache_entries; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE public.solid_cache_entries (
id bigint NOT NULL,
key bytea NOT NULL,
value bytea NOT NULL,
created_at timestamp(6) with time zone NOT NULL,
key_hash bigint NOT NULL,
byte_size integer NOT NULL
);


--
-- Name: solid_cache_entries_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

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


--
-- Name: solid_cache_entries_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE public.solid_cache_entries_id_seq OWNED BY public.solid_cache_entries.id;


--
-- Name: solid_cache_entries id; Type: DEFAULT; Schema: public; Owner: -
--

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


--
-- Name: ar_internal_metadata ar_internal_metadata_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.ar_internal_metadata
ADD CONSTRAINT ar_internal_metadata_pkey PRIMARY KEY (key);


--
-- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.schema_migrations
ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version);


--
-- Name: solid_cache_entries solid_cache_entries_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY public.solid_cache_entries
ADD CONSTRAINT solid_cache_entries_pkey PRIMARY KEY (id);


--
-- Name: index_solid_cache_entries_on_byte_size; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_solid_cache_entries_on_byte_size ON public.solid_cache_entries USING btree (byte_size);


--
-- Name: index_solid_cache_entries_on_key_hash; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX index_solid_cache_entries_on_key_hash ON public.solid_cache_entries USING btree (key_hash);


--
-- Name: index_solid_cache_entries_on_key_hash_and_byte_size; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_solid_cache_entries_on_key_hash_and_byte_size ON public.solid_cache_entries USING btree (key_hash, byte_size);


--
-- PostgreSQL database dump complete
--

SET search_path TO "$user", public;

INSERT INTO "schema_migrations" (version) VALUES
('1');

Loading

0 comments on commit be5d94a

Please sign in to comment.