1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
:VERSION 1
CREATE TABLE [assets] (
[id] [varchar](36) NOT NULL,
[name] [varchar](64) NOT NULL,
[description] [varchar](64) NOT NULL,
[assetType] [tinyint] NOT NULL,
[local] [tinyint] NOT NULL,
[temporary] [tinyint] NOT NULL,
[data] [image] NOT NULL,
PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
:VERSION 2
BEGIN TRANSACTION
CREATE TABLE Tmp_assets
(
id varchar(36) NOT NULL,
name varchar(64) NOT NULL,
description varchar(64) NOT NULL,
assetType tinyint NOT NULL,
local bit NOT NULL,
temporary bit NOT NULL,
data image NOT NULL
) ON [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
IF EXISTS(SELECT * FROM assets)
EXEC('INSERT INTO Tmp_assets (id, name, description, assetType, local, temporary, data)
SELECT id, name, description, assetType, CONVERT(bit, local), CONVERT(bit, temporary), data FROM assets WITH (HOLDLOCK TABLOCKX)')
DROP TABLE assets
EXECUTE sp_rename N'Tmp_assets', N'assets', 'OBJECT'
ALTER TABLE dbo.assets ADD CONSTRAINT
PK__assets__id PRIMARY KEY CLUSTERED
(
id
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
COMMIT
:VERSION 3
BEGIN TRANSACTION
ALTER TABLE assets add create_time integer default 0
ALTER TABLE assets add access_time integer default 0
COMMIT
:VERSION 4
BEGIN TRANSACTION
CREATE TABLE dbo.Tmp_assets
(
id uniqueidentifier NOT NULL,
name varchar(64) NOT NULL,
description varchar(64) NOT NULL,
assetType tinyint NOT NULL,
local bit NOT NULL,
temporary bit NOT NULL,
data image NOT NULL,
create_time int NULL,
access_time int NULL
) ON [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
IF EXISTS(SELECT * FROM dbo.assets)
EXEC('INSERT INTO dbo.Tmp_assets (id, name, description, assetType, local, temporary, data, create_time, access_time)
SELECT CONVERT(uniqueidentifier, id), name, description, assetType, local, temporary, data, create_time, access_time FROM dbo.assets WITH (HOLDLOCK TABLOCKX)')
DROP TABLE assets
EXECUTE sp_rename N'Tmp_assets', N'assets', 'OBJECT'
ALTER TABLE dbo.assets ADD CONSTRAINT
PK__assets__id PRIMARY KEY CLUSTERED
(
id
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
COMMIT
:VERSION 5
DELETE FROM assets WHERE id = 'dc4b9f0b-d008-45c6-96a4-01dd947ac621';
|