diff options
author | Florian Jacob <projects+git@florianjacob.de> | 2017-05-20 23:57:07 +0200 |
---|---|---|
committer | Franz Pletz <fpletz@fnordicwalking.de> | 2017-08-31 11:32:25 +0200 |
commit | d22c1c07196520c70c054e9dc127a37ce125a0d1 (patch) | |
tree | f341a00e12d7186c436acefef136c5cee41f37a6 /nixos/modules/services/databases | |
parent | a2bb174c63ec020f26e6f98cd1c9132adbb3b287 (diff) | |
download | nixlib-d22c1c07196520c70c054e9dc127a37ce125a0d1.tar nixlib-d22c1c07196520c70c054e9dc127a37ce125a0d1.tar.gz nixlib-d22c1c07196520c70c054e9dc127a37ce125a0d1.tar.bz2 nixlib-d22c1c07196520c70c054e9dc127a37ce125a0d1.tar.lz nixlib-d22c1c07196520c70c054e9dc127a37ce125a0d1.tar.xz nixlib-d22c1c07196520c70c054e9dc127a37ce125a0d1.tar.zst nixlib-d22c1c07196520c70c054e9dc127a37ce125a0d1.zip |
mysql service: Make initialDatabases.schema attribute optional
Diffstat (limited to 'nixos/modules/services/databases')
-rw-r--r-- | nixos/modules/services/databases/mysql.nix | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/nixos/modules/services/databases/mysql.nix b/nixos/modules/services/databases/mysql.nix index 6027f109285a..50766093307d 100644 --- a/nixos/modules/services/databases/mysql.nix +++ b/nixos/modules/services/databases/mysql.nix @@ -108,10 +108,13 @@ in initialDatabases = mkOption { default = []; - description = "List of database names and their initial schemas that should be used to create databases on the first startup of MySQL"; + description = '' + List of database names and their initial schemas that should be used to create databases on the first startup + of MySQL. The schema attribute is optional: If not specified, an empty database is created. + ''; example = [ { name = "foodatabase"; schema = literalExample "./foodatabase.sql"; } - { name = "bardatabase"; schema = literalExample "./bardatabase.sql"; } + { name = "bardatabase"; } ]; }; @@ -247,6 +250,8 @@ in if ! test -e "${cfg.dataDir}/${database.name}"; then echo "Creating initial database: ${database.name}" ( echo "create database ${database.name};" + + ${optionalString (database ? "schema") '' echo "use ${database.name};" if [ -f "${database.schema}" ] @@ -256,6 +261,7 @@ in then cat ${database.schema}/mysql-databases/*.sql fi + ''} ) | ${mysql}/bin/mysql -u root -N fi '') cfg.initialDatabases} |