diff --git a/db/init/init.sql b/db/init/init.sql index f0442c7..26ed0f1 100644 --- a/db/init/init.sql +++ b/db/init/init.sql @@ -665,10 +665,81 @@ CREATE TABLE IF NOT EXISTS `user_remember_tokens` ( CONSTRAINT `fk_user_remember_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -INSERT INTO `tenants` (`uuid`, `description`, `created`) -SELECT UUID(), 'MusterMandant', NOW() +INSERT INTO `tenants` ( + `uuid`, + `description`, + `address`, + `postal_code`, + `city`, + `country`, + `region`, + `vat_id`, + `tax_number`, + `phone`, + `fax`, + `email`, + `support_email`, + `support_phone`, + `billing_email`, + `website`, + `privacy_url`, + `imprint_url`, + `primary_color`, + `default_theme`, + `allow_user_theme`, + `status`, + `created` +) +SELECT + UUID(), + 'MusterMandant', + 'Musterstrasse 1', + '10115', + 'Berlin', + 'Deutschland', + 'Berlin', + 'DE123456789', + '12/345/67890', + '+49 30 12345670', + '+49 30 12345679', + 'info@mustermandant.de', + 'support@mustermandant.de', + '+49 30 12345671', + 'billing@mustermandant.de', + 'https://www.mustermandant.de', + 'https://www.mustermandant.de/datenschutz', + 'https://www.mustermandant.de/impressum', + '#1A73E8', + 'light', + 1, + 'active', + NOW() WHERE NOT EXISTS (SELECT 1 FROM tenants WHERE description = 'MusterMandant'); +UPDATE `tenants` +SET + `address` = COALESCE(`address`, 'Musterstrasse 1'), + `postal_code` = COALESCE(`postal_code`, '10115'), + `city` = COALESCE(`city`, 'Berlin'), + `country` = COALESCE(`country`, 'Deutschland'), + `region` = COALESCE(`region`, 'Berlin'), + `vat_id` = COALESCE(`vat_id`, 'DE123456789'), + `tax_number` = COALESCE(`tax_number`, '12/345/67890'), + `phone` = COALESCE(`phone`, '+49 30 12345670'), + `fax` = COALESCE(`fax`, '+49 30 12345679'), + `email` = COALESCE(`email`, 'info@mustermandant.de'), + `support_email` = COALESCE(`support_email`, 'support@mustermandant.de'), + `support_phone` = COALESCE(`support_phone`, '+49 30 12345671'), + `billing_email` = COALESCE(`billing_email`, 'billing@mustermandant.de'), + `website` = COALESCE(`website`, 'https://www.mustermandant.de'), + `privacy_url` = COALESCE(`privacy_url`, 'https://www.mustermandant.de/datenschutz'), + `imprint_url` = COALESCE(`imprint_url`, 'https://www.mustermandant.de/impressum'), + `primary_color` = COALESCE(`primary_color`, '#1A73E8'), + `default_theme` = COALESCE(`default_theme`, 'light'), + `allow_user_theme` = COALESCE(`allow_user_theme`, 1), + `status` = COALESCE(`status`, 'active') +WHERE `description` = 'MusterMandant'; + INSERT INTO `departments` (`uuid`, `description`, `tenant_id`, `code`, `active`, `created`) SELECT UUID(), 'Musterabteilung', t.id, 'MUSTER', 1, NOW() FROM tenants t