You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.
Which version and edition of Flyway are you using?
4.2.0
If this is not the latest version, can you reproduce the issue with the latest one as well?
could not test it, since 5.1.0 is not compatible with SQL Server 2012
Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin)
Maven plugin, Java API
Which database are you using (type & version)?
SQL Server 2012
Which operating system are you using?
Windows 10
What did you do?
SQL Migration:
IF NOT EXISTS (SELECT name FROMsys.schemasWHERE name = N'MySchema')
BEGIN
EXEC sp_executesql N'CREATE SCHEMA [MySchema]';
END
IF OBJECT_ID('[MySchema].[fn_SomeMyTableValue]') IS NULL-- Check if View Exists
EXEC('CREATE FUNCTION [MySchema].[fn_SomeMyTableValue] () RETURNS int WITH SCHEMABINDING AS BEGIN RETURN 1 END') -- Create dummy/empty SP
GO
CREATE TABLE [MySchema].[MyTable] (
[OrderId] [int] NOT NULL,
[MyDate] [date] NOT NULL
)
with the following repeatable
CREATE FUNCTION [MySchema].[fn_SomeMyTableValue]
(
@OrderId INT
)
RETURNS DATE
WITH SCHEMABINDING
ASBEGIN
RETURN (
SELECT MyDate
FROM [MySchema].[MyTable]
WHERE OrderId = @OrderId
)
END
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Cannot DROP TABLE 'MySchema.MyTable' because it is being referenced by object 'fn_SomeMyTableValue'.
Thanks for the report. I can confirm that Flyway clean does indeed not handle the case where a function depends on a table. The opposite works though.
This is the minimal migration required to demonstrate this:
CREATE TABLE [MyTable123] (
[OrderId] [int] NOT NULL,
[MyDate] [date] NOT NULL
)
GO
CREATE FUNCTION [fn_SomeMyTableValue]
(
@OrderId INT
)
RETURNS DATE
WITH SCHEMABINDING
ASBEGIN
RETURN (
SELECT MyDate
FROM [dbo].[MyTable123]
WHERE OrderId = @OrderId
)
END
axelfontaine
changed the title
Bug: Unable to clean schema that contains a user-defined function with schemabinding in SQL Server
Unable to clean schema that contains a user-defined function with schemabinding in SQL Server
Jun 5, 2018
Which version and edition of Flyway are you using?
4.2.0
If this is not the latest version, can you reproduce the issue with the latest one as well?
could not test it, since
5.1.0
is not compatible with SQL Server 2012Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin)
Maven plugin, Java API
Which database are you using (type & version)?
SQL Server 2012
Which operating system are you using?
Windows 10
What did you do?
SQL Migration:
with the following repeatable
What did you expect to see?
no error
What did you see instead?
Similar to #1193, we get a
after migrating the code and running
The text was updated successfully, but these errors were encountered: