暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

mailserver.sql.j2 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. -- If tables are not dropped, have to truncate before insert or use "insert or replace" (not postgres compatible)
  2. DROP TABLE IF EXISTS `virtual_users`;
  3. DROP TABLE IF EXISTS `virtual_aliases`;
  4. DROP TABLE IF EXISTS `virtual_domains`;
  5. CREATE TABLE IF NOT EXISTS `virtual_domains` (
  6. `id` int(11) NOT NULL auto_increment,
  7. `name` varchar(50) NOT NULL,
  8. PRIMARY KEY (`id`)
  9. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  10. CREATE TABLE IF NOT EXISTS `virtual_users` (
  11. `id` int(11) NOT NULL auto_increment,
  12. `domain_id` int(11) NOT NULL,
  13. `password` varchar(106) NOT NULL,
  14. `email` varchar(100) NOT NULL,
  15. PRIMARY KEY (`id`),
  16. UNIQUE KEY `email` (`email`),
  17. FOREIGN KEY (domain_id) REFERENCES virtual_domains(id) ON DELETE CASCADE
  18. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  19. CREATE TABLE IF NOT EXISTS `virtual_aliases` (
  20. `id` int(11) NOT NULL auto_increment,
  21. `domain_id` int(11) NOT NULL,
  22. `source` varchar(100) NOT NULL,
  23. `destination` varchar(100) NOT NULL,
  24. PRIMARY KEY (`id`),
  25. FOREIGN KEY (domain_id) REFERENCES virtual_domains(id) ON DELETE CASCADE
  26. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  27. {% for virtual_domain in mail_virtual_domains %}
  28. INSERT INTO {{ mail_mysql_database }}.`virtual_domains` (`id`, `name`)
  29. VALUES ('{{ virtual_domain.pk_id }}', '{{ virtual_domain.name }}');
  30. {% endfor %}
  31. {% for virtual_user in mail_virtual_users %}
  32. INSERT INTO {{ mail_mysql_database }}.`virtual_users` (`domain_id`, `password` , `email`)
  33. VALUES ('{{ virtual_user.domain_pk_id }}', '{{ virtual_user.password_hash }}', '{{ virtual_user.address }}');
  34. {% endfor %}
  35. {% if mail_virtual_aliases is defined %}
  36. {% for virtual_alias in mail_virtual_aliases %}
  37. INSERT INTO {{ mail_mysql_database }}.`virtual_aliases` (`domain_id`, `source`, `destination`)
  38. VALUES ('{{ virtual_alias.domain_pk_id }}', '{{ virtual_alias.source }}', '{{virtual_alias.destination }}');
  39. {% endfor %}
  40. {% endif %}