Skip to content

Commit afc6293

Browse files
committed
SQL dump usage refactoring
1 parent bd06bae commit afc6293

File tree

4 files changed

+50
-33
lines changed

4 files changed

+50
-33
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ pom.xml.asc
1010
.hgignore
1111
.hg/
1212
resources/public/js/out
13+
.idea/
14+
sample.iml

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,22 @@ This sample shows a sample dashboard done with [AnyChart JavaScript Charting Fra
1818
* [Leiningen 2+](http://leiningen.org/)
1919

2020
## Database Setup
21-
`psql anychart_sample < dump`
21+
```
22+
# login to PostgreSQL
23+
sudo -u postgres psql
24+
25+
# CREATE user and database
26+
CREATE USER anychart_user WITH PASSWORD 'anychart_pass';
27+
CREATE DATABASE anychart_sample;
28+
GRANT ALL PRIVILEGES ON DATABASE anychart_sample TO anychart_user;
29+
30+
# exit psql
31+
\q
32+
33+
# run dump
34+
psql anychart_sample < dump
35+
```
36+
2237

2338
## Database Connection Configiration
2439
Edit base-config in src/sample/core.clj

dump renamed to dump.sql

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ SET default_tablespace = '';
3030
SET default_with_oids = false;
3131

3232
--
33-
-- Name: industry; Type: TABLE; Schema: public; Owner: alex; Tablespace:
33+
-- Name: industry; Type: TABLE; Schema: public; Owner: anychart_user; Tablespace:
3434
--
3535

3636
CREATE TABLE industry (
@@ -39,10 +39,10 @@ CREATE TABLE industry (
3939
);
4040

4141

42-
ALTER TABLE industry OWNER TO alex;
42+
ALTER TABLE industry OWNER TO anychart_user;
4343

4444
--
45-
-- Name: product; Type: TABLE; Schema: public; Owner: alex; Tablespace:
45+
-- Name: product; Type: TABLE; Schema: public; Owner: anychart_user; Tablespace:
4646
--
4747

4848
CREATE TABLE product (
@@ -52,10 +52,10 @@ CREATE TABLE product (
5252
);
5353

5454

55-
ALTER TABLE product OWNER TO alex;
55+
ALTER TABLE product OWNER TO anychart_user;
5656

5757
--
58-
-- Name: region; Type: TABLE; Schema: public; Owner: alex; Tablespace:
58+
-- Name: region; Type: TABLE; Schema: public; Owner: anychart_user; Tablespace:
5959
--
6060

6161
CREATE TABLE region (
@@ -64,10 +64,10 @@ CREATE TABLE region (
6464
);
6565

6666

67-
ALTER TABLE region OWNER TO alex;
67+
ALTER TABLE region OWNER TO anychart_user;
6868

6969
--
70-
-- Name: sales_id_seq; Type: SEQUENCE; Schema: public; Owner: alex
70+
-- Name: sales_id_seq; Type: SEQUENCE; Schema: public; Owner: anychart_user
7171
--
7272

7373
CREATE SEQUENCE sales_id_seq
@@ -78,10 +78,10 @@ CREATE SEQUENCE sales_id_seq
7878
CACHE 1;
7979

8080

81-
ALTER TABLE sales_id_seq OWNER TO alex;
81+
ALTER TABLE sales_id_seq OWNER TO anychart_user;
8282

8383
--
84-
-- Name: sales; Type: TABLE; Schema: public; Owner: alex; Tablespace:
84+
-- Name: sales; Type: TABLE; Schema: public; Owner: anychart_user; Tablespace:
8585
--
8686

8787
CREATE TABLE sales (
@@ -94,10 +94,10 @@ CREATE TABLE sales (
9494
);
9595

9696

97-
ALTER TABLE sales OWNER TO alex;
97+
ALTER TABLE sales OWNER TO anychart_user;
9898

9999
--
100-
-- Name: sales_reps; Type: TABLE; Schema: public; Owner: alex; Tablespace:
100+
-- Name: sales_reps; Type: TABLE; Schema: public; Owner: anychart_user; Tablespace:
101101
--
102102

103103
CREATE TABLE sales_reps (
@@ -106,10 +106,10 @@ CREATE TABLE sales_reps (
106106
);
107107

108108

109-
ALTER TABLE sales_reps OWNER TO alex;
109+
ALTER TABLE sales_reps OWNER TO anychart_user;
110110

111111
--
112-
-- Data for Name: industry; Type: TABLE DATA; Schema: public; Owner: alex
112+
-- Data for Name: industry; Type: TABLE DATA; Schema: public; Owner: anychart_user
113113
--
114114

115115
COPY industry (id, name) FROM stdin;
@@ -122,7 +122,7 @@ COPY industry (id, name) FROM stdin;
122122

123123

124124
--
125-
-- Data for Name: product; Type: TABLE DATA; Schema: public; Owner: alex
125+
-- Data for Name: product; Type: TABLE DATA; Schema: public; Owner: anychart_user
126126
--
127127

128128
COPY product (id, name, industry_id) FROM stdin;
@@ -135,7 +135,7 @@ COPY product (id, name, industry_id) FROM stdin;
135135

136136

137137
--
138-
-- Data for Name: region; Type: TABLE DATA; Schema: public; Owner: alex
138+
-- Data for Name: region; Type: TABLE DATA; Schema: public; Owner: anychart_user
139139
--
140140

141141
COPY region (id, name) FROM stdin;
@@ -148,7 +148,7 @@ COPY region (id, name) FROM stdin;
148148

149149

150150
--
151-
-- Data for Name: sales; Type: TABLE DATA; Schema: public; Owner: alex
151+
-- Data for Name: sales; Type: TABLE DATA; Schema: public; Owner: anychart_user
152152
--
153153

154154
COPY sales (id, date, product_id, region_id, rep_id, total) FROM stdin;
@@ -6356,14 +6356,14 @@ COPY sales (id, date, product_id, region_id, rep_id, total) FROM stdin;
63566356

63576357

63586358
--
6359-
-- Name: sales_id_seq; Type: SEQUENCE SET; Schema: public; Owner: alex
6359+
-- Name: sales_id_seq; Type: SEQUENCE SET; Schema: public; Owner: anychart_user
63606360
--
63616361

63626362
SELECT pg_catalog.setval('sales_id_seq', 7635, true);
63636363

63646364

63656365
--
6366-
-- Data for Name: sales_reps; Type: TABLE DATA; Schema: public; Owner: alex
6366+
-- Data for Name: sales_reps; Type: TABLE DATA; Schema: public; Owner: anychart_user
63676367
--
63686368

63696369
COPY sales_reps (id, name) FROM stdin;
@@ -6376,84 +6376,84 @@ COPY sales_reps (id, name) FROM stdin;
63766376

63776377

63786378
--
6379-
-- Name: industry_pkey; Type: CONSTRAINT; Schema: public; Owner: alex; Tablespace:
6379+
-- Name: industry_pkey; Type: CONSTRAINT; Schema: public; Owner: anychart_user; Tablespace:
63806380
--
63816381

63826382
ALTER TABLE ONLY industry
63836383
ADD CONSTRAINT industry_pkey PRIMARY KEY (id);
63846384

63856385

63866386
--
6387-
-- Name: product_pkey; Type: CONSTRAINT; Schema: public; Owner: alex; Tablespace:
6387+
-- Name: product_pkey; Type: CONSTRAINT; Schema: public; Owner: anychart_user; Tablespace:
63886388
--
63896389

63906390
ALTER TABLE ONLY product
63916391
ADD CONSTRAINT product_pkey PRIMARY KEY (id);
63926392

63936393

63946394
--
6395-
-- Name: region_pkey; Type: CONSTRAINT; Schema: public; Owner: alex; Tablespace:
6395+
-- Name: region_pkey; Type: CONSTRAINT; Schema: public; Owner: anychart_user; Tablespace:
63966396
--
63976397

63986398
ALTER TABLE ONLY region
63996399
ADD CONSTRAINT region_pkey PRIMARY KEY (id);
64006400

64016401

64026402
--
6403-
-- Name: sales_pkey; Type: CONSTRAINT; Schema: public; Owner: alex; Tablespace:
6403+
-- Name: sales_pkey; Type: CONSTRAINT; Schema: public; Owner: anychart_user; Tablespace:
64046404
--
64056405

64066406
ALTER TABLE ONLY sales
64076407
ADD CONSTRAINT sales_pkey PRIMARY KEY (id);
64086408

64096409

64106410
--
6411-
-- Name: sales_reps_pkey; Type: CONSTRAINT; Schema: public; Owner: alex; Tablespace:
6411+
-- Name: sales_reps_pkey; Type: CONSTRAINT; Schema: public; Owner: anychart_user; Tablespace:
64126412
--
64136413

64146414
ALTER TABLE ONLY sales_reps
64156415
ADD CONSTRAINT sales_reps_pkey PRIMARY KEY (id);
64166416

64176417

64186418
--
6419-
-- Name: product_industry_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: alex
6419+
-- Name: product_industry_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: anychart_user
64206420
--
64216421

64226422
ALTER TABLE ONLY product
64236423
ADD CONSTRAINT product_industry_id_fkey FOREIGN KEY (industry_id) REFERENCES industry(id);
64246424

64256425

64266426
--
6427-
-- Name: sales_product_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: alex
6427+
-- Name: sales_product_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: anychart_user
64286428
--
64296429

64306430
ALTER TABLE ONLY sales
64316431
ADD CONSTRAINT sales_product_id_fkey FOREIGN KEY (product_id) REFERENCES product(id);
64326432

64336433

64346434
--
6435-
-- Name: sales_region_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: alex
6435+
-- Name: sales_region_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: anychart_user
64366436
--
64376437

64386438
ALTER TABLE ONLY sales
64396439
ADD CONSTRAINT sales_region_id_fkey FOREIGN KEY (region_id) REFERENCES region(id);
64406440

64416441

64426442
--
6443-
-- Name: sales_rep_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: alex
6443+
-- Name: sales_rep_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: anychart_user
64446444
--
64456445

64466446
ALTER TABLE ONLY sales
64476447
ADD CONSTRAINT sales_rep_id_fkey FOREIGN KEY (rep_id) REFERENCES sales_reps(id);
64486448

64496449

64506450
--
6451-
-- Name: public; Type: ACL; Schema: -; Owner: alex
6451+
-- Name: public; Type: ACL; Schema: -; Owner: anychart_user
64526452
--
64536453

64546454
REVOKE ALL ON SCHEMA public FROM PUBLIC;
6455-
REVOKE ALL ON SCHEMA public FROM alex;
6456-
GRANT ALL ON SCHEMA public TO alex;
6455+
REVOKE ALL ON SCHEMA public FROM anychart_user;
6456+
GRANT ALL ON SCHEMA public TO anychart_user;
64576457
GRANT ALL ON SCHEMA public TO PUBLIC;
64586458

64596459

src/sample/core.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
:jdbc {:subprotocol "postgresql"
99
:subname "//localhost:5432/anychart_sample"
1010
:classname "org.postgresql.Driver"
11-
:user "alex"
12-
:password ""}})
11+
:user "anychart_user"
12+
:password "anychart_pass"}})
1313

1414
(def prod-config (assoc-in base-config [:web :debug] false))
1515

0 commit comments

Comments
 (0)