-
Notifications
You must be signed in to change notification settings - Fork 2
Feature/schema alignment #32
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,5 +20,5 @@ | |
| acls: [ //Permissions needed | ||
| '/activities_.*/' => 'staff' | ||
| ], | ||
| dbver: 1.00 | ||
| dbver: 1.1 | ||
| ); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| -- | ||
| -- This file is part of Galette Activities plugin (https://galette.eu). | ||
| -- SPDX-FileCopyrightText: Copyright © 2024-2026 The Galette Team | ||
| -- SPDX-License-Identifier: GPL-3.0-or-later | ||
| -- | ||
|
|
||
| -- Align schema with PostgreSQL one: same foreign keys names and actions, | ||
| -- no default amount. Foreign keys names depend on the MySQL version that | ||
| -- created them, and MySQL cannot drop them conditionally: tables are rebuilt. | ||
| -- Foreign keys are added with checks enabled: without them, MariaDB records | ||
| -- ON DELETE RESTRICT as NO ACTION. | ||
| SET FOREIGN_KEY_CHECKS=0; | ||
|
|
||
| CREATE TABLE galette_activities_activities_new ( | ||
| id_activity int(10) NOT NULL auto_increment, | ||
| name varchar(150) NOT NULL, | ||
| type varchar(3) NOT NULL default '', | ||
| price decimal(15, 2) default NULL, | ||
| id_group int unsigned default NULL, | ||
| creation_date date NOT NULL, | ||
| comment text, | ||
| PRIMARY KEY (id_activity) | ||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci; | ||
|
|
||
| INSERT INTO galette_activities_activities_new (id_activity, name, type, price, id_group, creation_date, comment) | ||
| SELECT id_activity, name, type, price, id_group, creation_date, comment | ||
| FROM galette_activities_activities; | ||
|
|
||
| CREATE TABLE galette_activities_subscriptions_new ( | ||
| id_subscription int(10) NOT NULL auto_increment, | ||
| id_activity int(10) NOT NULL, | ||
| id_adh int(10) unsigned NOT NULL, | ||
| is_paid tinyint(1) NOT NULL default 0, | ||
| payment_amount decimal(15, 2) default NULL, | ||
| payment_method tinyint(3) unsigned NOT NULL default '0', | ||
| creation_date date NOT NULL, | ||
| subscription_date date NOT NULL, | ||
| end_date date NOT NULL, | ||
| comment text, | ||
| PRIMARY KEY (id_subscription), | ||
| CONSTRAINT galette_activities_subscriptions_id_activity_id_adh_key UNIQUE (id_activity, id_adh) | ||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci; | ||
|
|
||
| INSERT INTO galette_activities_subscriptions_new (id_subscription, id_activity, id_adh, is_paid, payment_amount, | ||
| payment_method, creation_date, subscription_date, end_date, comment) | ||
| SELECT id_subscription, id_activity, id_adh, is_paid, payment_amount, | ||
| payment_method, creation_date, subscription_date, end_date, comment | ||
| FROM galette_activities_subscriptions; | ||
|
|
||
| DROP TABLE galette_activities_subscriptions, galette_activities_activities; | ||
|
|
||
| RENAME TABLE galette_activities_activities_new TO galette_activities_activities, | ||
| galette_activities_subscriptions_new TO galette_activities_subscriptions; | ||
|
|
||
| SET FOREIGN_KEY_CHECKS=1; | ||
|
|
||
| ALTER TABLE galette_activities_activities | ||
| ADD CONSTRAINT galette_activities_activities_id_group_fkey FOREIGN KEY (id_group) | ||
| REFERENCES galette_groups (id_group) ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
|
||
| ALTER TABLE galette_activities_subscriptions | ||
| ADD CONSTRAINT galette_activities_subscriptions_id_activity_fkey FOREIGN KEY (id_activity) | ||
| REFERENCES galette_activities_activities (id_activity) ON DELETE CASCADE ON UPDATE CASCADE, | ||
| ADD CONSTRAINT galette_activities_subscriptions_id_adh_fkey FOREIGN KEY (id_adh) | ||
| REFERENCES galette_adherents (id_adh) ON DELETE CASCADE ON UPDATE CASCADE; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| -- | ||
| -- This file is part of Galette Activities plugin (https://galette.eu). | ||
| -- SPDX-FileCopyrightText: Copyright © 2024-2026 The Galette Team | ||
| -- SPDX-License-Identifier: GPL-3.0-or-later | ||
| -- | ||
|
|
||
| -- Align schema with MySQL one: subscriptions always have an activity, a member | ||
| -- and a payment status. | ||
| DELETE FROM galette_activities_subscriptions WHERE id_activity IS NULL OR id_adh IS NULL; | ||
| UPDATE galette_activities_subscriptions SET is_paid = FALSE WHERE is_paid IS NULL; | ||
|
|
||
| ALTER TABLE galette_activities_subscriptions | ||
| ALTER COLUMN id_activity SET NOT NULL, | ||
| ALTER COLUMN id_adh SET NOT NULL, | ||
| ALTER COLUMN is_paid SET NOT NULL; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.