File tree 4 files changed +24
-9
lines changed
4 files changed +24
-9
lines changed Original file line number Diff line number Diff line change 1
- ---
1
+ dist : bionic
2
2
language : ruby
3
+ addons :
4
+ postgresql : " 9.6"
5
+ rvm : 2.7.1
3
6
cache : bundler
4
- rvm :
5
- - 2.7.1
6
7
before_install : gem install bundler -v 2.1.4
8
+ before_script : psql -U postgres -c 'create database sql_spy_test;'
9
+ env :
10
+ - DATABASE_URL=sqlite3:///tmp/sql_spy_test.sqlite3
11
+ - DATABASE_URL=postgres://postgres/sql_spy_test
Original file line number Diff line number Diff line change 5
5
gem "rake" , "~> 12.0"
6
6
gem "minitest" , "~> 5.0"
7
7
gem "activerecord" , "~> 6.0"
8
+ gem "pg"
8
9
gem "sqlite3"
9
10
gem "byebug"
Original file line number Diff line number Diff line change 22
22
i18n (1.8.5 )
23
23
concurrent-ruby (~> 1.0 )
24
24
minitest (5.14.2 )
25
+ pg (1.2.3 )
25
26
rake (12.3.3 )
26
27
sqlite3 (1.4.2 )
27
28
thread_safe (0.3.6 )
@@ -36,6 +37,7 @@ DEPENDENCIES
36
37
activerecord (~> 6.0 )
37
38
byebug
38
39
minitest (~> 5.0 )
40
+ pg
39
41
rake (~> 12.0 )
40
42
sql_spy !
41
43
sqlite3
Original file line number Diff line number Diff line change 1
1
require "minitest/autorun"
2
2
require "active_record"
3
+ require "pg"
3
4
require "sqlite3"
4
5
5
6
SQLITE_DATABASE = File . expand_path ( "../test.sqlite3" , __dir__ )
6
7
File . delete ( SQLITE_DATABASE ) if File . file? ( SQLITE_DATABASE )
7
8
8
- ActiveRecord ::Base . establish_connection ( adapter : "sqlite3" , database : SQLITE_DATABASE )
9
+ ENV [ "DATABASE_URL" ] ||= "sqlite3://" + SQLITE_DATABASE
10
+ ActiveRecord ::Base . establish_connection ( ENV [ "DATABASE_URL" ] )
11
+
9
12
ActiveRecord ::Schema . define do
10
- create_table :users do |t |
11
- t . string :name
13
+ unless table_exists? ( :users )
14
+ create_table :users do |t |
15
+ t . string :name
16
+ end
12
17
end
13
18
14
- create_table :posts do |t |
15
- t . references :user
16
- t . string :title
19
+ unless table_exists? ( :posts )
20
+ create_table :posts do |t |
21
+ t . references :user
22
+ t . string :title
23
+ end
17
24
end
18
25
end
19
26
You can’t perform that action at this time.
0 commit comments