Skip to content

Commit c26ff41

Browse files
committed
Add metadata to stored procedures for 3rd party libs
This way a third party can parse the meta data and knows how to handle the bodies of a stored procedure
1 parent 103e832 commit c26ff41

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

ebean-ddl-generator/src/main/resources/io/ebeaninternal/dbmigration/builtin-extra-ddl.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ AS SET NOCOUNT ON
2828
declare @sql nvarchar(1000)
2929
declare @indexName nvarchar(255)
3030
BEGIN
31+
-- !Play-Evolutions: KEEP SEMICOLONS START
3132
DECLARE index_cursor CURSOR FOR SELECT i.name from sys.indexes i
3233
join sys.index_columns ic on ic.object_id = i.object_id and ic.index_id = i.index_id
3334
join sys.columns c on c.object_id = ic.object_id and c.column_id = ic.column_id
@@ -43,6 +44,7 @@ BEGIN
4344
END;
4445
CLOSE index_cursor;
4546
DEALLOCATE index_cursor;
47+
-- !Play-Evolutions: KEEP SEMICOLONS END
4648
END
4749
GO
4850

@@ -54,11 +56,13 @@ CREATE OR ALTER PROCEDURE usp_ebean_drop_default_constraint @tableName nvarchar(
5456
AS SET NOCOUNT ON
5557
declare @tmp nvarchar(1000)
5658
BEGIN
59+
-- !Play-Evolutions: KEEP SEMICOLONS START
5760
select @tmp = t1.name from sys.default_constraints t1
5861
join sys.columns t2 on t1.object_id = t2.default_object_id
5962
where t1.parent_object_id = OBJECT_ID(@tableName) and t2.name = @columnName;
6063

6164
if @tmp is not null EXEC('alter table [' + @tableName +'] drop constraint ' + @tmp);
65+
-- !Play-Evolutions: KEEP SEMICOLONS END
6266
END
6367
GO
6468

@@ -71,6 +75,7 @@ AS SET NOCOUNT ON
7175
declare @sql nvarchar(1000)
7276
declare @constraintName nvarchar(255)
7377
BEGIN
78+
-- !Play-Evolutions: KEEP SEMICOLONS START
7479
DECLARE name_cursor CURSOR FOR
7580
SELECT cc.name from sys.check_constraints cc
7681
join sys.columns c on c.object_id = cc.parent_object_id and c.column_id = cc.parent_column_id
@@ -92,6 +97,7 @@ BEGIN
9297
END;
9398
CLOSE name_cursor;
9499
DEALLOCATE name_cursor;
100+
-- !Play-Evolutions: KEEP SEMICOLONS END
95101
END
96102
GO
97103

@@ -103,12 +109,14 @@ CREATE OR ALTER PROCEDURE usp_ebean_drop_column @tableName nvarchar(255), @colum
103109
AS SET NOCOUNT ON
104110
declare @sql nvarchar(1000)
105111
BEGIN
112+
-- !Play-Evolutions: KEEP SEMICOLONS START
106113
EXEC usp_ebean_drop_indices @tableName, @columnName;
107114
EXEC usp_ebean_drop_default_constraint @tableName, @columnName;
108115
EXEC usp_ebean_drop_constraints @tableName, @columnName;
109116

110117
set @sql = 'alter table [' + @tableName + '] drop column [' + @columnName + ']';
111118
EXECUTE(@sql);
119+
-- !Play-Evolutions: KEEP SEMICOLONS END
112120
END
113121
GO
114122
</ddl-script>
@@ -122,6 +130,7 @@ delimiter $$
122130
--
123131
CREATE PROCEDURE usp_ebean_drop_foreign_keys(IN p_table_name VARCHAR(255), IN p_column_name VARCHAR(255))
124132
BEGIN
133+
-- !Play-Evolutions: KEEP SEMICOLONS START
125134
DECLARE done INT DEFAULT FALSE;
126135
DECLARE c_fk_name CHAR(255);
127136
DECLARE curs CURSOR FOR SELECT CONSTRAINT_NAME from information_schema.KEY_COLUMN_USAGE
@@ -142,6 +151,7 @@ EXECUTE stmt;
142151
END LOOP;
143152

144153
CLOSE curs;
154+
-- !Play-Evolutions: KEEP SEMICOLONS END
145155
END
146156
$$
147157

@@ -154,10 +164,12 @@ delimiter $$
154164
--
155165
CREATE PROCEDURE usp_ebean_drop_column(IN p_table_name VARCHAR(255), IN p_column_name VARCHAR(255))
156166
BEGIN
167+
-- !Play-Evolutions: KEEP SEMICOLONS START
157168
CALL usp_ebean_drop_foreign_keys(p_table_name, p_column_name);
158169
SET @sql = CONCAT('ALTER TABLE `', p_table_name, '` DROP COLUMN `', p_column_name, '`');
159170
PREPARE stmt FROM @sql;
160171
EXECUTE stmt;
172+
-- !Play-Evolutions: KEEP SEMICOLONS END
161173
END
162174
$$
163175
</ddl-script>
@@ -171,6 +183,7 @@ delimiter $$
171183
CREATE OR REPLACE PROCEDURE usp_ebean_drop_foreign_keys(IN table_name NVARCHAR(256), IN column_name NVARCHAR(256))
172184
AS
173185
BEGIN
186+
-- !Play-Evolutions: KEEP SEMICOLONS START
174187
DECLARE foreign_key_names TABLE(CONSTRAINT_NAME NVARCHAR(256), TABLE_NAME NVARCHAR(256));
175188
DECLARE i INT;
176189

@@ -180,6 +193,7 @@ FOR I IN 1 .. RECORD_COUNT(:foreign_key_names) DO
180193
EXEC 'ALTER TABLE "' || ESCAPE_DOUBLE_QUOTES(:foreign_key_names.TABLE_NAME[i]) || '" DROP CONSTRAINT "' || ESCAPE_DOUBLE_QUOTES(:foreign_key_names.CONSTRAINT_NAME[i]) || '"';
181194
END FOR;
182195

196+
-- !Play-Evolutions: KEEP SEMICOLONS END
183197
END;
184198
$$
185199

@@ -191,8 +205,10 @@ delimiter $$
191205
CREATE OR REPLACE PROCEDURE usp_ebean_drop_column(IN table_name NVARCHAR(256), IN column_name NVARCHAR(256))
192206
AS
193207
BEGIN
208+
-- !Play-Evolutions: KEEP SEMICOLONS START
194209
CALL usp_ebean_drop_foreign_keys(table_name, column_name);
195210
EXEC 'ALTER TABLE "' || UPPER(ESCAPE_DOUBLE_QUOTES(table_name)) || '" DROP ("' || UPPER(ESCAPE_DOUBLE_QUOTES(column_name)) || '")';
211+
-- !Play-Evolutions: KEEP SEMICOLONS END
196212
END;
197213
$$
198214
</ddl-script>

0 commit comments

Comments
 (0)