Skip to content

ddev/ddev-sqlsrv

Repository files navigation

tests project is maintained

ddev-sqlsrv

What is ddev-sqlsrv?

This add-on quickly installs the MS SQL server into a DDEV project. It is based on the mcr.microsoft.com/mssql/server image.

You have to keep in mind that the mssql-docker does not natively work on M1 (arm64). Some workarounds are described in the following threads:

Installation

Due to lack of upstream support, this add-on can only be used with amd64 machines, and is not usable on arm64 machines like Apple Silicon computers.

For DDEV v1.23.5 or above run

ddev add-on get ddev/ddev-sqlsrv

For earlier versions of DDEV run

ddev get ddev/ddev-sqlsrv

Then restart your project

ddev restart

If your project already has a .ddev/.env file, you need to add the following lines to it:

MSSQL_EXTERNAL_PORT=1433
MSSQL_SA_PASSWORD=Password12!
MSSQL_PID=Evaluation
MSSQL_DB_NAME=master
MSSQL_HOST=sqlsrv

Drupal Notice

Drupal CMS needs the database function installed that is mimicking the Regex function as Drupal requires. As a one-time setup for Drupal, install the database function by running the following command from your project's directory:

ddev drupal-regex

This script also changes the setting for the following database variables:

  • show advanced options will be set to 1
  • clr strict security will be set to 0
  • clr enable will be set to 1

Drupal also required the sqlsrv module to be installed as it is provides the database driver for SQL Server. The module can be installed with composer with the following command:

ddev composer require drupal/sqlsrv

There is an open issue for Drupal 9.4+ installations. Until merged, you need to apply patch #4, see Call to a member function fetchField() on null

Manually enabling MySQL/MariaDB

This addons disables the default database by automatically adding omit_containers: [db,dba] in the config.sqlsrv.yaml

If your project needs to use both MariaDB and MS SQL Server databases, you have to remove #ddev-generated and omit_containers: [db,dba] from config.sqlsrv.yaml.

See .ddev/config.yaml Options for additional notes.

Links with useful information

Note that more advanced techniques are discussed in DDEV docs.

Contributed and maintained by @robertoperuzzo based on the original ddev-contrib recipe by drupal-daffie