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

fix #123 fix #125 #131

Merged
merged 53 commits into from
Feb 3, 2022
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
5935267
refactoring
baimard Jan 22, 2022
184c16e
refactoring
baimard Jan 22, 2022
75ad70f
clean
baimard Jan 26, 2022
b527046
Merge branch 'master' of github.com:baimard/gestion into dev
baimard Jan 27, 2022
3f14409
transifex
baimard Jan 27, 2022
b0ea08d
Merge branch 'master' of github.com:baimard/gestion into dev
baimard Jan 28, 2022
cf20196
transifex
baimard Jan 28, 2022
0504719
Merge branch 'master' of github.com:baimard/gestion into dev
baimard Jan 29, 2022
54fa1c2
test
baimard Jan 29, 2022
9b23b2e
Translation
baimard Jan 29, 2022
d827efa
translation
baimard Jan 29, 2022
32a78c5
Merge branch 'master' into dev
baimard Jan 29, 2022
dca3b71
Merge branch 'master' of github.com:baimard/gestion into dev
baimard Jan 31, 2022
85f6179
hotfix
baimard Jan 31, 2022
02449f0
Merge branch 'dev' of github.com:baimard/gestion into dev
baimard Jan 31, 2022
475ed07
Merge branch 'master' of github.com:baimard/gestion into dev
baimard Feb 1, 2022
3cabf21
https://github.com/baimard/gestion/issues/123
baimard Feb 1, 2022
ac86d2a
Update lib/Migration/Version20002Date20220201085856.php
baimard Feb 1, 2022
804d73a
Update lib/Migration/Version20002Date20220201085856.php
baimard Feb 1, 2022
328cfbe
Update lib/Migration/Version7Date20220125174818.php
baimard Feb 1, 2022
dbddf9b
Update lib/Migration/Version7Date20220125174818.php
baimard Feb 1, 2022
fd52eb6
Update lib/Migration/Version7Date20220125174818.php
baimard Feb 1, 2022
2b4bab5
https://github.com/baimard/gestion/issues/135
baimard Feb 3, 2022
ea17117
Merge branch 'dev' of github.com:baimard/gestion into dev
baimard Feb 3, 2022
acd098d
Merge branch 'master' of github.com:baimard/gestion into dev
baimard Feb 3, 2022
fa8ab8e
Update lib/Migration/Version20002Date20220201085856.php
baimard Feb 3, 2022
9bb3d7a
Merge branch 'dev' of github.com:baimard/gestion into dev
baimard Feb 3, 2022
b6e6b91
valide
baimard Feb 3, 2022
0ca5f43
valide
baimard Feb 3, 2022
5981760
final
baimard Feb 3, 2022
3ea4ebd
Final
baimard Feb 3, 2022
a3f5f4e
Final
baimard Feb 3, 2022
90015f2
Update lib/Migration/Version20002Date20220201085856.php
baimard Feb 3, 2022
3ee5976
Update lib/Migration/Version20002Date20220201085856.php
baimard Feb 3, 2022
5fd7a03
Update lib/Migration/Version7Date20220125174818.php
baimard Feb 3, 2022
c8aacb8
Update lib/Migration/Version7Date20220125174818.php
baimard Feb 3, 2022
73eab43
Update lib/Migration/Version7Date20220125174818.php
baimard Feb 3, 2022
4578dfd
[tx-robot] updated from transifex
nextcloud-bot Feb 3, 2022
de54fd8
l10n: Fixed grammar
rakekniven Feb 3, 2022
7044077
l10n: Improve styling
Valdnet Feb 3, 2022
a6a8aa6
l10n: Improve styling
Valdnet Feb 3, 2022
3423b50
l10n: Add "an"
Valdnet Feb 3, 2022
53cec53
l10n: Add "an"
Valdnet Feb 3, 2022
9a34c28
l10n: Replace a word
Valdnet Feb 3, 2022
b9e233b
l10n: Replace a word
Valdnet Feb 3, 2022
894c831
[tx-robot] updated from transifex
nextcloud-bot Feb 3, 2022
76a995c
Update lib/Migration/Version20002Date20220201085856.php
baimard Feb 3, 2022
ab62c72
valide
baimard Feb 3, 2022
1ce19cb
valide
baimard Feb 3, 2022
987f873
final
baimard Feb 3, 2022
1db800d
Final
baimard Feb 3, 2022
dfa42dc
Final
baimard Feb 3, 2022
a025d9f
Merge branch 'dev' of github.com:baimard/gestion into dev
baimard Feb 3, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions lib/Migration/Version20002Date20220201085856.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php

declare(strict_types=1);

namespace OCA\Gestion\Migration;

use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
use OCP\IDBConnection;

class Version20002Date20220201085856 extends SimpleMigrationStep {
private $rows = [];
private IDbConnection $db;

public function __construct(IDbConnection $db){
$this->db = $db;
}

/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
*/
public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
$schema = $schemaClosure();
$tableprefix = "gestion_";
if($schema->getTable($tableprefix.'client')->hasColumn('siret')) {
$query = $this->db->getQueryBuilder();
$query ->select('id', 'siret')
->from($tableprefix.'client');
$this->rows = $query->execute()->fetchAll();
}
}

/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return null|ISchemaWrapper
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
$schema = $schemaClosure();
$tableprefix = "gestion_";

$table = $schema->getTable($tableprefix.'client');

if ($table->hasColumn('siret')) {
$table->dropColumn('siret');
}

if (!$table->hasColumn('legal_one')) {
$table->addColumn('legal_one', 'text', []);
}

$table = $schema->getTable($tableprefix.'configuration');
if (!$table->hasColumn('legal_one')) {
$table->addColumn('legal_one', 'text', []);
}
if (!$table->hasColumn('legal_two')) {
$table->addColumn('legal_two', 'text', []);
}

return $schema;


}

/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
*/
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
foreach ($this->rows as $row) {
$stmt = $this->db->prepare("UPDATE `".'*PREFIX*'."gestion_client` SET `legal_one` = ? WHERE id = ?;");
$stmt->execute(array($row['siret'], $row['id']));
baimard marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
15 changes: 0 additions & 15 deletions lib/Migration/Version7Date20220125174818.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
if (!$table->hasColumn('prenom')) {
$table->addColumn('prenom', 'text', []);
}
if (!$table->hasColumn('siret')) {
}else{
$stmt = $this->db->prepare("ALTER TABLE `".'*PREFIX*'."gestion_client` CHANGE `siret` `legal_one` LONGTEXT");
$stmt->execute();
}

if (!$table->hasColumn('legal_one')) {
$table->addColumn('legal_one', 'text', []);
Expand Down Expand Up @@ -102,17 +97,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
$table->addColumn('prenom', 'text', []);
}

if (!$table->hasColumn('siret')) {
}else{
$stmt = $this->db->prepare("ALTER TABLE `".'*PREFIX*'."gestion_configuration` CHANGE `siret` `legal_one` LONGTEXT");
$stmt->execute();
}

if (!$table->hasColumn('siren')) {
}else{
$stmt = $this->db->prepare("ALTER TABLE `".'*PREFIX*'."gestion_configuration` CHANGE `siren` `legal_two` LONGTEXT");
$stmt->execute();
}

if (!$table->hasColumn('legal_one')) {
$table->addColumn('legal_one', 'text', []);
Expand Down