Skip to content

Commit ecb1e5d

Browse files
committed
Postgre. Always Postgre.
1 parent fb9d8e7 commit ecb1e5d

File tree

6 files changed

+345
-39
lines changed

6 files changed

+345
-39
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ gem "rake"
55
gem "grape"
66

77
gem "grape-activerecord"
8-
gem "sqlite3"
8+
gem "pg"
99

1010
gem "activeuuid"
1111

Gemfile.lock

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ GEM
8484
passenger (5.0.16)
8585
rack
8686
rake (>= 0.8.1)
87+
pg (0.18.3)
8788
powerpack (0.1.1)
8889
rack (1.5.5)
8990
rack-accept (0.4.5)
@@ -120,7 +121,6 @@ GEM
120121
json (~> 1.8)
121122
simplecov-html (~> 0.10.0)
122123
simplecov-html (0.10.0)
123-
sqlite3 (1.3.10)
124124
thread_safe (0.3.5)
125125
tzinfo (1.2.2)
126126
thread_safe (~> 0.1)
@@ -144,11 +144,14 @@ DEPENDENCIES
144144
grape
145145
grape-activerecord
146146
passenger
147+
pg
147148
rack-test
148149
rake
149150
require_all
150151
rspec
151152
rubocop
152153
simplecov
153154
simplecov-summary!
154-
sqlite3
155+
156+
BUNDLED WITH
157+
1.10.6

config/database.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
development:
2-
adapter: sqlite3
3-
database: db/development.sqlite3
2+
adapter: postgresql
3+
encoding: unicode
4+
database: mcmuch_development
5+
pool: 5
46

57
test:
6-
adapter: sqlite3
7-
database: db/test.sqlite3
8+
adapter: postgresql
9+
encoding: unicode
10+
database: mcmuch_test
11+
pool: 5
812

913
production:
10-
adapter: sqlite3
11-
database: db/production.sqlite3
14+
adapter: postgresql
15+
encoding: unicode
16+
database: mcmuch
17+
pool: 5

config/setup.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,3 @@
1010
require_all __dir__ + "/../models"
1111
# require_all __dir__ + "/../helpers"
1212
require_all __dir__ + "/../api"
13-
14-
POSTGRE = ActiveRecord::Base.connection.adapter_name.downcase == "postgresql"

db/migrate/20150901155610_init.rb

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ def change
33
create_table :users do |t|
44
t.uuid :mojang_uuid
55

6-
t.string :username
7-
t.string :role
6+
t.text :username
7+
t.text :role
88

99
t.datetime :created_at
1010
t.datetime :last_login
@@ -14,10 +14,10 @@ def change
1414
add_index :users, :username, unique: true
1515

1616
create_table :creations do |t|
17-
t.string :title
17+
t.text :title
1818
t.text :description
1919

20-
t.string :visibility
20+
t.text :visibility
2121

2222
t.belongs_to :user
2323
end
@@ -26,28 +26,24 @@ def change
2626
add_index :creations, :user_id
2727

2828
create_table :revisions do |t|
29-
t.column :sha1, "binary(20)"
29+
t.text :sha1
3030
t.integer :filesize
3131

3232
t.belongs_to :creation
3333

34-
t.string :title
34+
t.text :title
3535

36-
t.string :type
36+
t.text :type
3737

38-
if ::POSTGRE
39-
t.column :tags, "jsonb"
40-
else
41-
t.text :tags_json
42-
end
38+
t.column :tags, "text[]"
4339

4440
t.datetime :created_at
4541
end
4642

4743
add_index :revisions, :sha1, unique: true
4844
add_index :revisions, :creation_id
4945
add_index :revisions, :type
50-
execute "ADD INDEX index_revisions_on_tags ON revisions USING gin (tags);" if ::POSTGRE
46+
execute "CREATE INDEX index_revisions_on_tags ON revisions USING gin (tags);"
5147

5248
create_table :comments do |t|
5349
t.belongs_to :user

0 commit comments

Comments
 (0)