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

Ajout d'un champ Membership.created_at #605

Merged
merged 1 commit into from
Nov 13, 2022

Conversation

raphodn
Copy link
Member

@raphodn raphodn commented Nov 8, 2022

Suite de #566

Ce champ sera rempli à chaque création d'un nouveau membre.

Comment remplir ce champ pour les membres existants

les commandes suivantes sont à effectuer en SQL, directement sur votre base de données.

sortir d'abord quelques stats sur le nombre de membres concernés

SELECT COUNT(*) from membership;
SELECT COUNT(*) from membership where created_at = '0000-00-00 00:00:00';

solution 1 : les membres qui ont une date d'adhésion et une date de premier créneau

UPDATE membership m LEFT JOIN (SELECT r.membership_id, min(r.created_at) as min_registration FROM registration r GROUP BY r.membership_id) as min_r ON m.id = min_r.membership_id SET m.created_at = LEAST(min_r.min_registration, m.first_shift_date) WHERE (m.created_at = '0000-00-00 00:00:00' AND min_r.min_registration is not null AND m.first_shift_date is not null);

solution 2 : pour les membres restants (sans date d'adhésion, ou sans date de premier créneau)

UPDATE membership m LEFT JOIN (SELECT r.membership_id, min(r.created_at) as min_registration FROM registration r GROUP BY r.membership_id) as min_r ON m.id = min_r.membership_id SET m.created_at = min_r.min_registration WHERE (m.created_at = '0000-00-00 00:00:00' AND min_r.min_registration is not null AND m.first_shift_date is null);

UPDATE membership m LEFT JOIN (SELECT r.membership_id, min(r.created_at) as min_registration FROM registration r GROUP BY r.membership_id) as min_r ON m.id = min_r.membership_id SET m.created_at = m.first_shift_date WHERE (m.created_at = '0000-00-00 00:00:00' AND min_r.min_registration is null AND m.first_shift_date is not null);

@raphodn raphodn self-assigned this Nov 8, 2022
@raphodn raphodn requested a review from petitalb November 8, 2022 13:27
@raphodn raphodn linked an issue Nov 10, 2022 that may be closed by this pull request
@raphodn raphodn force-pushed the raphodn/membership-created-at branch from 4d5cbb8 to c642f3b Compare November 13, 2022 11:47
@raphodn raphodn merged commit 6876a73 into master Nov 13, 2022
@raphodn raphodn deleted the raphodn/membership-created-at branch November 13, 2022 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Généraliser l'utilisation du champ createdAt
2 participants