Skip to content

Commit e7dd536

Browse files
committed
Minor fixes
1 parent f290ab5 commit e7dd536

5 files changed

Lines changed: 96 additions & 300 deletions

File tree

SmartStoreNET.Tasks.Targets

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@
9898

9999
<ItemGroup>
100100
<PluginFiles Include="$(WebPluginsFolder)\**\*" />
101+
<MigrationFiles Include="$(WebFolder)\App_Data\Migrations\**\*.sql" />
102+
<MigrationFiles Include="$(WebFolder)\App_Data\Migrations\**\*.txt" />
101103
<UploadedImages Include="$(WebFolder)\Media\uploaded\**\*" />
102104
<SqlCe-Native-Binaries-x86 Include="$(SqlCeFolder)\x86\**\*"/>
103105
<SqlCe-Native-Binaries-amd64 Include="$(SqlCeFolder)\amd64\**\*"/>
@@ -123,6 +125,9 @@
123125

124126
<!-- copy the plugins to the stage directory -->
125127
<Copy SourceFiles="@(PluginFiles)" DestinationFolder="$(StageFolder)\Plugins\%(RecursiveDir)" />
128+
129+
<!-- copy the migration sql scripts to the stage directory -->
130+
<Copy SourceFiles="@(MigrationFiles)" DestinationFolder="$(StageFolder)\App_Data\Migrations\%(RecursiveDir)" />
126131

127132
<!-- publish SmartStore.Admin -->
128133
<MSBuild Projects="$(WebFolder)\Administration\SmartStore.Admin.csproj"

src/Presentation/SmartStore.Web/App_Data/Migrations/1.2.1-1.3.0/2-migrate-core.sql

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -115,42 +115,28 @@ GO
115115
ALTER TABLE [Manufacturer] ALTER COLUMN [PictureId] [int] NULL
116116
GO
117117

118-
Update [Product] SET SampleDownloadId = null WHERE SampleDownloadId = 0
119118
Update [Category] SET PictureId = null WHERE PictureId = 0
120-
Update [Manufacturer] SET PictureId = null WHERE PictureId = 0
121-
119+
GO
122120
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id=OBJECT_ID('[Category]') and NAME='IX_PictureId')
123121
BEGIN
124122
CREATE INDEX [IX_PictureId] ON [Category]([PictureId])
125123
END
126124
GO
127-
128-
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id=OBJECT_ID('[Manufacturer]') and NAME='IX_PictureId')
125+
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[Category_Picture]') AND parent_object_id = OBJECT_ID(N'[Category]'))
129126
BEGIN
130-
CREATE INDEX [IX_PictureId] ON [Manufacturer]([PictureId])
127+
ALTER TABLE [Category] WITH CHECK ADD CONSTRAINT [Category_Picture] FOREIGN KEY ([PictureId]) REFERENCES [Picture] ([Id])
131128
END
132129
GO
133130

134-
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id=OBJECT_ID('[Product]') and NAME='IX_SampleDownloadId')
135-
BEGIN
136-
CREATE INDEX [IX_SampleDownloadId] ON [Product]([SampleDownloadId])
137-
END
131+
Update [Manufacturer] SET PictureId = null WHERE PictureId = 0
138132
GO
139-
140-
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[Category_Picture]') AND parent_object_id = OBJECT_ID(N'[Category]'))
133+
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id=OBJECT_ID('[Manufacturer]') and NAME='IX_PictureId')
141134
BEGIN
142-
ALTER TABLE [Category] WITH CHECK ADD CONSTRAINT [Category_Picture] FOREIGN KEY ([PictureId]) REFERENCES [Picture] ([Id])
135+
CREATE INDEX [IX_PictureId] ON [Manufacturer]([PictureId])
143136
END
144137
GO
145-
146138
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_dbo.Manufacturer_dbo.Picture_PictureId]') AND parent_object_id = OBJECT_ID(N'[Manufacturer]'))
147139
BEGIN
148140
ALTER TABLE [Manufacturer] WITH CHECK ADD CONSTRAINT [FK_dbo.Manufacturer_dbo.Picture_PictureId] FOREIGN KEY([PictureId]) REFERENCES [dbo].[Picture] ([Id])
149141
END
150142
GO
151-
152-
IF NOT EXISTS (SELECT * FROM sys.objects WHERE name = 'FK_dbo.Product_dbo.Download_SampleDownloadId' AND type = 'F')
153-
BEGIN
154-
ALTER TABLE [Product] WITH CHECK ADD CONSTRAINT [FK_dbo.Product_dbo.Download_SampleDownloadId] FOREIGN KEY ([SampleDownloadId]) REFERENCES [Download] ([Id])
155-
END
156-
GO

src/Presentation/SmartStore.Web/App_Data/Migrations/1.2.1-1.3.0/4-migrate-improved-product-structure-core.sql

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1738,9 +1738,21 @@ ALTER TABLE [Product]
17381738
ALTER COLUMN [HasSampleDownload] bit NOT NULL
17391739
GO
17401740

1741-
ALTER TABLE [Product]
1742-
ALTER COLUMN [SampleDownloadId] int NOT NULL
1741+
Update [Product] SET SampleDownloadId = null WHERE SampleDownloadId = 0
1742+
GO
1743+
IF NOT EXISTS (SELECT 1 FROM sys.indexes WHERE object_id=OBJECT_ID('[Product]') and NAME='IX_SampleDownloadId')
1744+
BEGIN
1745+
CREATE INDEX [IX_SampleDownloadId] ON [Product]([SampleDownloadId])
1746+
END
1747+
GO
1748+
IF NOT EXISTS (SELECT * FROM sys.objects WHERE name = 'FK_dbo.Product_dbo.Download_SampleDownloadId' AND type = 'F')
1749+
BEGIN
1750+
ALTER TABLE [Product] WITH CHECK ADD CONSTRAINT [FK_dbo.Product_dbo.Download_SampleDownloadId] FOREIGN KEY ([SampleDownloadId]) REFERENCES [Download] ([Id])
1751+
END
17431752
GO
1753+
--ALTER TABLE [Product]
1754+
--ALTER COLUMN [SampleDownloadId] int NOT NULL
1755+
--GO
17441756

17451757
ALTER TABLE [Product]
17461758
ALTER COLUMN [HasUserAgreement] bit NOT NULL

0 commit comments

Comments
 (0)