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

Evolution fails for auto-generated script contains create procedures script #10

Open
almothafar opened this issue Jan 14, 2019 · 14 comments
Labels

Comments

@almothafar
Copy link

The issue confusing but seems play's version not going to fix this issue soon, this is because a new feature added in ebean version 11.19.1 releases of it is here: https://github.com/ebean-orm/ebean/releases/tag/ebean-11.19.1

Full details and discussion with play team done in 2 tickets:
playframework#166
And
playframework/playframework#8879

Also, you may try to use this branch to reproduce: https://github.com/almothafar/play-with-mapstruct/tree/play-2.6.x-payintech

@stogo
Copy link

stogo commented Jun 9, 2019

I have the same issue. I'm using this as a workaround.
Same instructions than playframework/playframework#8879 but remove custom delimiter parts and replace all ; with ;; inside procedure definition and add ; after END

Easier to just replace procedure parts in the generated sql file with this.

-- init script create procs
-- Inital script to create stored procedures etc for mysql platform
DROP PROCEDURE IF EXISTS usp_ebean_drop_foreign_keys;

--
-- PROCEDURE: usp_ebean_drop_foreign_keys TABLE, COLUMN
-- deletes all constraints and foreign keys referring to TABLE.COLUMN
--
CREATE PROCEDURE usp_ebean_drop_foreign_keys(IN p_table_name VARCHAR(255), IN p_column_name VARCHAR(255))
BEGIN
    DECLARE done INT DEFAULT FALSE;;
    DECLARE c_fk_name CHAR(255);;
    DECLARE curs CURSOR FOR SELECT CONSTRAINT_NAME from information_schema.KEY_COLUMN_USAGE
                            WHERE TABLE_SCHEMA = DATABASE() and TABLE_NAME = p_table_name and COLUMN_NAME = p_column_name
                              AND REFERENCED_TABLE_NAME IS NOT NULL;;
    DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;;

    OPEN curs;;

    read_loop: LOOP
        FETCH curs INTO c_fk_name;;
        IF done THEN
            LEAVE read_loop;;
        END IF;;
        SET @sql = CONCAT('ALTER TABLE ', p_table_name, ' DROP FOREIGN KEY ', c_fk_name);;
        PREPARE stmt FROM @sql;;
        EXECUTE stmt;;
    END LOOP;;

    CLOSE curs;;
END;

DROP PROCEDURE IF EXISTS usp_ebean_drop_column;

--
-- PROCEDURE: usp_ebean_drop_column TABLE, COLUMN
-- deletes the column and ensures that all indices and constraints are dropped first
--
CREATE PROCEDURE usp_ebean_drop_column(IN p_table_name VARCHAR(255), IN p_column_name VARCHAR(255))
BEGIN
    CALL usp_ebean_drop_foreign_keys(p_table_name, p_column_name);;
    SET @sql = CONCAT('ALTER TABLE ', p_table_name, ' DROP COLUMN ', p_column_name);;
    PREPARE stmt FROM @sql;;
    EXECUTE stmt;;
END;

@almothafar
Copy link
Author

@stogo yes I'm using the same workaround but the problem is when you use auto generate (especially when you start a new project and you don't have a final form yet) and you keep auto-generate, it becomes annoying.

@cyrilfr
Copy link

cyrilfr commented Aug 21, 2019

Any chance to be fixed?

@allnash
Copy link

allnash commented Sep 11, 2019

Same here. Frustrating!

My work around was to downgrade to 18.10. I am on play 2.6.20

@cyrilfr
Copy link

cyrilfr commented Sep 12, 2019

It will be fixed by ebean: ebean-orm/ebean#1802

@almothafar
Copy link
Author

@cyrilfr will be fixed for MySQL what about the rest of DBMSs?

@cyrilfr
Copy link

cyrilfr commented Sep 12, 2019

@almothafar this is another issue. Here the problem is the DDL procedures that are not part of SQL language. You'll be able to disable this.

@allnash
Copy link

allnash commented May 23, 2020

@almothafar When is the fix for this getting merged?
@cyrilfr

@allnash
Copy link

allnash commented May 23, 2020

@almothafar actually this is fixed in ->

addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "6.0.0")
Play 2.8.2

@mkurz
Copy link

mkurz commented May 23, 2020

Actually this is fixed because of ebean version 11.45.1. Starting with that ebean version no stored procedure will be generated automatically anymore by default: ebean-orm/ebean#1802 and ebean-orm/ebean#1815

@almothafar
Copy link
Author

@mkurz That's only for MySQL, for MSSQL here it is still doing it

@RafalSladek
Copy link

do we have any news with this bug?

i have same issue with evolution being not able to create store procedure (using play 2.9) and no ebean

@mkurz
Copy link

mkurz commented May 21, 2024

i have same issue with evolution being not able to create store procedure (using play 2.9) and no ebean

what do you mean with "...no ebean"? You can create stored procedures with Play evolution's, you just have to escape ; with ;; within prodecure body's, see https://www.playframework.com/documentation/latest/Evolutions#Evolutions-scripts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants