Aggiungere stato Utente "Dimesso"

Ci sarebbe da aggiungere un nuovo stato per le utenze che decidono di dimettersi volontariamente, ancor prima della scadenza della propria quota associativa.

Quindi NON è stato Sospeso (quota scaduta).

Quindi NON è stato Espulso (cosa che capita quando il socio esce involontariamente).

Parliamo di un nuovo stato "Dimesso".

Situazione attuale

Al momento abbiamo questi stati utente:

  • In Attesa di Approvazione Assemblea
  • Attivo
  • Sospeso
  • Espulso
  • Scaduto
  • Limitato

Lato database c'è questa colonna:

$ SHOW CREATE TABLE users;

...

  `status` enum('pending','active','suspended','expelled','dropped','limited') NOT NULL DEFAULT 'pending',

...

Definizione completa:

CREATE TABLE `users` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `remember_token` varchar(100) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `username` varchar(191) NOT NULL,
  `password` varchar(191) NOT NULL,
  `status` enum('pending','active','suspended','expelled','dropped','limited') NOT NULL DEFAULT 'pending',
  `type` enum('regular','association','guest') NOT NULL,
  `legal_entity_id` bigint(20) unsigned DEFAULT NULL,
  `name` varchar(191) DEFAULT NULL,
  `surname` varchar(191) DEFAULT NULL,
  `email` varchar(191) NOT NULL,
  `email_alias` varchar(191) DEFAULT NULL,
  `website` varchar(191) DEFAULT NULL,
  `taxcode` varchar(191) DEFAULT NULL,
  `notes` text NOT NULL,
  `birth_place` varchar(191) DEFAULT NULL,
  `birth_prov` varchar(191) DEFAULT NULL,
  `birth_date` date DEFAULT NULL,
  `address_street` varchar(191) DEFAULT NULL,
  `address_place` varchar(191) DEFAULT NULL,
  `address_prov` varchar(191) DEFAULT NULL,
  `request_at` date DEFAULT NULL,
  `approved_at` date DEFAULT NULL,
  `expelled_at` date DEFAULT NULL,
  `section_id` int(10) unsigned DEFAULT NULL,
  `volunteer` tinyint(1) NOT NULL DEFAULT 0,
  `phone` varchar(191) DEFAULT NULL,
  `address_zip` varchar(191) DEFAULT NULL,
  `shipping_name` varchar(191) DEFAULT NULL,
  `shipping_street` varchar(191) DEFAULT NULL,
  `shipping_place` varchar(191) DEFAULT NULL,
  `shipping_zip` varchar(191) DEFAULT NULL,
  `shipping_prov` varchar(191) DEFAULT NULL,
  `size` varchar(191) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `users_username_unique` (`username`),
  UNIQUE KEY `users_email_alias_unique` (`email_alias`),
  KEY `users_section_id_foreign` (`section_id`),
  KEY `users_legal_entity_id_foreign` (`legal_entity_id`),
  KEY `users_status_surname_name_index` (`status`,`surname`,`name`),
  CONSTRAINT `users_legal_entity_id_foreign` FOREIGN KEY (`legal_entity_id`) REFERENCES `legal_entities` (`id`),
  CONSTRAINT `users_section_id_foreign` FOREIGN KEY (`section_id`) REFERENCES `sections` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=111 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci

Proposta 1 - nuovo valore ENUM

Ci sarebbe da aggiungere un nuovo stato "Dimesso" (resigned ? ).

Quindi con script creazione database.

https://gitlab.com/ItalianLinuxSociety/ilsmanager/#database---avanzamento-migrazione

Proposta 2 - refactor entità esterna ()

Verrebbe anche voglia di creare un'entità esterna.

Questo approccio è probabilmente da escludere perché troppo facile introdurre regressioni. Magari in futuro (cit).

Controllo qualità

  • gli indici rimangono così come sono (specialmente users_status_surname_name_index)
  • lo script di migrazione non esplode lanciandolo 2 volte:
docker compose run web php artisan migrate
docker compose run web php artisan migrate:rollback --step=1
docker compose run web php artisan migrate
docker compose run web php artisan migrate:rollback --step=1
Edited by Valerio Bozzolan