-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from ko4life-net/migrate-text-columns
Migrate database schema to modern types and improve string handling
- Loading branch information
Showing
4 changed files
with
6,287 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
-- Migrates legacy text columns to varchar(3000), which should be big enough to store really long NPC paths | ||
-- Also organized K_NPCPOS table | ||
|
||
CREATE TABLE [dbo].[K_NPCPOS_TMP] ( | ||
[ZoneID] [smallint] NOT NULL, | ||
[NpcID] [int] NOT NULL, | ||
[ActType] [tinyint] NOT NULL, | ||
[RegenType] [tinyint] NULL, | ||
[DungeonFamily] [tinyint] NULL, | ||
[SpecialType] [tinyint] NULL, | ||
[TrapNumber] [tinyint] NULL, | ||
[LeftX] [int] NOT NULL, | ||
[TopZ] [int] NOT NULL, | ||
[RightX] [int] NOT NULL, | ||
[BottomZ] [int] NOT NULL, | ||
[LimitMinX] [int] NULL, | ||
[LimitMinZ] [int] NULL, | ||
[LimitMaxX] [int] NULL, | ||
[LimitMaxZ] [int] NULL, | ||
[NumNPC] [tinyint] NOT NULL, | ||
[RegTime] [smallint] NOT NULL, | ||
[DotCnt] [tinyint] NOT NULL, | ||
[path] [varchar](3000) NULL -- Changed from ntext to varchar(3000) | ||
); | ||
|
||
INSERT INTO [dbo].[K_NPCPOS_TMP] ( | ||
[ZoneID], [NpcID], [ActType], [RegenType], [DungeonFamily], [SpecialType], [TrapNumber], | ||
[LeftX], [TopZ], [RightX], [BottomZ], [LimitMinX], [LimitMinZ], [LimitMaxX], [LimitMaxZ], | ||
[NumNPC], [RegTime], [DotCnt], [path] | ||
) | ||
SELECT | ||
[ZoneID], | ||
[NpcID], | ||
[ActType], | ||
[RegenType], | ||
[DungeonFamily], | ||
[SpecialType], | ||
[TrapNumber], | ||
[LeftX], | ||
[TopZ], | ||
[RightX], | ||
[BottomZ], | ||
[LimitMinX], | ||
[LimitMinZ], | ||
[LimitMaxX], | ||
[LimitMaxZ], | ||
[NumNPC], | ||
[RegTime], | ||
[DotCnt], | ||
CAST([path] AS varchar(3000)) -- Convert ntext to varchar | ||
FROM [dbo].[K_NPCPOS]; | ||
|
||
DROP TABLE [dbo].[K_NPCPOS]; | ||
EXEC sp_rename 'dbo.K_NPCPOS_TMP', 'K_NPCPOS'; | ||
|
||
-- Drop unused text column | ||
ALTER TABLE [dbo].[K_NPC] DROP COLUMN [Obs]; |
Oops, something went wrong.