Skip to content

Commit

Permalink
afup#1564 mariadb to mysql (afup#1565)
Browse files Browse the repository at this point in the history
* issue#1564 change database image

* issue#1564 fix fixtures

* issue#1564 fix tests

* issue#1564 sql schema

* issue#1564 lint compose.yml
  • Loading branch information
stakovicz authored Dec 6, 2024
1 parent 9acde78 commit 0d08d61
Show file tree
Hide file tree
Showing 26 changed files with 111 additions and 67 deletions.
10 changes: 4 additions & 6 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "2.2"

services:
db:
build: ./docker/dockerfiles/mysql
Expand All @@ -21,7 +19,7 @@ services:
volumes:
- ./data/mysqltest:/var/lib/mysql
healthcheck:
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
test: [ "CMD", "mysqladmin", "ping", "-h", "localhost" ]
timeout: 20s
retries: 10

Expand Down Expand Up @@ -58,7 +56,7 @@ services:
links:
- statictestresources
healthcheck:
test: ["CMD", "curl", "-f", "https://apachephptest:80"]
test: [ "CMD", "curl", "-f", "https://apachephptest:80" ]
interval: 30s
timeout: 10s
retries: 5
Expand All @@ -76,8 +74,8 @@ services:
.env
user: localUser
volumes:
- ./data/composer:/home/localUser/.composer
- ./:/var/www/html
- ./data/composer:/home/localUser/.composer
- ./:/var/www/html
links:
- db
- apachephp
Expand Down
10 changes: 5 additions & 5 deletions db/migrations/20180526091813_init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,8 @@ CREATE TABLE `afup_forum` (
`trello_list_id` varchar(100) CHARACTER SET utf8 DEFAULT NULL,
`logo_url` varchar(100) CHARACTER SET utf8 DEFAULT NULL,
`nb_places` int(11) unsigned NOT NULL DEFAULT '0',
`date_debut` date NOT NULL DEFAULT '0000-00-00',
`date_fin` date NOT NULL DEFAULT '0000-00-00',
`date_debut` date NULL,
`date_fin` date NULL,
`annee` int(11) DEFAULT NULL,
`text` text,
`date_fin_appel_projet` int(11) DEFAULT NULL,
Expand Down Expand Up @@ -935,7 +935,7 @@ DROP TABLE IF EXISTS `afup_sessions`;
CREATE TABLE `afup_sessions` (
`session_id` int(11) NOT NULL AUTO_INCREMENT,
`id_forum` smallint(6) NOT NULL DEFAULT '0',
`date_soumission` date NOT NULL DEFAULT '0000-00-00',
`date_soumission` date NOT NULL,
`titre` varchar(255) NOT NULL DEFAULT '',
`abstract` text NOT NULL,
`staff_notes` text,
Expand Down Expand Up @@ -985,7 +985,7 @@ CREATE TABLE `afup_sessions_note` (
`session_id` int(11) NOT NULL DEFAULT '0',
`note` tinyint(4) NOT NULL DEFAULT '0',
`salt` char(32) NOT NULL DEFAULT '',
`date_soumission` date NOT NULL DEFAULT '0000-00-00',
`date_soumission` date NOT NULL,
PRIMARY KEY (`note`,`session_id`,`salt`) USING BTREE
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
Expand Down Expand Up @@ -1441,7 +1441,7 @@ CREATE TABLE `compta` (
`attachment_filename` varchar(255) DEFAULT NULL,
`numero` varchar(50) NOT NULL,
`idmode_regl` tinyint(5) NOT NULL,
`date_regl` date NOT NULL,
`date_regl` date NULL,
`obs_regl` varchar(255) NOT NULL,
`idevenement` tinyint(5) NOT NULL,
`idcompte` tinyint(2) NOT NULL DEFAULT '1',
Expand Down
22 changes: 22 additions & 0 deletions db/migrations/20241202162110_mariadb_to_mysql.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

use Phinx\Migration\AbstractMigration;

class MariaDBToMysql extends AbstractMigration
{
public function change()
{
$this->execute("ALTER TABLE afup_sessions ALTER COLUMN skill SET DEFAULT 0");
$this->execute("ALTER TABLE afup_forum MODIFY date_debut date NULL");
$this->execute("ALTER TABLE afup_forum MODIFY date_fin date NULL");
$this->execute("ALTER TABLE afup_sessions ALTER COLUMN has_allowed_to_sharing_with_local_offices SET DEFAULT 0");
$this->execute("ALTER TABLE compta MODIFY idevenement TINYINT(5) NULL");
$this->execute("ALTER TABLE compta MODIFY date_regl date NULL");
$this->execute("ALTER TABLE compta_categorie MODIFY idevenement TINYINT(5) NULL");
$this->execute("ALTER TABLE afup_compta_facture MODIFY date_facture DATE NULL");
$this->execute("ALTER TABLE afup_compta_facture MODIFY numero_facture VARCHAR(50) NULL");
$this->execute("ALTER TABLE compta MODIFY idclef VARCHAR(20) NULL");
$this->execute("ALTER TABLE afup_inscription_forum MODIFY transport_mode SMALLINT NULL");
}
}

4 changes: 2 additions & 2 deletions db/seeds/Compta.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function run()
'idoperation' => 0,
'idcategorie' => 0,
'idmode_regl' => 0,
'date_regl' => '0000-00-00',
'date_regl' => null,
'idevenement' => 0,
],
[
Expand All @@ -89,7 +89,7 @@ public function run()
'idoperation' => 0,
'idcategorie' => 0,
'idmode_regl' => 0,
'date_regl' => '0000-00-00',
'date_regl' => null,
'idevenement' => 0,
],
];
Expand Down
4 changes: 2 additions & 2 deletions db/seeds/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function run()
'date_fin_saisie_nuites_hotel' => $event - $oneDayInSeconds * 7,
'place_name' => 'Paris',
'place_address' => 'Marriott Rive Gauche',
'date_annonce_planning' => date('Y-m-d H:i:s', $now - $oneMonthInSeconds),
'date_annonce_planning' => $now - $oneMonthInSeconds,
'transport_information_enabled' => 1,
'has_prices_defined_with_vat' => 1,
],
Expand Down Expand Up @@ -70,7 +70,7 @@ public function run()
'date_fin_saisie_nuites_hotel' => $event - $oneDayInSeconds * 7,
'place_name' => 'Paris',
'place_address' => 'Marriott Rive Gauche',
'date_annonce_planning' => date('Y-m-d H:i:s', $now - $oneMonthInSeconds),
'date_annonce_planning' => $now - $oneMonthInSeconds,
'transport_information_enabled' => 1,
'has_prices_defined_with_vat' => 1,
],
Expand Down
2 changes: 1 addition & 1 deletion docker/dockerfiles/mysql/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mariadb:10.0.29
FROM mysql:5.7

COPY my.cnf /etc/mysql/my.cnf
COPY mysql /opt/mysql
Expand Down
1 change: 1 addition & 0 deletions docker/dockerfiles/mysql/my.cnf
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
skip-host-cache
skip-name-resolve
innodb_file_per_table=1
sql-mode="STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION"
2 changes: 1 addition & 1 deletion docker/dockerfiles/mysqltest/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mariadb:10.0.29
FROM mysql:5.7

COPY my.cnf /etc/mysql/my.cnf
COPY mysql /opt/mysql
Expand Down
1 change: 1 addition & 0 deletions docker/dockerfiles/mysqltest/my.cnf
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
skip-host-cache
skip-name-resolve
innodb_file_per_table=1
sql-mode="STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION"
14 changes: 7 additions & 7 deletions htdocs/pages/administration/compta_devis.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,9 @@ function prepareDefaultsFromComptaFacId(Facture $comptaFact, $id) {
$ok = $comptaFact->ajouter_details(
$valeur['ref'.$i],
$valeur['designation'.$i],
$valeur['quantite'.$i],
$valeur['pu'.$i],
$valeur['tva'.$i]
(int)$valeur['quantite'.$i],
(float)$valeur['pu'.$i],
(int)$valeur['tva'.$i]
);
}
} else {
Expand All @@ -264,7 +264,7 @@ function prepareDefaultsFromComptaFacId(Facture $comptaFact, $id) {
$valeur['ref_clt2'],
$valeur['ref_clt3'],
$valeur['numero_devis'],
$valeur['numero_facture'],
$valeur['numero_facture'] ?? null,
0,
null,
$valeur['devise_facture']
Expand All @@ -275,9 +275,9 @@ function prepareDefaultsFromComptaFacId(Facture $comptaFact, $id) {
$valeur['id'.$i],
$valeur['ref'.$i],
$valeur['designation'.$i],
$valeur['quantite'.$i],
$valeur['pu'.$i],
$valeur['tva'.$i]
(int)$valeur['quantite'.$i],
(float)$valeur['pu'.$i],
(int)$valeur['tva'.$i]
);
}

Expand Down
6 changes: 3 additions & 3 deletions htdocs/pages/administration/compta_facture.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,9 @@
$valeur['id'.$i],
$valeur['ref'.$i],
$valeur['designation'.$i],
$valeur['quantite'.$i],
$valeur['pu'.$i],
$valeur['tva'.$i]
(int)$valeur['quantite'.$i],
(float)$valeur['pu'.$i],
(int)$valeur['tva'.$i]
);
}

Expand Down
4 changes: 2 additions & 2 deletions htdocs/pages/administration/forum_inscriptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,8 @@ function updateGlobalsForTarif(
$valeurs['commentaires'],
$valeurs['etat'],
$valeurs['facturation'],
$valeurs['transport_mode'],
$valeurs['transport_distance']);
(int)$valeurs['transport_mode'],
(int)$valeurs['transport_distance']);

/** @var \AppBundle\Event\Model\Ticket $ticket */
$ticket = $ticketRepository->get($_GET['id']);
Expand Down
16 changes: 8 additions & 8 deletions htdocs/pages/administration/forum_sessions.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,10 @@
$valeurs['date_soumission']['Y'].'-'.$valeurs['date_soumission']['M'].'-'.$valeurs['date_soumission']['d'],
$valeurs['titre'],
$valeurs['abstract'],
$valeurs['genre'],
$valeurs['plannifie'],
isset($valeurs['needs_mentoring']) ? $valeurs['needs_mentoring'] : 0,
$valeurs['skill'],
(int)$valeurs['genre'],
(int)$valeurs['plannifie'],
isset($valeurs['needs_mentoring']) ? (int)$valeurs['needs_mentoring'] : 0,
(int)$valeurs['skill'],
$valeurs['use_markdown']
);
$ok = (bool)$session_id;
Expand All @@ -255,17 +255,17 @@
$valeurs['date_soumission']['Y'].'-'.$valeurs['date_soumission']['M'].'-'.$valeurs['date_soumission']['d'],
$valeurs['titre'],
$valeurs['abstract'],
$valeurs['genre'],
$valeurs['plannifie'],
(int)$valeurs['genre'],
(int)$valeurs['plannifie'],
$valeurs['joindin'],
$valeurs['youtube_id'],
$valeurs['slides_url'],
$valeurs['openfeedback_path'],
$valeurs['blog_post_url'],
$valeurs['interview_url'],
$valeurs['language_code'],
$valeurs['skill'],
$valeurs['needs_mentoring'],
(int)$valeurs['skill'],
(int)$valeurs['needs_mentoring'],
$valeurs['use_markdown'],
$valeurs['video_has_fr_subtitles'],
$valeurs['video_has_en_subtitles'],
Expand Down
4 changes: 2 additions & 2 deletions sources/Afup/Comptabilite/Facture.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ function ajouter($date_devis, $societe, $service, $adresse, $code_postal, $ville
return $this->_bdd->executer($requete);
}

function ajouter_details($ref, $designation, $quantite, $pu, $tva = 0)
function ajouter_details($ref, $designation, int $quantite, float $pu, int $tva = 0)
{
$requete = 'INSERT INTO ';
$requete .= 'afup_compta_facture_details (';
Expand Down Expand Up @@ -237,7 +237,7 @@ function modifier($id, $date_devis, $societe, $service, $adresse, $code_postal,
return $this->_bdd->executer($requete);
}

function modifier_details($id, $ref, $designation, $quantite, $pu, $tva = 0)
function modifier_details($id, $ref, $designation, int $quantite, float $pu, int $tva = 0)
{
$requete = 'UPDATE ';
$requete .= 'afup_compta_facture_details ';
Expand Down
4 changes: 2 additions & 2 deletions sources/Afup/Corporate/Feuille.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function inserer()
}
$requete = 'INSERT INTO afup_site_feuille
SET
id_parent = ' . $this->bdd->echapper($this->id_parent) . ',
id_parent = ' . $this->bdd->echapper(!$this->id_parent ? null : $this->id_parent) . ',
nom = ' . $this->bdd->echapper($this->nom) . ',
lien = ' . $this->bdd->echapper($this->lien) . ',
alt = ' . $this->bdd->echapper($this->alt) . ',
Expand All @@ -66,7 +66,7 @@ function modifier()
{
$requete = 'UPDATE afup_site_feuille
SET
id_parent = ' . $this->bdd->echapper($this->id_parent) . ',
id_parent = ' . $this->bdd->echapper(!$this->id_parent ? null : $this->id_parent) . ',
nom = ' . $this->bdd->echapper($this->nom) . ',
lien = ' . $this->bdd->echapper($this->lien) . ',
alt = ' . $this->bdd->echapper($this->alt) . ',
Expand Down
19 changes: 11 additions & 8 deletions sources/Afup/Forum/AppelConferencier.php
Original file line number Diff line number Diff line change
Expand Up @@ -404,17 +404,17 @@ public function modifierSession(
$date_soumission,
$titre,
$abstract,
$genre,
$plannifie,
int $genre,
int $plannifie,
$joindin = null,
$youtubeId = null,
$slidesUrl = null,
$openfeedbackPath = null,
$blogPostUrl = null,
$interviewUrl = null,
$languageCode = null,
$skill = null,
$needs_mentoring = null,
int $skill = null,
int $needs_mentoring = null,
$use_markdown = null,
$video_has_fr_subtitles = null,
$video_has_en_subtitles = null,
Expand Down Expand Up @@ -499,10 +499,10 @@ public function ajouterSession(
$date_soumission,
$titre,
$abstract,
$genre,
$plannifie = 0,
$needs_mentoring = 0,
$level = Talk::SKILL_NA,
int $genre,
int $plannifie = 0,
int $needs_mentoring = 0,
int $level = Talk::SKILL_NA,
$useMarkdown = false
) {

Expand Down Expand Up @@ -541,6 +541,9 @@ function delierSession($session_id)

public function lierConferencierSession($conferencier_id, $session_id)
{
if (!$conferencier_id) {
return true;
}
$donnees = array(
$this->_bdd->echapper($conferencier_id),
$this->_bdd->echapper($session_id),
Expand Down
2 changes: 1 addition & 1 deletion sources/Afup/Forum/Inscriptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ function obtenirListe($id_forum = null,
function modifierInscription($id, $reference, $type_inscription, $civilite, $nom, $prenom,
$email, $telephone, $coupon, $citer_societe, $newsletter_afup,
$newsletter_nexen, $mail_partenaire, $commentaires, $etat, $facturation,
$transportMode, $transportDistance)
int $transportMode, int $transportDistance)
{
$requete = 'UPDATE ';
$requete .= ' afup_inscription_forum ';
Expand Down
4 changes: 4 additions & 0 deletions sources/Afup/Utils/Base_De_Donnees.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,10 @@ public function getLastErrorMessage()
function executer($requete)
{
$result = mysqli_query($this->getDbLink(), $requete);
if (!$result) {
throw new \RuntimeException(mysqli_error($this->getDbLink()));
}

return $result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use AppBundle\Association\Model\CompanyMember;
use Aura\SqlQuery\Common\SelectInterface;
use CCMBenchmark\Ting\Driver\Mysqli\Serializer\Boolean;
use CCMBenchmark\Ting\Repository\HydratorSingleObject;
use CCMBenchmark\Ting\Repository\Metadata;
use CCMBenchmark\Ting\Repository\MetadataInitializer;
Expand Down Expand Up @@ -170,7 +171,8 @@ public static function initMetadata(SerializerFactoryInterface $serializerFactor
->addField([
'columnName' => 'public_profile_enabled',
'fieldName' => 'publicProfileEnabled',
'type' => 'boolean',
'type' => 'bool',
'serializer' => Boolean::class
])
->addField([
'columnName' => 'description',
Expand Down
Loading

0 comments on commit 0d08d61

Please sign in to comment.