Skip to content

Commit

Permalink
remove default empty project if unused
Browse files Browse the repository at this point in the history
  • Loading branch information
syjer committed Aug 4, 2015
1 parent bd23f44 commit a46e854
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/io/lavagna/config/DataSourceConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

public class DataSourceConfig {

public static final MigrationVersion LATEST_STABLE_VERSION = MigrationVersion.fromVersion("7");
public static final MigrationVersion LATEST_STABLE_VERSION = MigrationVersion.fromVersion("8");

@Bean(destroyMethod = "close")
public DataSource getDataSource(Environment env) throws URISyntaxException {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
--
-- This file is part of lavagna.
--
-- lavagna is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- lavagna is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with lavagna. If not, see <http://www.gnu.org/licenses/>.
--

DELETE FROM LA_BOARD_COLUMN_DEFINITION WHERE
BOARD_COLUMN_DEFINITION_PROJECT_ID_FK = (SELECT PROJECT_ID FROM LA_PROJECT WHERE PROJECT_SHORT_NAME = 'DEFAULT') AND
(SELECT COUNT(*) FROM LA_BOARD INNER JOIN LA_PROJECT ON BOARD_PROJECT_ID_FK = PROJECT_ID WHERE PROJECT_SHORT_NAME = 'DEFAULT') = 0;

DELETE FROM LA_CARD_LABEL_LIST_VALUE WHERE CARD_LABEL_LIST_VALUE_ID IN (SELECT CARD_LABEL_LIST_VALUE_ID FROM LA_CARD_LABEL_LIST_VALUE INNER JOIN
LA_CARD_LABEL ON CARD_LABEL_ID_FK = CARD_LABEL_ID WHERE CARD_LABEL_PROJECT_ID_FK = (SELECT PROJECT_ID FROM LA_PROJECT WHERE PROJECT_SHORT_NAME = 'DEFAULT')) AND
(SELECT COUNT(*) FROM LA_BOARD INNER JOIN LA_PROJECT ON BOARD_PROJECT_ID_FK = PROJECT_ID WHERE PROJECT_SHORT_NAME = 'DEFAULT') = 0;

DELETE FROM LA_CARD_LABEL WHERE
CARD_LABEL_PROJECT_ID_FK = (SELECT PROJECT_ID FROM LA_PROJECT WHERE PROJECT_SHORT_NAME = 'DEFAULT') AND
(SELECT COUNT(*) FROM LA_BOARD INNER JOIN LA_PROJECT ON BOARD_PROJECT_ID_FK = PROJECT_ID WHERE PROJECT_SHORT_NAME = 'DEFAULT') = 0;

DELETE FROM LA_PROJECT_ROLE_PERMISSION WHERE
PROJECT_ROLE_ID_FK = (SELECT PROJECT_ID FROM LA_PROJECT WHERE PROJECT_SHORT_NAME = 'DEFAULT') AND
(SELECT COUNT(*) FROM LA_BOARD INNER JOIN LA_PROJECT ON BOARD_PROJECT_ID_FK = PROJECT_ID WHERE PROJECT_SHORT_NAME = 'DEFAULT') = 0;

DELETE FROM LA_PROJECT_ROLE WHERE
PROJECT_ID_FK = (SELECT PROJECT_ID FROM LA_PROJECT WHERE PROJECT_SHORT_NAME = 'DEFAULT') AND
(SELECT COUNT(*) FROM LA_BOARD INNER JOIN LA_PROJECT ON BOARD_PROJECT_ID_FK = PROJECT_ID WHERE PROJECT_SHORT_NAME = 'DEFAULT') = 0;

DELETE FROM LA_PROJECT WHERE
(PROJECT_SHORT_NAME = 'DEFAULT') AND
(SELECT COUNT(*) FROM LA_BOARD INNER JOIN LA_PROJECT ON BOARD_PROJECT_ID_FK = PROJECT_ID WHERE PROJECT_SHORT_NAME = 'DEFAULT') = 0;
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
--
-- This file is part of lavagna.
--
-- lavagna is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- lavagna is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with lavagna. If not, see <http://www.gnu.org/licenses/>.
--

DELETE FROM LA_BOARD_COLUMN_DEFINITION WHERE
BOARD_COLUMN_DEFINITION_PROJECT_ID_FK = (SELECT PROJECT_ID FROM LA_PROJECT WHERE PROJECT_SHORT_NAME = 'DEFAULT') AND
(SELECT COUNT(*) FROM LA_BOARD INNER JOIN LA_PROJECT ON BOARD_PROJECT_ID_FK = PROJECT_ID WHERE PROJECT_SHORT_NAME = 'DEFAULT') = 0;

DELETE FROM LA_CARD_LABEL_LIST_VALUE WHERE CARD_LABEL_LIST_VALUE_ID IN (SELECT * FROM (SELECT CARD_LABEL_LIST_VALUE_ID FROM LA_CARD_LABEL_LIST_VALUE INNER JOIN
LA_CARD_LABEL ON CARD_LABEL_ID_FK = CARD_LABEL_ID WHERE CARD_LABEL_PROJECT_ID_FK = (SELECT PROJECT_ID FROM LA_PROJECT WHERE PROJECT_SHORT_NAME = 'DEFAULT')) A) AND
(SELECT COUNT(PROJECT_ID) FROM LA_BOARD INNER JOIN LA_PROJECT ON BOARD_PROJECT_ID_FK = PROJECT_ID WHERE PROJECT_SHORT_NAME = 'DEFAULT') = 0;

DELETE FROM LA_CARD_LABEL WHERE
CARD_LABEL_PROJECT_ID_FK = (SELECT PROJECT_ID FROM LA_PROJECT WHERE PROJECT_SHORT_NAME = 'DEFAULT') AND
(SELECT COUNT(*) FROM LA_BOARD INNER JOIN LA_PROJECT ON BOARD_PROJECT_ID_FK = PROJECT_ID WHERE PROJECT_SHORT_NAME = 'DEFAULT') = 0;

DELETE FROM LA_PROJECT_ROLE_PERMISSION WHERE
PROJECT_ROLE_ID_FK = (SELECT PROJECT_ID FROM LA_PROJECT WHERE PROJECT_SHORT_NAME = 'DEFAULT') AND
(SELECT COUNT(*) FROM LA_BOARD INNER JOIN LA_PROJECT ON BOARD_PROJECT_ID_FK = PROJECT_ID WHERE PROJECT_SHORT_NAME = 'DEFAULT') = 0;

DELETE FROM LA_PROJECT_ROLE WHERE
PROJECT_ID_FK = (SELECT PROJECT_ID FROM LA_PROJECT WHERE PROJECT_SHORT_NAME = 'DEFAULT') AND
(SELECT COUNT(*) FROM LA_BOARD INNER JOIN LA_PROJECT ON BOARD_PROJECT_ID_FK = PROJECT_ID WHERE PROJECT_SHORT_NAME = 'DEFAULT') = 0;

DELETE FROM LA_PROJECT WHERE
(PROJECT_SHORT_NAME = 'DEFAULT') AND
(SELECT * FROM ((SELECT COUNT(*) FROM LA_BOARD INNER JOIN LA_PROJECT ON BOARD_PROJECT_ID_FK = PROJECT_ID WHERE PROJECT_SHORT_NAME = 'DEFAULT')) A) = 0;
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
--
-- This file is part of lavagna.
--
-- lavagna is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- lavagna is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with lavagna. If not, see <http://www.gnu.org/licenses/>.
--

DELETE FROM LA_BOARD_COLUMN_DEFINITION WHERE
BOARD_COLUMN_DEFINITION_PROJECT_ID_FK = (SELECT PROJECT_ID FROM LA_PROJECT WHERE PROJECT_SHORT_NAME = 'DEFAULT') AND
(SELECT COUNT(*) FROM LA_BOARD INNER JOIN LA_PROJECT ON BOARD_PROJECT_ID_FK = PROJECT_ID WHERE PROJECT_SHORT_NAME = 'DEFAULT') = 0;

DELETE FROM LA_CARD_LABEL_LIST_VALUE WHERE CARD_LABEL_LIST_VALUE_ID IN (SELECT CARD_LABEL_LIST_VALUE_ID FROM LA_CARD_LABEL_LIST_VALUE INNER JOIN
LA_CARD_LABEL ON CARD_LABEL_ID_FK = CARD_LABEL_ID WHERE CARD_LABEL_PROJECT_ID_FK = (SELECT PROJECT_ID FROM LA_PROJECT WHERE PROJECT_SHORT_NAME = 'DEFAULT')) AND
(SELECT COUNT(*) FROM LA_BOARD INNER JOIN LA_PROJECT ON BOARD_PROJECT_ID_FK = PROJECT_ID WHERE PROJECT_SHORT_NAME = 'DEFAULT') = 0;

DELETE FROM LA_CARD_LABEL WHERE
CARD_LABEL_PROJECT_ID_FK = (SELECT PROJECT_ID FROM LA_PROJECT WHERE PROJECT_SHORT_NAME = 'DEFAULT') AND
(SELECT COUNT(*) FROM LA_BOARD INNER JOIN LA_PROJECT ON BOARD_PROJECT_ID_FK = PROJECT_ID WHERE PROJECT_SHORT_NAME = 'DEFAULT') = 0;

DELETE FROM LA_PROJECT_ROLE_PERMISSION WHERE
PROJECT_ROLE_ID_FK = (SELECT PROJECT_ID FROM LA_PROJECT WHERE PROJECT_SHORT_NAME = 'DEFAULT') AND
(SELECT COUNT(*) FROM LA_BOARD INNER JOIN LA_PROJECT ON BOARD_PROJECT_ID_FK = PROJECT_ID WHERE PROJECT_SHORT_NAME = 'DEFAULT') = 0;

DELETE FROM LA_PROJECT_ROLE WHERE
PROJECT_ID_FK = (SELECT PROJECT_ID FROM LA_PROJECT WHERE PROJECT_SHORT_NAME = 'DEFAULT') AND
(SELECT COUNT(*) FROM LA_BOARD INNER JOIN LA_PROJECT ON BOARD_PROJECT_ID_FK = PROJECT_ID WHERE PROJECT_SHORT_NAME = 'DEFAULT') = 0;

DELETE FROM LA_PROJECT WHERE
(PROJECT_SHORT_NAME = 'DEFAULT') AND
(SELECT COUNT(*) FROM LA_BOARD INNER JOIN LA_PROJECT ON BOARD_PROJECT_ID_FK = PROJECT_ID WHERE PROJECT_SHORT_NAME = 'DEFAULT') = 0;

0 comments on commit a46e854

Please sign in to comment.