From c71ddf68ec92c89230885f9c5f4d0ca6aa5fd0d1 Mon Sep 17 00:00:00 2001 From: Jonah George Date: Sun, 24 Dec 2023 11:38:08 -0800 Subject: [PATCH] WIP: Add MSSQL support --- .github/workflows/main.yml | 9 ++++++++- Gemfile | 1 + Gemfile.lock | 8 +++++--- docker-compose.yml | 12 ++++++++++-- test/dummy/config/database.yml | 9 +++++++++ 5 files changed, 33 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9b7c9834..45477e39 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 @@ -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: diff --git a/Gemfile b/Gemfile index 0461dab1..4f08c946 100644 --- a/Gemfile +++ b/Gemfile @@ -7,3 +7,4 @@ gemspec gem "mysql2" gem "pg" gem "sqlite3" +gem "activerecord-sqlserver-adapter" diff --git a/Gemfile.lock b/Gemfile.lock index 6e1eabeb..df290858 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) @@ -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) @@ -173,8 +173,8 @@ 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) tzinfo (2.0.6) @@ -186,10 +186,12 @@ GEM zeitwerk (2.6.12) PLATFORMS + arm64-darwin-21 arm64-darwin-22 x86_64-linux DEPENDENCIES + activerecord-sqlserver-adapter debug mocha mysql2 diff --git a/docker-compose.yml b/docker-compose.yml index 9777d762..ec6fa136 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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"] diff --git a/test/dummy/config/database.yml b/test/dummy/config/database.yml index a05e6c3f..c9f32fdd 100644 --- a/test/dummy/config/database.yml +++ b/test/dummy/config/database.yml @@ -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