schema-mssql.sql 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  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. if object_id('[source_message]', 'U') is not null
  11. drop table [source_message];
  12. if object_id('[message]', 'U') is not null
  13. drop table [message];
  14. CREATE TABLE [source_message]
  15. (
  16. [id] integer IDENTITY PRIMARY KEY,
  17. [category] varchar(255),
  18. [message] text
  19. );
  20. CREATE TABLE [message]
  21. (
  22. [id] integer NOT NULL,
  23. [language] varchar(16) NOT NULL,
  24. [translation] text
  25. );
  26. ALTER TABLE [message] ADD CONSTRAINT [pk_message_id_language] PRIMARY KEY ([id], [language]);
  27. ALTER TABLE [message] ADD CONSTRAINT [fk_message_source_message] FOREIGN KEY ([id]) REFERENCES [source_message] ([id]) ON UPDATE CASCADE ON DELETE NO ACTION;
  28. CREATE INDEX [idx_message_language] on [message] ([language]);
  29. CREATE INDEX [idx_source_message_category] on [source_message] ([category]);