schema-mysql.sql 990 B

12345678910111213141516171819202122232425262728293031323334
  1. /**
  2. * Database schema required by \yii\i18n\DbMessageSource.
  3. *
  4. * @author Dmitry Naumenko <d.naumenko.a@gmail.com>
  5. * @link http://www.yiiframework.com/
  6. * @copyright 2008 Yii Software LLC
  7. * @license http://www.yiiframework.com/license/
  8. * @since 2.0.7
  9. */
  10. drop table if exists `source_message`;
  11. drop table if exists `message`;
  12. CREATE TABLE `source_message`
  13. (
  14. `id` integer NOT NULL AUTO_INCREMENT PRIMARY KEY,
  15. `category` varchar(255),
  16. `message` text
  17. );
  18. CREATE TABLE `message`
  19. (
  20. `id` integer NOT NULL,
  21. `language` varchar(16) NOT NULL,
  22. `translation` text
  23. );
  24. ALTER TABLE `message` ADD CONSTRAINT `pk_message_id_language` PRIMARY KEY (`id`, `language`);
  25. ALTER TABLE `message` ADD CONSTRAINT `fk_message_source_message` FOREIGN KEY (`id`) REFERENCES `source_message` (`id`) ON UPDATE CASCADE ON DELETE RESTRICT;
  26. CREATE INDEX idx_message_language ON message (language);
  27. CREATE INDEX idx_source_message_category ON source_message (category);