Skip to content

Commit e411fac

Browse files
committed
Make the server runnable in production env
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
1 parent 621f1a5 commit e411fac

10 files changed

+1098
-200
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
# Ignore master key for decrypting credentials and more.
3434
/config/master.key
35+
/config/credentials/*.key
3536

3637
/app/assets/builds/*
3738
!/app/assets/builds/.keep

config/application.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class Application < Rails::Application
2929
# Please, add to the `ignore` list any other `lib` subdirectories that do
3030
# not contain `.rb` files, or that should not be reloaded or eager loaded.
3131
# Common ones are `templates`, `generators`, or `middleware`, for example.
32-
config.autoload_lib(ignore: %w[assets tasks])
32+
config.autoload_lib(ignore: %w[assets tasks templates])
3333

3434
# Configuration for the application, engines, and railties goes here.
3535
#

config/credentials/production.yml.enc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
yDaM7cxL47Q/z3xc+I9Izm/LoSyele5jMaPT33ugHbeLNOvwx+gGh2D6TzIdKVcjO/L3M1S8GGT209kqntJcAs0/iNPO04IKstcPYdDc4pqzaw5xq8ND+hMQ+o42luaoXBNwE0yqxsX0E+4Aq4jyU2uPn7lm0XRCbykee1KENlFX7lwbuvDAHyUFMRkaxhNeNHFQotp+tw+HBhYmSXDpfzpC2DdmsncOXX68chtIE9/kirecF5yV1VW7d6N88gZRmiK60jHdPR/DriDvCNBGLyCgnuPabW870CckmAiTJKFf/nsGUh4Fq4e908oxrR0LoY2ItP1DXHdlq4Pgp1+fkt7jrDzaNwnjx4OqLmx+y+wzIXXF0LaQ0Hix5tADmETXfRNNV67sJZ34UNn/0tQ5vPAy4JqHTLv2pLJHbpw3d7WyXeDmj4hCMJSK2vNililgXSGXtmMUjoXYFwTQ1+UfoAbl1u3sXv1Mg6srzq1J9ZHdPRNn1oZyPz1q--pZqoLx0eufR0I5a3--7n4oId0EAaQAtUYeuRfhRg==

config/database.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ production:
8282
<<: *default
8383
database: minesweeper_alliance_production
8484
username: minesweeper_alliance
85-
password: <%= ENV["MINESWEEPER_ALLIANCE_DATABASE_PASSWORD"] %>
85+
password: <%= ENV["DB_PASSWORD"] %>
8686
cache:
8787
<<: *primary_production
8888
database: minesweeper_alliance_production_cache

db/cable_schema.rb

-13
This file was deleted.

db/cable_structure.sql

+130
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
SET statement_timeout = 0;
2+
SET lock_timeout = 0;
3+
SET idle_in_transaction_session_timeout = 0;
4+
SET transaction_timeout = 0;
5+
SET client_encoding = 'UTF8';
6+
SET standard_conforming_strings = on;
7+
SELECT pg_catalog.set_config('search_path', '', false);
8+
SET check_function_bodies = false;
9+
SET xmloption = content;
10+
SET client_min_messages = warning;
11+
SET row_security = off;
12+
13+
SET default_tablespace = '';
14+
15+
SET default_table_access_method = heap;
16+
17+
--
18+
-- Name: ar_internal_metadata; Type: TABLE; Schema: public; Owner: -
19+
--
20+
21+
CREATE TABLE public.ar_internal_metadata (
22+
key character varying NOT NULL,
23+
value character varying,
24+
created_at timestamp(6) with time zone NOT NULL,
25+
updated_at timestamp(6) with time zone NOT NULL
26+
);
27+
28+
29+
--
30+
-- Name: schema_migrations; Type: TABLE; Schema: public; Owner: -
31+
--
32+
33+
CREATE TABLE public.schema_migrations (
34+
version character varying NOT NULL
35+
);
36+
37+
38+
--
39+
-- Name: solid_cable_messages; Type: TABLE; Schema: public; Owner: -
40+
--
41+
42+
CREATE TABLE public.solid_cable_messages (
43+
id bigint NOT NULL,
44+
channel bytea NOT NULL,
45+
payload bytea NOT NULL,
46+
created_at timestamp(6) with time zone NOT NULL,
47+
channel_hash bigint NOT NULL
48+
);
49+
50+
51+
--
52+
-- Name: solid_cable_messages_id_seq; Type: SEQUENCE; Schema: public; Owner: -
53+
--
54+
55+
CREATE SEQUENCE public.solid_cable_messages_id_seq
56+
START WITH 1
57+
INCREMENT BY 1
58+
NO MINVALUE
59+
NO MAXVALUE
60+
CACHE 1;
61+
62+
63+
--
64+
-- Name: solid_cable_messages_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
65+
--
66+
67+
ALTER SEQUENCE public.solid_cable_messages_id_seq OWNED BY public.solid_cable_messages.id;
68+
69+
70+
--
71+
-- Name: solid_cable_messages id; Type: DEFAULT; Schema: public; Owner: -
72+
--
73+
74+
ALTER TABLE ONLY public.solid_cable_messages ALTER COLUMN id SET DEFAULT nextval('public.solid_cable_messages_id_seq'::regclass);
75+
76+
77+
--
78+
-- Name: ar_internal_metadata ar_internal_metadata_pkey; Type: CONSTRAINT; Schema: public; Owner: -
79+
--
80+
81+
ALTER TABLE ONLY public.ar_internal_metadata
82+
ADD CONSTRAINT ar_internal_metadata_pkey PRIMARY KEY (key);
83+
84+
85+
--
86+
-- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
87+
--
88+
89+
ALTER TABLE ONLY public.schema_migrations
90+
ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version);
91+
92+
93+
--
94+
-- Name: solid_cable_messages solid_cable_messages_pkey; Type: CONSTRAINT; Schema: public; Owner: -
95+
--
96+
97+
ALTER TABLE ONLY public.solid_cable_messages
98+
ADD CONSTRAINT solid_cable_messages_pkey PRIMARY KEY (id);
99+
100+
101+
--
102+
-- Name: index_solid_cable_messages_on_channel; Type: INDEX; Schema: public; Owner: -
103+
--
104+
105+
CREATE INDEX index_solid_cable_messages_on_channel ON public.solid_cable_messages USING btree (channel);
106+
107+
108+
--
109+
-- Name: index_solid_cable_messages_on_channel_hash; Type: INDEX; Schema: public; Owner: -
110+
--
111+
112+
CREATE INDEX index_solid_cable_messages_on_channel_hash ON public.solid_cable_messages USING btree (channel_hash);
113+
114+
115+
--
116+
-- Name: index_solid_cable_messages_on_created_at; Type: INDEX; Schema: public; Owner: -
117+
--
118+
119+
CREATE INDEX index_solid_cable_messages_on_created_at ON public.solid_cable_messages USING btree (created_at);
120+
121+
122+
--
123+
-- PostgreSQL database dump complete
124+
--
125+
126+
SET search_path TO "$user", public;
127+
128+
INSERT INTO "schema_migrations" (version) VALUES
129+
('1');
130+

db/cache_schema.rb

-16
This file was deleted.

db/cache_structure.sql

+131
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
SET statement_timeout = 0;
2+
SET lock_timeout = 0;
3+
SET idle_in_transaction_session_timeout = 0;
4+
SET transaction_timeout = 0;
5+
SET client_encoding = 'UTF8';
6+
SET standard_conforming_strings = on;
7+
SELECT pg_catalog.set_config('search_path', '', false);
8+
SET check_function_bodies = false;
9+
SET xmloption = content;
10+
SET client_min_messages = warning;
11+
SET row_security = off;
12+
13+
SET default_tablespace = '';
14+
15+
SET default_table_access_method = heap;
16+
17+
--
18+
-- Name: ar_internal_metadata; Type: TABLE; Schema: public; Owner: -
19+
--
20+
21+
CREATE TABLE public.ar_internal_metadata (
22+
key character varying NOT NULL,
23+
value character varying,
24+
created_at timestamp(6) with time zone NOT NULL,
25+
updated_at timestamp(6) with time zone NOT NULL
26+
);
27+
28+
29+
--
30+
-- Name: schema_migrations; Type: TABLE; Schema: public; Owner: -
31+
--
32+
33+
CREATE TABLE public.schema_migrations (
34+
version character varying NOT NULL
35+
);
36+
37+
38+
--
39+
-- Name: solid_cache_entries; Type: TABLE; Schema: public; Owner: -
40+
--
41+
42+
CREATE TABLE public.solid_cache_entries (
43+
id bigint NOT NULL,
44+
key bytea NOT NULL,
45+
value bytea NOT NULL,
46+
created_at timestamp(6) with time zone NOT NULL,
47+
key_hash bigint NOT NULL,
48+
byte_size integer NOT NULL
49+
);
50+
51+
52+
--
53+
-- Name: solid_cache_entries_id_seq; Type: SEQUENCE; Schema: public; Owner: -
54+
--
55+
56+
CREATE SEQUENCE public.solid_cache_entries_id_seq
57+
START WITH 1
58+
INCREMENT BY 1
59+
NO MINVALUE
60+
NO MAXVALUE
61+
CACHE 1;
62+
63+
64+
--
65+
-- Name: solid_cache_entries_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
66+
--
67+
68+
ALTER SEQUENCE public.solid_cache_entries_id_seq OWNED BY public.solid_cache_entries.id;
69+
70+
71+
--
72+
-- Name: solid_cache_entries id; Type: DEFAULT; Schema: public; Owner: -
73+
--
74+
75+
ALTER TABLE ONLY public.solid_cache_entries ALTER COLUMN id SET DEFAULT nextval('public.solid_cache_entries_id_seq'::regclass);
76+
77+
78+
--
79+
-- Name: ar_internal_metadata ar_internal_metadata_pkey; Type: CONSTRAINT; Schema: public; Owner: -
80+
--
81+
82+
ALTER TABLE ONLY public.ar_internal_metadata
83+
ADD CONSTRAINT ar_internal_metadata_pkey PRIMARY KEY (key);
84+
85+
86+
--
87+
-- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
88+
--
89+
90+
ALTER TABLE ONLY public.schema_migrations
91+
ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version);
92+
93+
94+
--
95+
-- Name: solid_cache_entries solid_cache_entries_pkey; Type: CONSTRAINT; Schema: public; Owner: -
96+
--
97+
98+
ALTER TABLE ONLY public.solid_cache_entries
99+
ADD CONSTRAINT solid_cache_entries_pkey PRIMARY KEY (id);
100+
101+
102+
--
103+
-- Name: index_solid_cache_entries_on_byte_size; Type: INDEX; Schema: public; Owner: -
104+
--
105+
106+
CREATE INDEX index_solid_cache_entries_on_byte_size ON public.solid_cache_entries USING btree (byte_size);
107+
108+
109+
--
110+
-- Name: index_solid_cache_entries_on_key_hash; Type: INDEX; Schema: public; Owner: -
111+
--
112+
113+
CREATE UNIQUE INDEX index_solid_cache_entries_on_key_hash ON public.solid_cache_entries USING btree (key_hash);
114+
115+
116+
--
117+
-- Name: index_solid_cache_entries_on_key_hash_and_byte_size; Type: INDEX; Schema: public; Owner: -
118+
--
119+
120+
CREATE INDEX index_solid_cache_entries_on_key_hash_and_byte_size ON public.solid_cache_entries USING btree (key_hash, byte_size);
121+
122+
123+
--
124+
-- PostgreSQL database dump complete
125+
--
126+
127+
SET search_path TO "$user", public;
128+
129+
INSERT INTO "schema_migrations" (version) VALUES
130+
('1');
131+

0 commit comments

Comments
 (0)