· 8 years ago · Jul 26, 2018, 09:18 PM
1const sqlSync = `
2DROP TABLE IF EXISTS upvotes;
3DROP TABLE IF EXISTS posts;
4DROP TABLE IF EXISTS users;
5
6CREATE TABLE users (
7id SERIAL PRIMARY KEY,
8name TEXT DEFAULT NULL
9);
10
11CREATE TABLE posts (
12id SERIAL PRIMARY KEY,
13userId INTEGER REFERENCES users(id) NOT NULL,
14title varchar(255) DEFAULT NULL,
15content TEXT DEFAULT NULL,
16date timestamp DEFAULT now()
17);
18
19CREATE TABLE upvotes (
20userId INTEGER REFERENCES users(id) NOT NULL,
21postId INTEGER REFERENCES posts(id) NOT NULL,
22date timestamp DEFAULT now()
23);
24`;
25
26const sqlSeed = `
27INSERT INTO users (name) VALUES ('RubeusH');
28INSERT INTO users (name) VALUES ('Baddock');
29INSERT INTO users (name) VALUES ('Hetty');
30INSERT INTO users (name) VALUES ('Alphard');
31INSERT INTO users (name) VALUES ('Baruffio');
32INSERT INTO users (name) VALUES ('Hbeery');
33INSERT INTO users (name) VALUES ('Alatar');
34INSERT INTO users (name) VALUES ('Falco');
35INSERT INTO users (name) VALUES ('Otto');
36INSERT INTO users (name) VALUES ('Cuthbert');
37INSERT INTO users (name) VALUES ('Humphrey22');
38INSERT INTO users (name) VALUES ('Bellatrix1');
39INSERT INTO users (name) VALUES ('Dracod');
40INSERT INTO users (name) VALUES ('Lupin');
41
42INSERT INTO posts (userId, title, content, date) VALUES ((SELECT id from users where name='RubeusH'), 'Fianto Duri, the complete tutorial', 'Fianto Duri is a charm that was created to be combined with protective spells (Can be used with another person''s shield spell)(When used on something else creates a explosion). As we already knows the (i.e.) Shield Charm needs the caster to stay focused on the spell in order to continue protecting him, so Fianto Duri allows the caster to keep a charm “alive†while he does some other work or casts some other spells.', (now() - interval '4 hours'));
43INSERT INTO posts (userId, title, content, date) VALUES ((SELECT id from users where name='Baddock'), 'Untransfiguration classes to become compulsory at Hogwarts', 'Learning untransfiguration is going to be mandatory at Hogwarts School of Witchcraft and Wizardry from 2017 onward. Untransfiguration will be covered in beginner-level spellbooks such as A Beginner''s Guide to Transfiguration. Failure to at least attempt to untranfigure a wrongly-done transfiguration will be considered irresponsible.', (now() - interval '1 day'));
44INSERT INTO posts (userId, title, content, date) VALUES ((SELECT id from users where name='Hetty'), 'Cracking the Aurologist Interview', 'Now in the 5th edition, Cracking the Aurologist Interview gives you the interview preparation you need to get the top aura study jobs. The book is over 500 pages and includes 150 aurologist interview questions and answers, as well as other advice.', (now() - interval '15 minutes'));
45INSERT INTO posts (userId, title, content, date) VALUES ((SELECT id from users where name='Alphard'), 'ASK WN: What do you use to digitalize your scrolls?', 'Some scrolls need conservation treatment before they can be safely transported, handled, and digitized. After these questions are answered, Preservation and Information Technology Specialists assess the project requirements and create the digitilized version.', (now()));
46INSERT INTO posts (userId, title, content, date) VALUES ((SELECT id from users where name='Baruffio'), 'The Pragmatic Dragon Feeder', 'In The Pragmatic Dragon Feeder, the author Baruffio tell us how to give food to dragons in a way that we can follow. How did they get so smart? Aren''t they just as focused on details as other dragon feeders? The answer is that they paid attention to what they were doing while they were doing it.', (now() - interval '3 hours'));
47INSERT INTO posts (userId, title, content, date) VALUES ((SELECT id from users where name='Hbeery'), 'The complete quidditch statistics', 'This is the Complete source for quidditch history including complete player, team, and league stats, awards, records, leaders, rookies and scores.', (now() - interval '1 hour'));
48INSERT INTO posts (userId, title, content, date) VALUES ((SELECT id from users where name='Alatar'), 'Ordinary Wizarding Levels study guide', 'The Ordinary Wizarding Level (O.W.L.) is, as you know, going to determine whether or not you will be allowed to continue taking that subject in subsequent school years, and whether they might be successful in obtaining a particular job. This guide help direct you to the most important information you need to know to ace the test', (now() - interval '1 hour'));
49INSERT INTO posts (userId, title, content, date) VALUES ((SELECT id from users where name='Falco'), 'Is muggle-baiting ever acceptable?', 'Muggle-baiting can be a manifestation of anti-Muggle sentiments and is not acceptable according to the International Statute of Wizarding Secrecy - But, are there any circumstances under which it could be acceptable?', (now() - interval '10 minutes'));
50INSERT INTO posts (userId, title, content, date) VALUES ((SELECT id from users where name='Otto'), 'Conserving waterplants cheatsheet.', 'This Cheat Sheet is dedicated to providing wizards the information they want in an approachable, entertaining way.', (now() - interval '24 hours'));
51INSERT INTO posts (userId, title, content, date) VALUES ((SELECT id from users where name='Cuthbert'), 'Could wizards prevent WW3?', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla vitae fermentum enim. Pellentesque sodales ut risus eu porta. Duis dictum rhoncus semper. Proin accumsan mollis ligula, eget elementum nibh dignissim quis. Proin augue risus, mollis non neque in, molestie rutrum purus. Morbi pretium nisl a commodo.', (now() - interval '50 minutes'));
52INSERT INTO posts (userId, title, content, date) VALUES ((SELECT id from users where name='Humphrey22'), 'Show WN: Wand-Extinguishing Protection', 'This spell extinguishes the wand the caster is holding, a counter-charm to Lumos.', (now() - interval '1 hour'));
53INSERT INTO posts (userId, title, content, date) VALUES ((SELECT id from users where name='Bellatrix1'), 'Do you still use Alarte Ascendare?', 'You''ve got levicorpus and Ascendio and wingardium leviosa, so is anyone still using Alarte Ascendare, too? (That is, unless you find wingardium leviosa too difficult to pronounce.)', (now() - interval '30 seconds'));
54INSERT INTO posts (userId, title, content, date) VALUES ((SELECT id from users where name='Dracod'), 'Mailing lists WN readers ought to know about?', 'I love to subscribe to information feeds through mailing list subscription. What do you subscribe to that you think others would benefit by if they were to as well?', (now() - interval '1 minute'));
55INSERT INTO posts (userId, title, content, date) VALUES ((SELECT id from users where name='Lupin'), 'How to tell which spell used on a bug?', 'Question: Are ther any non-jinx incantations available to detect which spell used on a bug?', (now()));
56INSERT INTO upvotes (userId, postId) VALUES (1,1),(1,2),(1,3),(1,4),(1,5),(1,6),(1,7),(1,8),(1,9),(1,10),(1,11),(1,12),(1,13),(1,14);
57INSERT INTO upvotes (userId, postId) VALUES (2,1),(2,2),(2,3),(2,4),(2,5),(2,6),(2,7),(2,8),(2,9),(2,10),(2,11),(2,12),(2,13);
58INSERT INTO upvotes (userId, postId) VALUES (3,1),(3,2),(3,3),(3,4),(3,5),(3,6),(3,7),(3,8),(3,9),(3,10),(3,11);
59INSERT INTO upvotes (userId, postId) VALUES (4,1),(4,2),(4,3),(4,4),(4,5),(4,6),(4,7),(4,8),(4,9);
60INSERT INTO upvotes (userId, postId) VALUES (5,1),(5,2),(5,3),(5,5),(5,5),(5,6);
61INSERT INTO upvotes (userId, postId) VALUES (6,1),(6,2),(7,3),(8,5);
62INSERT INTO upvotes (userId, postId) VALUES (9,1),(10,2),(11,3);
63INSERT INTO upvotes (userId, postId) VALUES (12,1),(13,2);
64INSERT INTO upvotes (userId, postId) VALUES (14,1);
65`;
66
67
68module.exports = {
69 sqlSync,
70 sqlSeed
71};