Skip to content

Commit

Permalink
Add PostHistory table
Browse files Browse the repository at this point in the history
Addresses #8.
  • Loading branch information
Andrew Brobston committed Nov 16, 2017
1 parent a2cdc4e commit c677647
Show file tree
Hide file tree
Showing 6 changed files with 243 additions and 1 deletion.
84 changes: 83 additions & 1 deletion soddi/Loaders/Scripts/mssql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ IF (OBJECT_ID('DUMMY.FK_Votes_UserId__Users_Id', 'F') IS NOT NULL)
ALTER TABLE DUMMY.Votes DROP CONSTRAINT FK_Votes_UserId__Users_Id;
IF (OBJECT_ID('DUMMY.FK_Votes_UserId__VoteTypes_Id', 'F') IS NOT NULL)
ALTER TABLE DUMMY.Votes DROP CONSTRAINT FK_Votes_UserId__VoteTypes_Id;
IF (OBJECT_ID('DUMMY.FK_PostHistory_PostId__Posts_Id', 'F') IS NOT NULL)
ALTER TABLE DUMMY.PostHistory DROP CONSTRAINT FK_PostHistory_PostId__Posts_Id;
IF (OBJECT_ID('DUMMY.FK_PostHistory_UserId__Users_Id', 'F') IS NOT NULL)
ALTER TABLE DUMMY.PostHistory DROP CONSTRAINT FK_PostHistory_UserId__Users_Id;
IF (OBJECT_ID('DUMMY.FK_PostHistory_PostHistoryTypeId__PostHistoryTypes_Id', 'F') IS NOT NULL)
ALTER TABLE DUMMY.PostHistory DROP CONSTRAINT FK_PostHistory_PostHistoryTypeId__PostHistoryTypes_Id;

IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'DUMMY.[Badges]') AND type in (N'U'))
DROP TABLE DUMMY.[Badges];
Expand All @@ -49,6 +55,10 @@ IF EXISTS (SELECT * FROM sys.objects WHERE OBJECT_ID = OBJECT_ID(N'DUMMY.[LinkTy
DROP TABLE DUMMY.[LinkTypes];
IF EXISTS (SELECT * FROM sys.objects WHERE OBJECT_ID = OBJECT_ID(N'DUMMY.[Tags]') AND type IN (N'U'))
DROP TABLE DUMMY.[Tags];
IF EXISTS (SELECT * FROM sys.objects WHERE OBJECT_ID = OBJECT_ID(N'DUMMY.[PostHistory]') AND type in (N'U'))
DROP TABLE DUMMY.[PostHistory];
IF EXISTS (SELECT * FROM sys.objects WHERE OBJECT_ID = OBJECT_ID(N'DUMMY.[PostHistoryTypes]') AND type IN (N'U'))
DROP TABLE DUMMY.[PostHistoryTypes];

IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'DUMMY.[Badges]') AND type in (N'U'))
DROP TABLE DUMMY.[Badges]
Expand All @@ -72,6 +82,10 @@ IF EXISTS (SELECT * FROM sys.objects WHERE OBJECT_ID = OBJECT_ID(N'DUMMY.[LinkTy
DROP TABLE DUMMY.[LinkTypes]
IF EXISTS (SELECT * FROM sys.objects WHERE OBJECT_ID = OBJECT_ID(N'DUMMY.[Tags]') AND type IN (N'U'))
DROP TABLE DUMMY.[Tags];
IF EXISTS (SELECT * FROM sys.objects WHERE OBJECT_ID = OBJECT_ID(N'DUMMY.[PostHistory]') AND type in (N'U'))
DROP TABLE DUMMY.[PostHistory];
IF EXISTS (SELECT * FROM sys.objects WHERE OBJECT_ID = OBJECT_ID(N'DUMMY.[PostHistoryTypes]') AND type IN (N'U'))
DROP TABLE DUMMY.[PostHistoryTypes];

SET ansi_nulls ON
SET quoted_identifier ON
Expand All @@ -98,6 +112,12 @@ CREATE TABLE DUMMY.[PostTypes] (
, CONSTRAINT [PK_PostTypes__Id] PRIMARY KEY CLUSTERED ( [Id] ASC ) ON [PRIMARY]
) ON [PRIMARY]

CREATE TABLE DUMMY.[PostHistoryTypes] (
[Id] INT /* IDENTITY */ NOT NULL,
[Type] NVARCHAR(50) NOT NULL,
CONSTRAINT [PK_PostHistoryTypes__Id] PRIMARY KEY CLUSTERED ( [Id] ASC ) ON [PRIMARY]
) ON [PRIMARY]

IF 0 = 1--SPLIT
BEGIN
SET ansi_nulls ON
Expand Down Expand Up @@ -145,7 +165,46 @@ INSERT DUMMY.[LinkTypes] ([Id], [Type]) VALUES(1, N'Linked')
INSERT DUMMY.[LinkTypes] ([Id], [Type]) VALUES(3, N'Duplicate')
--IDENTITY SET IDENTITY_INSERT [DUMMY].[LinkTypes] OFF
--IDENTITY DBCC CHECKIDENT('DUMMY.LinkTypes', RESEED)

--IDENTITY SET IDENTITY_INSERT [DUMMY].[PostHistoryTypes] ON
INSERT DUMMY.[PostHistoryTypes] ([Id], [Type]) VALUES(1, N'InitialTitle')
INSERT DUMMY.[PostHistoryTypes] ([Id], [Type]) VALUES(2, N'InitialBody')
INSERT DUMMY.[PostHistoryTypes] ([Id], [Type]) VALUES(3, N'InitialTags')
INSERT DUMMY.[PostHistoryTypes] ([Id], [Type]) VALUES(4, N'EditTitle')
INSERT DUMMY.[PostHistoryTypes] ([Id], [Type]) VALUES(5, N'EditBody')
INSERT DUMMY.[PostHistoryTypes] ([Id], [Type]) VALUES(6, N'EditTags')
INSERT DUMMY.[PostHistoryTypes] ([Id], [Type]) VALUES(7, N'RollbackTitle')
INSERT DUMMY.[PostHistoryTypes] ([Id], [Type]) VALUES(8, N'RollbackBody')
INSERT DUMMY.[PostHistoryTypes] ([Id], [Type]) VALUES(9, N'RollbackTags')
INSERT DUMMY.[PostHistoryTypes] ([Id], [Type]) VALUES(10, N'PostClosed')
INSERT DUMMY.[PostHistoryTypes] ([Id], [Type]) VALUES(11, N'PostReopened')
INSERT DUMMY.[PostHistoryTypes] ([Id], [Type]) VALUES(12, N'PostDeleted')
INSERT DUMMY.[PostHistoryTypes] ([Id], [Type]) VALUES(13, N'PostUndeleted')
INSERT DUMMY.[PostHistoryTypes] ([Id], [Type]) VALUES(14, N'PostLocked')
INSERT DUMMY.[PostHistoryTypes] ([Id], [Type]) VALUES(15, N'PostUnlocked')
INSERT DUMMY.[PostHistoryTypes] ([Id], [Type]) VALUES(16, N'CommunityOwned')
INSERT DUMMY.[PostHistoryTypes] ([Id], [Type]) VALUES(17, N'PostMigrated')
INSERT DUMMY.[PostHistoryTypes] ([Id], [Type]) VALUES(18, N'QuestionMerged')
INSERT DUMMY.[PostHistoryTypes] ([Id], [Type]) VALUES(19, N'QuestionProtected')
INSERT DUMMY.[PostHistoryTypes] ([Id], [Type]) VALUES(20, N'QuestionUnprotected')
INSERT DUMMY.[PostHistoryTypes] ([Id], [Type]) VALUES(21, N'PostDisassociated')
INSERT DUMMY.[PostHistoryTypes] ([Id], [Type]) VALUES(22, N'QuestionUnmerged')
INSERT DUMMY.[PostHistoryTypes] ([Id], [Type]) VALUES(23, N'UnknownDevRelatedEvent')
INSERT DUMMY.[PostHistoryTypes] ([Id], [Type]) VALUES(24, N'SuggestedEditApplied')
INSERT DUMMY.[PostHistoryTypes] ([Id], [Type]) VALUES(25, N'PostTweeted')
INSERT DUMMY.[PostHistoryTypes] ([Id], [Type]) VALUES(26, N'VoteNullificationByDev')
INSERT DUMMY.[PostHistoryTypes] ([Id], [Type]) VALUES(27, N'PostUnmigrated')
INSERT DUMMY.[PostHistoryTypes] ([Id], [Type]) VALUES(28, N'UnknownSuggestionEvent')
INSERT DUMMY.[PostHistoryTypes] ([Id], [Type]) VALUES(29, N'UnknownModeratorEvent')
INSERT DUMMY.[PostHistoryTypes] ([Id], [Type]) VALUES(30, N'UnknownEvent')
INSERT DUMMY.[PostHistoryTypes] ([Id], [Type]) VALUES(31, N'CommentDiscussionMovedToChat')
INSERT DUMMY.[PostHistoryTypes] ([Id], [Type]) VALUES(33, N'PostNoticeAdded')
INSERT DUMMY.[PostHistoryTypes] ([Id], [Type]) VALUES(34, N'PostNoticeRemoved')
INSERT DUMMY.[PostHistoryTypes] ([Id], [Type]) VALUES(35, N'PostMigratedAway')
INSERT DUMMY.[PostHistoryTypes] ([Id], [Type]) VALUES(36, N'PostMigratedHere')
INSERT DUMMY.[PostHistoryTypes] ([Id], [Type]) VALUES(37, N'PostMergeSource')
INSERT DUMMY.[PostHistoryTypes] ([Id], [Type]) VALUES(38, N'PostMergeDestination')
--IDENTITY SET IDENTITY_INSERT [DUMMY].[PostHistoryTypes] OFF
--IDENTITY DBCC CHECKIDENT('DUMMY.PostHistoryTypes', RESEED)

IF 0 = 1--FULLTEXT
BEGIN
Expand Down Expand Up @@ -353,6 +412,20 @@ CREATE TABLE DUMMY.[Tags] (
CONSTRAINT [PK_Tags__Id] PRIMARY KEY CLUSTERED ([Id] ASC) ON [PRIMARY]
) ON [PRIMARY]

CREATE TABLE DUMMY.[PostHistory] (
[Id] INT /* IDENTITY */ NOT NULL,
[PostHistoryTypeId] INT NOT NULL,
[PostId] INT NOT NULL,
-- Not a UNIQUEIDENTIFIER for conversion reasons
[RevisionGUID] CHAR(36) NOT NULL,
[CreationDate] DATETIME NOT NULL,
[UserId] INT NULL,
[UserDisplayName] NVARCHAR(40) NULL,
[Comment] NTEXT NULL,
[Text] NTEXT NULL,
CONSTRAINT [PK_PostHistory__Id] PRIMARY KEY CLUSTERED ([Id] ASC) ON [PRIMARY]
) ON [PRIMARY]

IF 0 = 1-- INDICES
BEGIN
CREATE NONCLUSTERED INDEX [IX_Badges__Id_UserId] ON DUMMY.[Badges] (
Expand Down Expand Up @@ -382,6 +455,15 @@ IF 0 = 1--FK
ALTER TABLE Comments
ADD CONSTRAINT FK_Comments_UserId__Users_Id FOREIGN KEY (UserId) REFERENCES Users(Id)

ALTER TABLE PostHistory
ADD CONSTRAINT FK_PostHistory_PostId__Posts_Id FOREIGN KEY (PostId) REFERENCES Posts(Id)

ALTER TABLE PostHistory
ADD CONSTRAINT FK_PostHistory_UserId__Users_Id FOREIGN KEY (UserId) REFERENCES Users(Id)

ALTER TABLE PostHistory
ADD CONSTRAINT FK_PostHistory_PostHistoryTypeId__PostHistoryTypes_Id FOREIGN KEY (PostHistoryTypeId) REFERENCES PostHistoryTypes(Id)

ALTER TABLE PostLinks
ADD CONSTRAINT FK_PostLinks_PostId__Posts_Id FOREIGN KEY (PostId) REFERENCES Posts(Id)

Expand Down
71 changes: 71 additions & 0 deletions soddi/Loaders/Scripts/mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,20 @@ ENGINE = MyISAM
DEFAULT CHARACTER SET = latin1;


-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
-- Table DUMMY.`posthistorytypes`
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
DROP TABLE IF EXISTS DUMMY.`posthistorytypes` ;

CREATE TABLE IF NOT EXISTS DUMMY.`posthistorytypes` (
`Id` INT(11) NOT NULL /* IDENTITY */,
`Type` VARCHAR(50) CHARACTER SET 'utf8' NOT NULL,
PRIMARY KEY (`Id`)
)
ENGINE = MyISAM
DEFAULT CHARACTER SET = latin1;



INSERT DUMMY.`VoteTypes` (`Id`, `Name`) VALUES(1, 'AcceptedByOriginator');
INSERT DUMMY.`VoteTypes` (`Id`, `Name`) VALUES(2, 'UpMod');
Expand All @@ -62,6 +76,43 @@ INSERT DUMMY.`VoteTypes` (`Id`, `Name`) VALUES(12,'Spam');
INSERT DUMMY.`VoteTypes` (`Id`, `Name`) VALUES(13,'InformModerator');
INSERT DUMMY.`PostTypes` (`Id`, `Type`) VALUES(1, 'Question') ;
INSERT DUMMY.`PostTypes` (`Id`, `Type`) VALUES(2, 'Answer') ;
INSERT DUMMY.`PostHistoryTypes` (`Id`, `Type`) VALUES(1, 'InitialTitle');
INSERT DUMMY.`PostHistoryTypes` (`Id`, `Type`) VALUES(2, 'InitialBody');
INSERT DUMMY.`PostHistoryTypes` (`Id`, `Type`) VALUES(3, 'InitialTags');
INSERT DUMMY.`PostHistoryTypes` (`Id`, `Type`) VALUES(4, 'EditTitle');
INSERT DUMMY.`PostHistoryTypes` (`Id`, `Type`) VALUES(5, 'EditBody');
INSERT DUMMY.`PostHistoryTypes` (`Id`, `Type`) VALUES(6, 'EditTags');
INSERT DUMMY.`PostHistoryTypes` (`Id`, `Type`) VALUES(7, 'RollbackTitle');
INSERT DUMMY.`PostHistoryTypes` (`Id`, `Type`) VALUES(8, 'RollbackBody');
INSERT DUMMY.`PostHistoryTypes` (`Id`, `Type`) VALUES(9, 'RollbackTags');
INSERT DUMMY.`PostHistoryTypes` (`Id`, `Type`) VALUES(10, 'PostClosed');
INSERT DUMMY.`PostHistoryTypes` (`Id`, `Type`) VALUES(11, 'PostReopened');
INSERT DUMMY.`PostHistoryTypes` (`Id`, `Type`) VALUES(12, 'PostDeleted');
INSERT DUMMY.`PostHistoryTypes` (`Id`, `Type`) VALUES(13, 'PostUndeleted');
INSERT DUMMY.`PostHistoryTypes` (`Id`, `Type`) VALUES(14, 'PostLocked');
INSERT DUMMY.`PostHistoryTypes` (`Id`, `Type`) VALUES(15, 'PostUnlocked');
INSERT DUMMY.`PostHistoryTypes` (`Id`, `Type`) VALUES(16, 'CommunityOwned');
INSERT DUMMY.`PostHistoryTypes` (`Id`, `Type`) VALUES(17, 'PostMigrated');
INSERT DUMMY.`PostHistoryTypes` (`Id`, `Type`) VALUES(18, 'QuestionMerged');
INSERT DUMMY.`PostHistoryTypes` (`Id`, `Type`) VALUES(19, 'QuestionProtected');
INSERT DUMMY.`PostHistoryTypes` (`Id`, `Type`) VALUES(20, 'QuestionUnprotected');
INSERT DUMMY.`PostHistoryTypes` (`Id`, `Type`) VALUES(21, 'PostDisassociated');
INSERT DUMMY.`PostHistoryTypes` (`Id`, `Type`) VALUES(22, 'QuestionUnmerged');
INSERT DUMMY.`PostHistoryTypes` (`Id`, `Type`) VALUES(23, 'UnknownDevRelatedEvent');
INSERT DUMMY.`PostHistoryTypes` (`Id`, `Type`) VALUES(24, 'SuggestedEditApplied');
INSERT DUMMY.`PostHistoryTypes` (`Id`, `Type`) VALUES(25, 'PostTweeted');
INSERT DUMMY.`PostHistoryTypes` (`Id`, `Type`) VALUES(26, 'VoteNullificationByDev');
INSERT DUMMY.`PostHistoryTypes` (`Id`, `Type`) VALUES(27, 'PostUnmigrated');
INSERT DUMMY.`PostHistoryTypes` (`Id`, `Type`) VALUES(28, 'UnknownSuggestionEvent');
INSERT DUMMY.`PostHistoryTypes` (`Id`, `Type`) VALUES(29, 'UnknownModeratorEvent');
INSERT DUMMY.`PostHistoryTypes` (`Id`, `Type`) VALUES(30, 'UnknownEvent');
INSERT DUMMY.`PostHistoryTypes` (`Id`, `Type`) VALUES(31, 'CommentDiscussionMovedToChat');
INSERT DUMMY.`PostHistoryTypes` (`Id`, `Type`) VALUES(33, 'PostNoticeAdded');
INSERT DUMMY.`PostHistoryTypes` (`Id`, `Type`) VALUES(34, 'PostNoticeRemoved');
INSERT DUMMY.`PostHistoryTypes` (`Id`, `Type`) VALUES(35, 'PostMigratedAway');
INSERT DUMMY.`PostHistoryTypes` (`Id`, `Type`) VALUES(36, 'PostMigratedHere');
INSERT DUMMY.`PostHistoryTypes` (`Id`, `Type`) VALUES(37, 'PostMergeSource');
INSERT DUMMY.`PostHistoryTypes` (`Id`, `Type`) VALUES(38, 'PostMergeDestination');

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
-- Table DUMMY.`badges`
Expand Down Expand Up @@ -101,6 +152,26 @@ DEFAULT CHARACTER SET = latin1;
-- INDICES CREATE INDEX `IX_Comments_Id_PostId` ON DUMMY.`comments` (`Id` ASC, `PostId` ASC) ;
-- INDICES CREATE INDEX `IX_Comments_Id_UserId` ON DUMMY.`comments` (`Id` ASC, `UserId` ASC) ;

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
-- Table DUMMY.`posthistory`
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
DROP TABLE IF EXISTS DUMMY.`posthistory` ;

CREATE TABLE IF NOT EXISTS DUMMY.`posthistory` (
`Id` INT(11) NOT NULL /* IDENTITY */,
`PostHistoryTypeId` INT(11) NOT NULL,
`PostId` INT(11) NOT NULL,
`RevisionGUID` CHAR(36) NOT NULL,
`CreationDate` DATETIME NOT NULL,
`UserId` INT NULL,
`UserDisplayName` VARCHAR(40) CHARACTER SET 'utf8' NULL,
`Comment` TEXT CHARACTER SET 'utf8' NULL,
`Text` TEXT CHARACTER SET 'utf8' NULL,
PRIMARY KEY (`Id`)
)
ENGINE = MyISAM
DEFAULT CHARACTER SET = latin1;

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
-- Table DUMMY.`postlinks`
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
Expand Down
54 changes: 54 additions & 0 deletions soddi/Loaders/Scripts/sqlite-main.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ CREATE TABLE [PostTags] (
,CONSTRAINT [PK_PostTags] PRIMARY KEY ([PostId], [Tag]
)
);
CREATE TABLE [PostHistoryTypes] (
[Id] INTEGER PRIMARY KEY /* IDENTITY */ NOT NULL,
[Type] nvarchar(50) NOT NULL
);


INSERT INTO VoteTypes (Id, Name) VALUES(1, 'AcceptedByOriginator');
Expand All @@ -39,6 +43,45 @@ INSERT INTO VoteTypes (Id, Name) VALUES(12,'Spam');
INSERT INTO VoteTypes (Id, Name) VALUES(13,'InformModerator');
INSERT INTO PostTypes (Id, Type) VALUES(1, 'Question');
INSERT INTO PostTypes (Id, Type) VALUES(2, 'Answer');
INSERT INTO PostHistoryTypes (Id, Type) VALUES(1, 'InitialTitle');
INSERT INTO PostHistoryTypes (Id, Type) VALUES(2, 'InitialBody');
INSERT INTO PostHistoryTypes (Id, Type) VALUES(3, 'InitialTags');
INSERT INTO PostHistoryTypes (Id, Type) VALUES(4, 'EditTitle');
INSERT INTO PostHistoryTypes (Id, Type) VALUES(5, 'EditBody');
INSERT INTO PostHistoryTypes (Id, Type) VALUES(6, 'EditTags');
INSERT INTO PostHistoryTypes (Id, Type) VALUES(7, 'RollbackTitle');
INSERT INTO PostHistoryTypes (Id, Type) VALUES(8, 'RollbackBody');
INSERT INTO PostHistoryTypes (Id, Type) VALUES(9, 'RollbackTags');
INSERT INTO PostHistoryTypes (Id, Type) VALUES(10, 'PostClosed');
INSERT INTO PostHistoryTypes (Id, Type) VALUES(11, 'PostReopened');
INSERT INTO PostHistoryTypes (Id, Type) VALUES(12, 'PostDeleted');
INSERT INTO PostHistoryTypes (Id, Type) VALUES(13, 'PostUndeleted');
INSERT INTO PostHistoryTypes (Id, Type) VALUES(14, 'PostLocked');
INSERT INTO PostHistoryTypes (Id, Type) VALUES(15, 'PostUnlocked');
INSERT INTO PostHistoryTypes (Id, Type) VALUES(16, 'CommunityOwned');
INSERT INTO PostHistoryTypes (Id, Type) VALUES(17, 'PostMigrated');
INSERT INTO PostHistoryTypes (Id, Type) VALUES(18, 'QuestionMerged');
INSERT INTO PostHistoryTypes (Id, Type) VALUES(19, 'QuestionProtected');
INSERT INTO PostHistoryTypes (Id, Type) VALUES(20, 'QuestionUnprotected');
INSERT INTO PostHistoryTypes (Id, Type) VALUES(21, 'PostDisassociated');
INSERT INTO PostHistoryTypes (Id, Type) VALUES(22, 'QuestionUnmerged');
INSERT INTO PostHistoryTypes (Id, Type) VALUES(23, 'UnknownDevRelatedEvent');
INSERT INTO PostHistoryTypes (Id, Type) VALUES(24, 'SuggestedEditApplied');
INSERT INTO PostHistoryTypes (Id, Type) VALUES(25, 'PostTweeted');
INSERT INTO PostHistoryTypes (Id, Type) VALUES(26, 'VoteNullificationByDev');
INSERT INTO PostHistoryTypes (Id, Type) VALUES(27, 'PostUnmigrated');
INSERT INTO PostHistoryTypes (Id, Type) VALUES(28, 'UnknownSuggestionEvent');
INSERT INTO PostHistoryTypes (Id, Type) VALUES(29, 'UnknownModeratorEvent');
INSERT INTO PostHistoryTypes (Id, Type) VALUES(30, 'UnknownEvent');
INSERT INTO PostHistoryTypes (Id, Type) VALUES(31, 'CommentDiscussionMovedToChat');
INSERT INTO PostHistoryTypes (Id, Type) VALUES(33, 'PostNoticeAdded');
INSERT INTO PostHistoryTypes (Id, Type) VALUES(34, 'PostNoticeRemoved');
INSERT INTO PostHistoryTypes (Id, Type) VALUES(35, 'PostMigratedAway');
INSERT INTO PostHistoryTypes (Id, Type) VALUES(36, 'PostMigratedHere');
INSERT INTO PostHistoryTypes (Id, Type) VALUES(37, 'PostMergeSource');
INSERT INTO PostHistoryTypes (Id, Type) VALUES(38, 'PostMergeDestination');



CREATE TABLE [Votes] (
[Id] INTEGER PRIMARY KEY /* IDENTITY */ NOT NULL,
Expand Down Expand Up @@ -106,6 +149,17 @@ CREATE TABLE [PostLinks] (
[RelatedPostId] int NOT NULL,
[LinkTypeId] int NOT NULL
);
CREATE TABLE [PostHistory] (
[Id] INTEGER PRIMARY KEY /* IDENTITY */ NOT NULL,
[PostHistoryTypeId] INT NOT NULL,
[PostId] INT NOT NULL,
[RevisionGUID] CHAR(36) NOT NULL,
[CreationDate] DATETIME NOT NULL,
[UserId] INT NULL,
[UserDisplayName] VARCHAR(40) NULL,
[Comment] TEXT NULL,
[Text] TEXT NULL
);
CREATE TABLE [Tags] (
[Id] INTEGER PRIMARY KEY /* IDENTITY */ NOT NULL,
[TagName] nvarchar(150) NOT NULL,
Expand Down
13 changes: 13 additions & 0 deletions soddi/Loaders/Scripts/sqlite-tmp.sql
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@ CREATE TABLE [Comments_tmp] (
[UserId] int
);

DROP TABLE IF EXISTS [PostHistory_tmp];
CREATE TABLE [PostHistory_tmp] (
[Id] INT NOT NULL,
[PostHistoryTypeId] INT NOT NULL,
[PostId] INT NOT NULL,
[RevisionGUID] CHAR(36) NOT NULL,
[CreationDate] DATETIME NOT NULL,
[UserId] INT NULL,
[UserDisplayName] VARCHAR(40) NULL,
[Comment] TEXT NULL,
[Text] TEXT NULL
);

DROP TABLE IF EXISTS [Posts_tmp];
CREATE TABLE [Posts_tmp] (
[Id] int NOT NULL,
Expand Down
21 changes: 21 additions & 0 deletions soddi/TableTypes/PostHistory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using Salient.StackExchange.Import.Loaders;

namespace Salient.StackExchange.Import.TableTypes
{
public class PostHistory : SoBase<PostHistory>, ISoBase
{
public int Id { get; set; }
public int PostHistoryTypeId { get; set; }
public int PostId { get; set; }
// Not a Guid for conversion reasons
public string RevisionGUID { get; set; }
public DateTime CreationDate { get; set; }
public int? UserId { get; set; }
public string UserDisplayName { get; set; }
public string Comment { get; set; }
public string Text { get; set; }

public static string GetFileName() => "PostHistory.xml";
}
}
1 change: 1 addition & 0 deletions soddi/soddi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
<Compile Include="TableTypes\Comments.cs" />
<Compile Include="Loaders\ISoBase.cs" />
<Compile Include="Loaders\LoaderAttribute.cs" />
<Compile Include="TableTypes\PostHistory.cs" />
<Compile Include="TableTypes\PostLinks.cs" />
<Compile Include="TableTypes\Posts.cs" />
<Compile Include="TableTypes\PostTags.cs" />
Expand Down

0 comments on commit c677647

Please sign in to comment.