|
| 1 | +-- Creates the following tables: |
| 2 | +-- * Entry |
| 3 | +-- * Feed |
| 4 | +-- * FeedItem |
| 5 | +-- * Revision |
| 6 | + |
| 7 | +create table $schema$.[Entry]( |
| 8 | + [Id] [int] identity(1,1) not null constraint PK_Entry_Id primary key, |
| 9 | + [Name] [nvarchar](50) not null, |
| 10 | + [Title] [nvarchar](200) not null, |
| 11 | + [Summary] [nvarchar](max) not null, |
| 12 | + [IsVisible] [bit] not null, |
| 13 | + [Published] [datetime] not null, |
| 14 | + [LatestRevisionId] [int] null |
| 15 | +) |
| 16 | +go |
| 17 | + |
| 18 | +create table $schema$.[Feed]( |
| 19 | + [Id] [int] identity(1,1) not null constraint PK_Feed_Id primary key, |
| 20 | + [Name] [nvarchar](100) not null, |
| 21 | + [Title] [nvarchar](255) not null, |
| 22 | +) |
| 23 | +go |
| 24 | + |
| 25 | +create table $schema$.[Revision]( |
| 26 | + [Id] [int] identity(1,1) not null constraint PK_Revision_Id primary key, |
| 27 | + [EntryId] [int] not null, |
| 28 | + [Body] [nvarchar](max) not null, |
| 29 | + [ChangeSummary] [nvarchar](1000) not null, |
| 30 | + [Reason] [nvarchar](1000) not null, |
| 31 | + [Revised] [datetime] not null, |
| 32 | + [Tags] [nvarchar](1000) not null, |
| 33 | + [Status] [int] not null, |
| 34 | + [IsVisible] [bit] not null, |
| 35 | + [RevisionNumber] [int] not null, |
| 36 | +) |
| 37 | +go |
| 38 | + |
| 39 | +create table $schema$.[FeedItem]( |
| 40 | + [Id] [int] identity(1,1) not null constraint PK_FeedItem_Id primary key, |
| 41 | + [FeedId] [int] not null, |
| 42 | + [ItemId] [int] not null, |
| 43 | + [SortDate] [datetime] not null, |
| 44 | +) |
| 45 | +go |
| 46 | + |
| 47 | +create table $schema$.[Comment]( |
| 48 | + [Id] [int] identity(1,1) not null constraint PK_Comment_Id primary key, |
| 49 | + [Body] [nvarchar](max) not null, |
| 50 | + [AuthorName] [nvarchar](100) not null, |
| 51 | + [AuthorCompany] [nvarchar](100) not null, |
| 52 | + [AuthorEmail] [nvarchar](100) not null, |
| 53 | + [AuthorUrl] [nvarchar](100) not null, |
| 54 | + [Posted] [datetime] not null, |
| 55 | + [EntryId] [int] not null, |
| 56 | + [Status] int not null |
| 57 | +) |
| 58 | +go |
| 59 | + |
| 60 | +alter table $schema$.[Revision] with check add constraint [FK_Revision_Entry] foreign key([EntryId]) |
| 61 | +references $schema$.[Entry] ([Id]) |
| 62 | +go |
| 63 | + |
| 64 | +alter table $schema$.[Revision] check constraint [FK_Revision_Entry] |
| 65 | +go |
| 66 | + |
| 67 | +alter table $schema$.[Revision] add constraint [DF_Revision_RevisionNumber] default ((0)) FOR [RevisionNumber] |
| 68 | +go |
| 69 | + |
| 70 | +alter table $schema$.[FeedItem] with check add constraint [FK_FeedItem_Entry] foreign key([ItemId]) |
| 71 | +references $schema$.[Entry] ([Id]) |
| 72 | +go |
| 73 | + |
| 74 | +alter table $schema$.[FeedItem] check constraint [FK_FeedItem_Entry] |
| 75 | +go |
| 76 | + |
| 77 | +alter table $schema$.[FeedItem] with check add constraint [FK_FeedItem_Feed] foreign key([FeedId]) |
| 78 | +references $schema$.[Feed] ([Id]) |
| 79 | +go |
| 80 | + |
| 81 | +alter table $schema$.[FeedItem] check constraint [FK_FeedItem_Feed] |
| 82 | +go |
| 83 | + |
| 84 | +alter table $schema$.[Comment] with check add constraint [FK_Comment_Comment] foreign key([EntryId]) |
| 85 | +references $schema$.[Entry] ([Id]) |
| 86 | +go |
| 87 | + |
| 88 | +alter table $schema$.[Comment] check constraint [FK_Comment_Comment] |
| 89 | +go |
0 commit comments