Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

2011092800.sql 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. -- Updates from version 0.6
  2. CREATE TABLE [dbo].[dictionary] (
  3. [user_id] [int] ,
  4. [language] [varchar] (5) COLLATE Latin1_General_CI_AI NOT NULL ,
  5. [data] [text] COLLATE Latin1_General_CI_AI NOT NULL
  6. ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
  7. GO
  8. CREATE UNIQUE INDEX [IX_dictionary_user_language] ON [dbo].[dictionary]([user_id],[language]) ON [PRIMARY]
  9. GO
  10. CREATE TABLE [dbo].[searches] (
  11. [search_id] [int] IDENTITY (1, 1) NOT NULL ,
  12. [user_id] [int] NOT NULL ,
  13. [type] [tinyint] NOT NULL ,
  14. [name] [varchar] (128) COLLATE Latin1_General_CI_AI NOT NULL ,
  15. [data] [text] COLLATE Latin1_General_CI_AI NOT NULL
  16. ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
  17. GO
  18. ALTER TABLE [dbo].[searches] WITH NOCHECK ADD
  19. CONSTRAINT [PK_searches_search_id] PRIMARY KEY CLUSTERED
  20. (
  21. [search_id]
  22. ) ON [PRIMARY]
  23. GO
  24. ALTER TABLE [dbo].[searches] ADD
  25. CONSTRAINT [DF_searches_user] DEFAULT (0) FOR [user_id],
  26. CONSTRAINT [DF_searches_type] DEFAULT (0) FOR [type],
  27. GO
  28. CREATE UNIQUE INDEX [IX_searches_user_type_name] ON [dbo].[searches]([user_id],[type],[name]) ON [PRIMARY]
  29. GO
  30. ALTER TABLE [dbo].[searches] ADD CONSTRAINT [FK_searches_user_id]
  31. FOREIGN KEY ([user_id]) REFERENCES [dbo].[users] ([user_id])
  32. ON DELETE CASCADE ON UPDATE CASCADE
  33. GO
  34. DROP TABLE [dbo].[messages]
  35. GO
  36. CREATE TABLE [dbo].[cache_index] (
  37. [user_id] [int] NOT NULL ,
  38. [mailbox] [varchar] (128) COLLATE Latin1_General_CI_AI NOT NULL ,
  39. [changed] [datetime] NOT NULL ,
  40. [valid] [char] (1) COLLATE Latin1_General_CI_AI NOT NULL ,
  41. [data] [text] COLLATE Latin1_General_CI_AI NOT NULL
  42. ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
  43. GO
  44. CREATE TABLE [dbo].[cache_thread] (
  45. [user_id] [int] NOT NULL ,
  46. [mailbox] [varchar] (128) COLLATE Latin1_General_CI_AI NOT NULL ,
  47. [changed] [datetime] NOT NULL ,
  48. [data] [text] COLLATE Latin1_General_CI_AI NOT NULL
  49. ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
  50. GO
  51. CREATE TABLE [dbo].[cache_messages] (
  52. [user_id] [int] NOT NULL ,
  53. [mailbox] [varchar] (128) COLLATE Latin1_General_CI_AI NOT NULL ,
  54. [uid] [int] NOT NULL ,
  55. [changed] [datetime] NOT NULL ,
  56. [data] [text] COLLATE Latin1_General_CI_AI NOT NULL ,
  57. [flags] [int] NOT NULL
  58. ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
  59. GO
  60. ALTER TABLE [dbo].[cache_index] WITH NOCHECK ADD
  61. PRIMARY KEY CLUSTERED
  62. (
  63. [user_id],[mailbox]
  64. ) ON [PRIMARY]
  65. GO
  66. ALTER TABLE [dbo].[cache_thread] WITH NOCHECK ADD
  67. PRIMARY KEY CLUSTERED
  68. (
  69. [user_id],[mailbox]
  70. ) ON [PRIMARY]
  71. GO
  72. ALTER TABLE [dbo].[cache_messages] WITH NOCHECK ADD
  73. PRIMARY KEY CLUSTERED
  74. (
  75. [user_id],[mailbox],[uid]
  76. ) ON [PRIMARY]
  77. GO
  78. ALTER TABLE [dbo].[cache_index] ADD
  79. CONSTRAINT [DF_cache_index_changed] DEFAULT (getdate()) FOR [changed],
  80. CONSTRAINT [DF_cache_index_valid] DEFAULT ('0') FOR [valid]
  81. GO
  82. CREATE INDEX [IX_cache_index_user_id] ON [dbo].[cache_index]([user_id]) ON [PRIMARY]
  83. GO
  84. ALTER TABLE [dbo].[cache_thread] ADD
  85. CONSTRAINT [DF_cache_thread_changed] DEFAULT (getdate()) FOR [changed]
  86. GO
  87. CREATE INDEX [IX_cache_thread_user_id] ON [dbo].[cache_thread]([user_id]) ON [PRIMARY]
  88. GO
  89. ALTER TABLE [dbo].[cache_messages] ADD
  90. CONSTRAINT [DF_cache_messages_changed] DEFAULT (getdate()) FOR [changed],
  91. CONSTRAINT [DF_cache_messages_flags] DEFAULT (0) FOR [flags]
  92. GO
  93. CREATE INDEX [IX_cache_messages_user_id] ON [dbo].[cache_messages]([user_id]) ON [PRIMARY]
  94. GO
  95. ALTER TABLE [dbo].[cache_index] ADD CONSTRAINT [FK_cache_index_user_id]
  96. FOREIGN KEY ([user_id]) REFERENCES [dbo].[users] ([user_id])
  97. ON DELETE CASCADE ON UPDATE CASCADE
  98. GO
  99. ALTER TABLE [dbo].[cache_thread] ADD CONSTRAINT [FK_cache_thread_user_id]
  100. FOREIGN KEY ([user_id]) REFERENCES [dbo].[users] ([user_id])
  101. ON DELETE CASCADE ON UPDATE CASCADE
  102. GO
  103. ALTER TABLE [dbo].[cache_messages] ADD CONSTRAINT [FK_cache_messages_user_id]
  104. FOREIGN KEY ([user_id]) REFERENCES [dbo].[users] ([user_id])
  105. ON DELETE CASCADE ON UPDATE CASCADE
  106. GO