-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate-db.sh
executable file
·63 lines (32 loc) · 1.28 KB
/
create-db.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
clear
cd ..
echo "The following script will create a rails database..."
echo "The first step is to install Rails..."
rails new rudeymental-db
echo "Rails has been installed."
echo "Replacing Rails default Gemfile with custom Gemfile."
rm rudeymental-db/Gemfile
cp rudeymental/Gemfile rudeymental-db
echo "Replacing default database.yml file with custom database.yml (the database parameters)"
rm rudeymental-db/config/database.yml
cp rudeymental/config/database.yml rudeymental-db/config
echo "Replacing default schema.rb with custom schema.rb (the specific database table configurations.)"
rm rudeymental-db/db/schema.rb
cp rudeymental/db/schema.rb rudeymental-db/db
echo "Changing to the rudeymental directory"
cd rudeymental
echo "Checking that all the newly installed gems have their necessary dependencies."
bundle install
echo "Heading into the database..."
psql
\c rudeymental_test
echo "Clearing test database of tables."
drop table translations, schema_migrations, cusswords;
echo "Clearing development database of tables."
\c rudeymental_development
drop table if exists translations, schema_migrations, cusswords;
echo "Deleting mock/helper directory (rudeymental-db)"
rm -rf ../rudeymental-db
echo "Rebuilding databases."
rake db:drop db:create db:schema:load