Skip to content

Commit

Permalink
WIP: Add MSSQL support
Browse files Browse the repository at this point in the history
  • Loading branch information
jonahgeorge committed Dec 24, 2023
1 parent 282d75d commit ac359f7
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 7 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
fail-fast: false
matrix:
ruby-version: [3.2.2]
database: [mysql, postgres, sqlite]
database: [mysql, postgres, sqlite, mssql]
services:
mysql:
image: mysql:8.0.31
Expand All @@ -24,6 +24,13 @@ jobs:
POSTGRES_HOST_AUTH_METHOD: "trust"
ports:
- 55432:5432
mssql:
image: mcr.microsoft.com/azure-sql-edge:1.0.4
env:
SA_PASSWORD: yourStrongPassword123
ACCEPT_EULA: Y
ports:
- 11433:1433
env:
TARGET_DB: ${{ matrix.database }}
steps:
Expand Down
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ gemspec
gem "mysql2"
gem "pg"
gem "sqlite3"

gem "activerecord-sqlserver-adapter"
gem 'tiny_tds'
10 changes: 7 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ GEM
activemodel (= 7.1.0)
activesupport (= 7.1.0)
timeout (>= 0.4.0)
activerecord-sqlserver-adapter (2.3.8)
activestorage (7.1.0)
actionpack (= 7.1.0)
activejob (= 7.1.0)
Expand Down Expand Up @@ -110,7 +111,6 @@ GEM
net-smtp
marcel (1.0.2)
mini_mime (1.1.5)
mini_portile2 (2.8.1)
minitest (5.20.0)
mocha (2.1.0)
ruby2_keywords (>= 0.0.5)
Expand Down Expand Up @@ -173,10 +173,11 @@ GEM
reline (0.3.2)
io-console (~> 0.5)
ruby2_keywords (0.0.5)
sqlite3 (1.5.4)
mini_portile2 (~> 2.8.0)
sqlite3 (1.5.4-arm64-darwin)
sqlite3 (1.5.4-x86_64-linux)
thor (1.2.2)
timeout (0.4.0)
tiny_tds (2.1.6)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
webrick (1.8.1)
Expand All @@ -186,16 +187,19 @@ GEM
zeitwerk (2.6.12)

PLATFORMS
arm64-darwin-21
arm64-darwin-22
x86_64-linux

DEPENDENCIES
activerecord-sqlserver-adapter
debug
mocha
mysql2
pg
solid_queue!
sqlite3
tiny_tds

BUNDLED WITH
2.4.2
6 changes: 5 additions & 1 deletion app/models/solid_queue/record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ class Record < ActiveRecord::Base

def self.non_blocking_lock
if SolidQueue.use_skip_locked
lock(Arel.sql("FOR UPDATE SKIP LOCKED"))
# self.connection.adapter_name == 'MSSQL'
# lock(Arel.sql("WITH(READPAST)"))
# else
lock(Arel.sql("FOR UPDATE SKIP LOCKED"))
# end
else
lock
end
Expand Down
12 changes: 10 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,19 @@ services:
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
volumes:
- db:/var/lib/mysql
ports: [ "127.0.0.1:33060:3306" ]
ports: ["127.0.0.1:33060:3306"]
postgres:
image: postgres:15.1
environment:
POSTGRES_HOST_AUTH_METHOD: "trust"
volumes:
- db:/var/lib/postgres
ports: [ "127.0.0.1:55432:5432" ]
ports: ["127.0.0.1:55432:5432"]
mssql:
image: mcr.microsoft.com/azure-sql-edge:1.0.4
environment:
SA_PASSWORD: yourStrongPassword123
ACCEPT_EULA: Y
volumes:
- db:/var/lib/mssql
ports: ["127.0.0.1:11430:1430"]
9 changes: 9 additions & 0 deletions test/dummy/config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ default: &default
port: 55432
gssencmode: disable # https://github.com/ged/ruby-pg/issues/311

<% elsif ENV["TARGET_DB"] == "mssql" %>
default: &default
adapter: sqlserver
username: sa
password: "yourStrongPassword123"
pool: 5
host: "127.0.0.1"
port: 11433

<% else %>
default: &default
adapter: mysql2
Expand Down

0 comments on commit ac359f7

Please sign in to comment.