Browse Source

CPassage de sqlite3 à pgsql 12

Lou 2 years ago
parent
commit
a79c4d4127
4 changed files with 23 additions and 12 deletions
  1. 5
    1
      Gemfile
  2. 2
    2
      Gemfile.lock
  3. 8
    4
      config/database.yml
  4. 8
    5
      db/schema.rb

+ 5
- 1
Gemfile View File

@@ -6,7 +6,11 @@ ruby '3.0.1'
6 6
 # Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main'
7 7
 gem 'rails', '~> 6.1.3', '>= 6.1.3.1'
8 8
 # Use sqlite3 as the database for Active Record
9
-gem 'sqlite3', '~> 1.4'
9
+# gem 'sqlite3', '~> 1.4'
10
+
11
+# Use PostgreSQL as the database for Active Record
12
+gem 'pg'
13
+
10 14
 # Use Puma as the app server
11 15
 gem 'puma', '~> 5.0'
12 16
 # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder

+ 2
- 2
Gemfile.lock View File

@@ -96,6 +96,7 @@ GEM
96 96
     nio4r (2.5.7)
97 97
     nokogiri (1.11.3-x86_64-linux)
98 98
       racc (~> 1.4)
99
+    pg (1.2.3)
99 100
     puma (5.2.2)
100 101
       nio4r (~> 2.0)
101 102
     racc (1.5.2)
@@ -150,7 +151,6 @@ GEM
150 151
       actionpack (>= 4.0)
151 152
       activesupport (>= 4.0)
152 153
       sprockets (>= 3.0.0)
153
-    sqlite3 (1.4.2)
154 154
     table_print (1.5.7)
155 155
     thor (1.1.0)
156 156
     tzinfo (2.0.4)
@@ -172,12 +172,12 @@ DEPENDENCIES
172 172
   jsonapi-serializer (~> 2.2)
173 173
   jwt (~> 2.2)
174 174
   listen (~> 3.3)
175
+  pg
175 176
   puma (~> 5.0)
176 177
   rack-cors
177 178
   rails (~> 6.1.3, >= 6.1.3.1)
178 179
   rails-erd
179 180
   spring
180
-  sqlite3 (~> 1.4)
181 181
   table_print (~> 1.5)
182 182
   tzinfo-data
183 183
 

+ 8
- 4
config/database.yml View File

@@ -5,21 +5,25 @@
5 5
 #   gem 'sqlite3'
6 6
 #
7 7
 default: &default
8
-  adapter: sqlite3
8
+  # adapter: sqlite3
9
+  adapter: postgresql
9 10
   pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
10 11
   timeout: 5000
11 12
 
12 13
 development:
13 14
   <<: *default
14
-  database: db/development.sqlite3
15
+  # database: db/development.sqlite3
16
+  database: registra_development
15 17
 
16 18
 # Warning: The database defined as "test" will be erased and
17 19
 # re-generated from your development database when you run "rake".
18 20
 # Do not set this db to the same as development or production.
19 21
 test:
20 22
   <<: *default
21
-  database: db/test.sqlite3
23
+  # database: db/test.sqlite3
24
+  database: registra_test
22 25
 
23 26
 production:
24 27
   <<: *default
25
-  database: db/production.sqlite3
28
+  # database: db/production.sqlite3
29
+  database: registra_production

+ 8
- 5
db/schema.rb View File

@@ -12,11 +12,14 @@
12 12
 
13 13
 ActiveRecord::Schema.define(version: 2021_05_10_133939) do
14 14
 
15
+  # These are extensions that must be enabled in order to support this database
16
+  enable_extension "plpgsql"
17
+
15 18
   create_table "activities", force: :cascade do |t|
16 19
     t.string "name", null: false
17 20
     t.string "client"
18 21
     t.string "description"
19
-    t.integer "author_id", null: false
22
+    t.bigint "author_id", null: false
20 23
     t.datetime "created_at", precision: 6, null: false
21 24
     t.datetime "updated_at", precision: 6, null: false
22 25
     t.index ["author_id"], name: "index_activities_on_author_id"
@@ -24,8 +27,8 @@ ActiveRecord::Schema.define(version: 2021_05_10_133939) do
24 27
   end
25 28
 
26 29
   create_table "joined_user_activities", force: :cascade do |t|
27
-    t.integer "user_id"
28
-    t.integer "activity_id"
30
+    t.bigint "user_id"
31
+    t.bigint "activity_id"
29 32
     t.datetime "created_at", precision: 6, null: false
30 33
     t.datetime "updated_at", precision: 6, null: false
31 34
     t.index ["activity_id"], name: "index_joined_user_activities_on_activity_id"
@@ -36,8 +39,8 @@ ActiveRecord::Schema.define(version: 2021_05_10_133939) do
36 39
     t.string "name", null: false
37 40
     t.text "description"
38 41
     t.integer "duration"
39
-    t.integer "activity_id", null: false
40
-    t.integer "user_id", null: false
42
+    t.bigint "activity_id", null: false
43
+    t.bigint "user_id", null: false
41 44
     t.datetime "created_at", precision: 6, null: false
42 45
     t.datetime "updated_at", precision: 6, null: false
43 46
     t.index ["activity_id"], name: "index_tasks_on_activity_id"

Loading…
Cancel
Save