Skip to content

Commit e767d8d

Browse files
committed
Added T4SQL.META_CREATE_WORKSPACE
1 parent 24227b2 commit e767d8d

File tree

8 files changed

+101
-93
lines changed

8 files changed

+101
-93
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
CREATE PROCEDURE T4SQL.META_CREATE_WORKSPACE
2+
(
3+
@inWorkitem_Table NVARCHAR(128),
4+
@inProperty_Table NVARCHAR(128),
5+
@inWorkspace_Description NVARCHAR(128),
6+
@inAutonomous_Owner NVARCHAR(64)
7+
)
8+
AS
9+
SET NOCOUNT ON;
10+
11+
SET @inWorkitem_Table = LTRIM(RTRIM(@inWorkitem_Table));
12+
SET @inProperty_Table = LTRIM(RTRIM(@inProperty_Table));
13+
14+
IF OBJECT_ID(@inWorkitem_Table) IS NOT NULL OR OBJECT_ID(@inProperty_Table) IS NOT NULL
15+
BEGIN
16+
RAISERROR (N'%s, %s already exists in the database.', 16, 1, @inWorkitem_Table, @inProperty_Table);
17+
RETURN;
18+
END;
19+
20+
DECLARE @tTab NVARCHAR(64), @tDdlSql NVARCHAR(1024);
21+
22+
SET @tTab = PARSENAME(@inWorkitem_Table, 1);
23+
SET @tDdlSql = N'CREATE TABLE ' + @inWorkitem_Table + N'
24+
(
25+
WORKITEM_NAME NVARCHAR(32) NOT NULL,
26+
TEMPLATE_NAME VARCHAR(128) NOT NULL,
27+
WORKITEM_DESCRIPTION NVARCHAR(256) NOT NULL,
28+
WORKITEM_USER NVARCHAR(32),
29+
MODIFIED_TIME DATETIME NOT NULL DEFAULT GETDATE(),
30+
COMPILED_TIME DATETIME,
31+
COMPILED_ERROR NVARCHAR(2000),
32+
OBJECT_CODE NVARCHAR(MAX),
33+
BUILD_ORDER INT,
34+
START_BUILD BIT NOT NULL DEFAULT 0,
35+
36+
CONSTRAINT PK_' + @tTab + N' PRIMARY KEY (WORKITEM_NAME),
37+
CONSTRAINT FK_' + @tTab + N'_TEMPLATE FOREIGN KEY (TEMPLATE_NAME)
38+
REFERENCES T4SQL.TEMPLATE_CLASS(FULL_NAME)
39+
ON UPDATE CASCADE
40+
ON DELETE CASCADE
41+
);';
42+
43+
EXECUTE (@tDdlSql);
44+
45+
SET @tTab = PARSENAME(@inProperty_Table, 1);
46+
SET @tDdlSql = N'CREATE TABLE ' + @inProperty_Table + N'
47+
(
48+
WORKITEM_NAME NVARCHAR(32) NOT NULL,
49+
PROPERTY_NAME NVARCHAR(64) NOT NULL,
50+
STRING_VALUE NVARCHAR(4000) NOT NULL,
51+
LINK_STATE NVARCHAR(256),
52+
53+
CONSTRAINT PK_' + @tTab + N' PRIMARY KEY (WORKITEM_NAME, PROPERTY_NAME),
54+
CONSTRAINT FK_' + @tTab + N'_WORKITEM FOREIGN KEY (WORKITEM_NAME)
55+
REFERENCES ' + @inWorkitem_Table + N'(WORKITEM_NAME)
56+
ON UPDATE CASCADE
57+
ON DELETE CASCADE
58+
);';
59+
60+
EXECUTE (@tDdlSql);
61+
62+
INSERT INTO T4SQL.WORKSPACE_ENTRY
63+
(
64+
WORKITEM_TABLE_NAME,
65+
PROPERTY_TABLE_NAME,
66+
WORKSPACE_DESCRIPTION,
67+
AUTONOMOUS_OWNER
68+
)
69+
VALUES
70+
(
71+
@inWorkitem_Table,
72+
@inProperty_Table,
73+
@inWorkspace_Description,
74+
@inAutonomous_Owner
75+
);
76+
77+
----------------------------------------------------------------------------------------------------
78+
--
79+
-- Copyright 2013 Abel Cheng
80+
-- This source code is subject to terms and conditions of the Apache License, Version 2.0.
81+
-- See http://www.apache.org/licenses/LICENSE-2.0.
82+
-- All other rights reserved.
83+
-- You must not remove this notice, or any other, from this software.
84+
--
85+
-- Original Author: Abel Cheng <[email protected]>
86+
-- Created Date: ‎‎June ‎26, ‎2013, ‏‎11:30:13 PM
87+
-- Primary Host: http://t4sql.codeplex.com
88+
-- Change Log:
89+
-- Author Date Comment
90+
--
91+
--
92+
--
93+
--
94+
-- (Keep code clean)
95+
--
96+
----------------------------------------------------------------------------------------------------

T4SQLTemplateLibrary/Databases/SqlServer/T4SQLDB.sqlproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@
305305
</Build>
306306
<Build Include="Schema Objects\Schemas\T4SQL\Programmability\Stored Procedures\T4SQL.CMD_BUILD_SCRIPTS.sql" />
307307
<Build Include="Schema Objects\Schemas\T4SQL\Programmability\Stored Procedures\T4SQL.CMD_PRINT_ALL_LINES.sql" />
308+
<Build Include="Schema Objects\Schemas\T4SQL\Programmability\Stored Procedures\T4SQL.META_CREATE_WORKSPACE.sql" />
308309
</ItemGroup>
309310
<ItemGroup>
310311
<None Include="Scripts\Post-Deployment\1-T4SQL.ENGINE_CONFIG.data.sql">
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
IF OBJECT_ID(N'test.sample_workspace') IS NULL AND OBJECT_ID(N'test.sample_properties') IS NULL
2+
EXECUTE T4SQL.META_CREATE_WORKSPACE @inWorkitem_Table = N'test.sample_workspace', @inProperty_Table = N'test.sample_properties', @inWorkspace_Description = N'Sample Workspace', @inAutonomous_Owner = N'test';

T4SQLTemplateLibrary/Databases/SqlServer/Test/InitData/RegisterSampleWorkspace.sql

Lines changed: 0 additions & 15 deletions
This file was deleted.

T4SQLTemplateLibrary/Databases/SqlServer/Test/InitData/Script.PostDeployment.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ Post-Deployment Script Template
1010
--------------------------------------------------------------------------------------
1111
*/
1212

13-
:r .\RegisterSampleWorkspace.sql
13+
:r .\1-CreateSampleWorkspace.sql

T4SQLTemplateLibrary/Databases/SqlServer/Test/Tables/test.sample_properties.sql

Lines changed: 0 additions & 34 deletions
This file was deleted.

T4SQLTemplateLibrary/Databases/SqlServer/Test/Tables/test.sample_workspace.sql

Lines changed: 0 additions & 40 deletions
This file was deleted.

T4SQLTemplateLibrary/Databases/SqlServer/Test/Test (SQL Server).sqlproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@
8080
</ItemGroup>
8181
<ItemGroup>
8282
<Build Include="test.schema.sql" />
83-
<Build Include="Tables\test.sample_properties.sql" />
84-
<Build Include="Tables\test.sample_workspace.sql" />
8583
</ItemGroup>
8684
<ItemGroup>
8785
<ArtifactReference Include="$(DacPacRootPath)\Extensions\Microsoft\SQLDB\Extensions\SqlServer\100\SqlSchemas\master.dacpac">
@@ -94,6 +92,6 @@
9492
<PostDeploy Include="InitData\Script.PostDeployment.sql" />
9593
</ItemGroup>
9694
<ItemGroup>
97-
<None Include="InitData\RegisterSampleWorkspace.sql" />
95+
<None Include="InitData\1-CreateSampleWorkspace.sql" />
9896
</ItemGroup>
9997
</Project>

0 commit comments

Comments
 (0)