Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flyway clean doesn't remove partition schemes and functions #2447

Closed
AigleeK opened this issue Jul 25, 2019 · 1 comment

Comments

@AigleeK
Copy link

commented Jul 25, 2019

Which version and edition of Flyway are you using?

Flyway 5 and Flyway 6 Beta

If this is not the latest version, can you reproduce the issue with the latest one as well?

(Many bugs are fixed in newer releases and upgrading will often resolve the issue)
Yes

Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin)

Command-line

Which database are you using (type & version)?

SQL Server 2017

Which operating system are you using?

Windows 10

What did you do?

(Please include the content causing the issue, any relevant configuration settings, the SQL statement that failed (if relevant) and the command you ran.)
I partitioned a table in the DB and ran flyway clean so I could recreate my DB and recreate the partition

What did you expect to see?

Partition scheme and partition functions should not exist anymore in the DB

What did you see instead?

Partition scheme and partition functions were still in the DB. As a workaround I added the following code to afterClean.sql callback to remove them:

CREATE TABLE #Commands (Command VARCHAR(MAX));

INSERT #Commands
SELECT 
	'DROP PARTITION SCHEME ' + QUOTENAME(name) + '; '
FROM 
	sys.partition_schemes;

INSERT #Commands
SELECT 
	'DROP PARTITION FUNCTION ' + QUOTENAME(name) + '; '
FROM 
	sys.partition_functions;

DECLARE @Command VARCHAR(MAX);

DECLARE curCommand CURSOR FOR SELECT Command FROM #Commands;
OPEN curCommand;

FETCH NEXT FROM curCommand INTO @Command;

WHILE @@FETCH_STATUS =0
BEGIN
    EXEC(@Command);
    FETCH NEXT FROM curCommand INTO @Command;
END;

CLOSE curCommand;
DEALLOCATE curCommand;

DROP TABLE #Commands;

@juliahayward juliahayward added the t: bug label Jul 25, 2019

juliahayward added a commit to flyway/flywaydb.org that referenced this issue Jul 30, 2019

@juliahayward juliahayward added this to the Flyway 6.0.0 milestone Jul 30, 2019

@juliahayward

This comment has been minimized.

Copy link
Member

commented Jul 30, 2019

Many thanks for the report - we have done a fix so with v6.0 you will not need this workround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.