Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MaarchCourrier
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Redmine
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Harbor Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maarch
MaarchCourrier
Commits
e93ca969
Commit
e93ca969
authored
4 years ago
by
Guillaume Heurtier
Browse files
Options
Downloads
Patches
Plain Diff
FEAT #15370 TIME 7:00 fix migration
parent
064d613e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
migration/20.10/2010.sql
+23
-1
23 additions, 1 deletion
migration/20.10/2010.sql
migration/20.10/migrateSavedQueries.php
+10
-8
10 additions, 8 deletions
migration/20.10/migrateSavedQueries.php
with
33 additions
and
9 deletions
migration/20.10/2010.sql
+
23
−
1
View file @
e93ca969
...
@@ -120,6 +120,13 @@ DO $$ BEGIN
...
@@ -120,6 +120,13 @@ DO $$ BEGIN
IF
(
SELECT
count
(
column_name
)
from
information_schema
.
columns
where
table_name
=
'res_attachments'
and
column_name
=
'typist'
and
data_type
!=
'integer'
)
THEN
IF
(
SELECT
count
(
column_name
)
from
information_schema
.
columns
where
table_name
=
'res_attachments'
and
column_name
=
'typist'
and
data_type
!=
'integer'
)
THEN
ALTER
TABLE
res_attachments
ADD
COLUMN
typist_tmp
INTEGER
;
ALTER
TABLE
res_attachments
ADD
COLUMN
typist_tmp
INTEGER
;
UPDATE
res_attachments
set
typist_tmp
=
(
select
id
FROM
users
where
users
.
user_id
=
res_attachments
.
typist
);
UPDATE
res_attachments
set
typist_tmp
=
(
select
id
FROM
users
where
users
.
user_id
=
res_attachments
.
typist
);
UPDATE
res_attachments
set
typist_tmp
=
(
SELECT
CASE
WHEN
(
SELECT
count
(
id
)
FROM
users
WHERE
user_id
=
'superadmin'
)
>
0
THEN
(
SELECT
id
FROM
users
WHERE
user_id
=
'superadmin'
)
ELSE
(
SELECT
id
FROM
users
WHERE
status
=
'OK'
ORDER
BY
id
LIMIT
1
)
END
)
WHERE
typist_tmp
IS
NULL
;
ALTER
TABLE
res_attachments
DROP
COLUMN
IF
EXISTS
typist
;
ALTER
TABLE
res_attachments
DROP
COLUMN
IF
EXISTS
typist
;
ALTER
TABLE
res_attachments
RENAME
COLUMN
typist_tmp
TO
typist
;
ALTER
TABLE
res_attachments
RENAME
COLUMN
typist_tmp
TO
typist
;
END
IF
;
END
IF
;
...
@@ -146,6 +153,14 @@ DO $$ BEGIN
...
@@ -146,6 +153,14 @@ DO $$ BEGIN
ALTER
TABLE
listinstance
ADD
COLUMN
item_id_tmp
INTEGER
;
ALTER
TABLE
listinstance
ADD
COLUMN
item_id_tmp
INTEGER
;
UPDATE
listinstance
set
item_id_tmp
=
(
select
id
FROM
users
where
users
.
user_id
=
listinstance
.
item_id
)
WHERE
item_type
=
'user_id'
;
UPDATE
listinstance
set
item_id_tmp
=
(
select
id
FROM
users
where
users
.
user_id
=
listinstance
.
item_id
)
WHERE
item_type
=
'user_id'
;
UPDATE
listinstance
set
item_id_tmp
=
(
select
id
FROM
entities
where
entities
.
entity_id
=
listinstance
.
item_id
)
WHERE
item_type
=
'entity_id'
;
UPDATE
listinstance
set
item_id_tmp
=
(
select
id
FROM
entities
where
entities
.
entity_id
=
listinstance
.
item_id
)
WHERE
item_type
=
'entity_id'
;
UPDATE
listinstance
set
item_id_tmp
=
(
SELECT
CASE
WHEN
(
SELECT
count
(
id
)
FROM
users
WHERE
user_id
=
'superadmin'
)
>
0
THEN
(
SELECT
id
FROM
users
WHERE
user_id
=
'superadmin'
)
ELSE
(
SELECT
id
FROM
users
WHERE
status
=
'OK'
ORDER
BY
id
LIMIT
1
)
END
)
WHERE
item_id_tmp
IS
NULL
AND
item_type
=
'user_id'
;
UPDATE
listinstance
set
item_id_tmp
=
(
SELECT
id
FROM
entities
WHERE
enabled
=
'Y'
ORDER
BY
id
LIMIT
1
)
WHERE
item_id_tmp
IS
NULL
AND
item_type
=
'entity_id'
;
ALTER
TABLE
listinstance
DROP
COLUMN
IF
EXISTS
item_id
;
ALTER
TABLE
listinstance
DROP
COLUMN
IF
EXISTS
item_id
;
ALTER
TABLE
listinstance
RENAME
COLUMN
item_id_tmp
TO
item_id
;
ALTER
TABLE
listinstance
RENAME
COLUMN
item_id_tmp
TO
item_id
;
UPDATE
baskets
SET
basket_clause
=
REGEXP_REPLACE
(
basket_clause
,
'item_id(
\s
*)=(
\s
*)@user '
,
'item_id = @user_id '
,
'gmi'
);
UPDATE
baskets
SET
basket_clause
=
REGEXP_REPLACE
(
basket_clause
,
'item_id(
\s
*)=(
\s
*)@user '
,
'item_id = @user_id '
,
'gmi'
);
...
@@ -159,6 +174,13 @@ DO $$ BEGIN
...
@@ -159,6 +174,13 @@ DO $$ BEGIN
IF
(
SELECT
count
(
column_name
)
from
information_schema
.
columns
where
table_name
=
'listinstance'
and
column_name
=
'added_by_user'
and
data_type
!=
'integer'
)
THEN
IF
(
SELECT
count
(
column_name
)
from
information_schema
.
columns
where
table_name
=
'listinstance'
and
column_name
=
'added_by_user'
and
data_type
!=
'integer'
)
THEN
ALTER
TABLE
listinstance
ADD
COLUMN
added_by_user_tmp
INTEGER
;
ALTER
TABLE
listinstance
ADD
COLUMN
added_by_user_tmp
INTEGER
;
UPDATE
listinstance
set
added_by_user_tmp
=
(
select
id
FROM
users
where
users
.
user_id
=
listinstance
.
added_by_user
);
UPDATE
listinstance
set
added_by_user_tmp
=
(
select
id
FROM
users
where
users
.
user_id
=
listinstance
.
added_by_user
);
UPDATE
listinstance
set
added_by_user_tmp
=
(
SELECT
CASE
WHEN
(
SELECT
count
(
id
)
FROM
users
WHERE
user_id
=
'superadmin'
)
>
0
THEN
(
SELECT
id
FROM
users
WHERE
user_id
=
'superadmin'
)
ELSE
(
SELECT
id
FROM
users
WHERE
status
=
'OK'
ORDER
BY
id
LIMIT
1
)
END
)
WHERE
added_by_user_tmp
IS
NULL
;
ALTER
TABLE
listinstance
DROP
COLUMN
IF
EXISTS
added_by_user
;
ALTER
TABLE
listinstance
DROP
COLUMN
IF
EXISTS
added_by_user
;
ALTER
TABLE
listinstance
RENAME
COLUMN
added_by_user_tmp
TO
added_by_user
;
ALTER
TABLE
listinstance
RENAME
COLUMN
added_by_user_tmp
TO
added_by_user
;
END
IF
;
END
IF
;
...
@@ -166,7 +188,7 @@ END$$;
...
@@ -166,7 +188,7 @@ END$$;
DO
$$
BEGIN
DO
$$
BEGIN
IF
(
SELECT
count
(
column_name
)
from
information_schema
.
columns
where
table_name
=
'history'
and
column_name
=
'user_id'
and
data_type
!=
'integer'
)
THEN
IF
(
SELECT
count
(
column_name
)
from
information_schema
.
columns
where
table_name
=
'history'
and
column_name
=
'user_id'
and
data_type
!=
'integer'
)
THEN
ALTER
TABLE
history
ADD
COLUMN
user_id_tmp
INTEGER
;
ALTER
TABLE
history
ADD
COLUMN
user_id_tmp
INTEGER
;
UPDATE
history
set
user_id_tmp
=
(
select
id
FROM
users
where
users
.
user_id
=
history
.
user_id
);
UPDATE
history
set
user_id_tmp
=
(
select
id
FROM
users
where
lower
(
users
.
user_id
)
=
lower
(
history
.
user_id
)
)
;
ALTER
TABLE
history
DROP
COLUMN
IF
EXISTS
user_id
;
ALTER
TABLE
history
DROP
COLUMN
IF
EXISTS
user_id
;
ALTER
TABLE
history
RENAME
COLUMN
user_id_tmp
TO
user_id
;
ALTER
TABLE
history
RENAME
COLUMN
user_id_tmp
TO
user_id
;
UPDATE
history
set
record_id
=
(
select
id
FROM
users
where
users
.
user_id
=
history
.
record_id
)
WHERE
table_name
=
'users'
;
UPDATE
history
set
record_id
=
(
select
id
FROM
users
where
users
.
user_id
=
history
.
record_id
)
WHERE
table_name
=
'users'
;
...
...
This diff is collapsed.
Click to expand it.
migration/20.10/migrateSavedQueries.php
+
10
−
8
View file @
e93ca969
...
@@ -91,15 +91,15 @@ foreach ($customs as $custom) {
...
@@ -91,15 +91,15 @@ foreach ($customs as $custom) {
}
elseif
(
$key
==
'confidentiality'
)
{
}
elseif
(
$key
==
'confidentiality'
)
{
$query
[]
=
[
'identifier'
=>
'confidentiality'
,
'values'
=>
[[
'id'
=>
$value
[
'fields'
][
'confidentiality'
][
0
]
==
'Y'
,
'label'
=>
$value
[
'fields'
][
'confidentiality'
][
0
]
==
'Y'
?
'Oui'
:
'Non'
]]];
$query
[]
=
[
'identifier'
=>
'confidentiality'
,
'values'
=>
[[
'id'
=>
$value
[
'fields'
][
'confidentiality'
][
0
]
==
'Y'
,
'label'
=>
$value
[
'fields'
][
'confidentiality'
][
0
]
==
'Y'
?
'Oui'
:
'Non'
]]];
}
elseif
(
$key
==
'creation_date'
)
{
}
elseif
(
$key
==
'creation_date'
)
{
$query
[]
=
[
'identifier'
=>
'creationDate'
,
'values'
=>
[
'start'
=>
getFormattedDate
(
$value
[
'fields'
][
'creation_date_from'
][
0
]),
'end'
=>
getFormattedDate
(
$value
[
'fields'
][
'creation_date_to'
][
0
])]];
$query
[]
=
[
'identifier'
=>
'creationDate'
,
'values'
=>
[
'start'
=>
getFormattedDate
(
[
'date'
=>
$value
[
'fields'
][
'creation_date_from'
][
0
]
]
),
'end'
=>
getFormattedDate
(
[
'date'
=>
$value
[
'fields'
][
'creation_date_to'
][
0
]
]
)]];
}
elseif
(
$key
==
'doc_date'
)
{
}
elseif
(
$key
==
'doc_date'
)
{
$query
[]
=
[
'identifier'
=>
'documentDate'
,
'values'
=>
[
'start'
=>
getFormattedDate
(
$value
[
'fields'
][
'doc_date_from'
][
0
]),
'end'
=>
getFormattedDate
(
$value
[
'fields'
][
'doc_date_to'
][
0
])]];
$query
[]
=
[
'identifier'
=>
'documentDate'
,
'values'
=>
[
'start'
=>
getFormattedDate
(
[
'date'
=>
$value
[
'fields'
][
'doc_date_from'
][
0
]
]
),
'end'
=>
getFormattedDate
(
[
'date'
=>
$value
[
'fields'
][
'doc_date_to'
][
0
]
]
)]];
}
elseif
(
$key
==
'admission_date'
)
{
}
elseif
(
$key
==
'admission_date'
)
{
$query
[]
=
[
'identifier'
=>
'arrivalDate'
,
'values'
=>
[
'start'
=>
getFormattedDate
(
$value
[
'fields'
][
'admission_date_from'
][
0
]),
'end'
=>
getFormattedDate
(
$value
[
'fields'
][
'admission_date_to'
][
0
])]];
$query
[]
=
[
'identifier'
=>
'arrivalDate'
,
'values'
=>
[
'start'
=>
getFormattedDate
(
[
'date'
=>
$value
[
'fields'
][
'admission_date_from'
][
0
]
]
),
'end'
=>
getFormattedDate
(
[
'date'
=>
$value
[
'fields'
][
'admission_date_to'
][
0
]
]
)]];
}
elseif
(
$key
==
'exp_date'
)
{
}
elseif
(
$key
==
'exp_date'
)
{
$query
[]
=
[
'identifier'
=>
'departureDate'
,
'values'
=>
[
'start'
=>
getFormattedDate
(
$value
[
'fields'
][
'exp_date_from'
][
0
]),
'end'
=>
getFormattedDate
(
$value
[
'fields'
][
'exp_date_to'
][
0
])]];
$query
[]
=
[
'identifier'
=>
'departureDate'
,
'values'
=>
[
'start'
=>
getFormattedDate
(
[
'date'
=>
$value
[
'fields'
][
'exp_date_from'
][
0
]
]
),
'end'
=>
getFormattedDate
(
[
'date'
=>
$value
[
'fields'
][
'exp_date_to'
][
0
]
]
)]];
}
elseif
(
$key
==
'process_limit_date'
)
{
}
elseif
(
$key
==
'process_limit_date'
)
{
$query
[]
=
[
'identifier'
=>
'processLimitDate'
,
'values'
=>
[
'start'
=>
getFormattedDate
(
$value
[
'fields'
][
'process_limit_date_from'
][
0
]),
'end'
=>
getFormattedDate
(
$value
[
'fields'
][
'process_limit_date_to'
][
0
])]];
$query
[]
=
[
'identifier'
=>
'processLimitDate'
,
'values'
=>
[
'start'
=>
getFormattedDate
(
[
'date'
=>
$value
[
'fields'
][
'process_limit_date_from'
][
0
]
]
),
'end'
=>
getFormattedDate
(
[
'date'
=>
$value
[
'fields'
][
'process_limit_date_to'
][
0
]
]
)]];
}
elseif
(
$key
==
'destination_mu'
)
{
}
elseif
(
$key
==
'destination_mu'
)
{
$allEntities
=
[];
$allEntities
=
[];
if
(
!
empty
(
$value
[
'fields'
][
'services_chosen'
])
&&
is_array
(
$value
[
'fields'
][
'services_chosen'
]))
{
if
(
!
empty
(
$value
[
'fields'
][
'services_chosen'
])
&&
is_array
(
$value
[
'fields'
][
'services_chosen'
]))
{
...
@@ -206,12 +206,14 @@ foreach ($customs as $custom) {
...
@@ -206,12 +206,14 @@ foreach ($customs as $custom) {
printf
(
"Migration recherches sauvegardées (CUSTOM
{
$custom
}
) :
{
$migrated
}
sauvegarde(s) trouvée(s) et migrée(s).
\n
"
);
printf
(
"Migration recherches sauvegardées (CUSTOM
{
$custom
}
) :
{
$migrated
}
sauvegarde(s) trouvée(s) et migrée(s).
\n
"
);
}
}
function
getFormattedDate
(
string
$date
)
function
getFormattedDate
(
array
$args
)
{
{
if
(
empty
(
$date
))
{
\SrcCore\models\ValidatorModel
::
stringType
(
$args
,
[
'date'
]);
if
(
empty
(
$args
[
'date'
]))
{
return
null
;
return
null
;
}
}
$date
=
new
\DateTime
(
$date
);
$date
=
new
\DateTime
(
$
args
[
'
date
'
]
);
$date
->
setTime
(
00
,
00
,
00
);
$date
->
setTime
(
00
,
00
,
00
);
return
$date
->
format
(
'Y-m-d'
);
return
$date
->
format
(
'Y-m-d'
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment