Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
web-et-numerique
Factory
Resin
Server
Commits
aaf0363e
Commit
aaf0363e
authored
9 months ago
by
Etienne LOUPIAS
Browse files
Options
Downloads
Patches
Plain Diff
fix(filter): fix freeWorkshop id
parent
26978f06
Loading
Loading
2 merge requests
!404
V3.1.0 (sans impression)
,
!402
fix(filter): fix freeWorkshop id
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/migrations/scripts/1716971590976-rename-freeworkshop-id.ts
+118
-0
118 additions, 0 deletions
...igrations/scripts/1716971590976-rename-freeworkshop-id.ts
with
118 additions
and
0 deletions
src/migrations/scripts/1716971590976-rename-freeworkshop-id.ts
0 → 100644
+
118
−
0
View file @
aaf0363e
import
{
Db
}
from
'
mongodb
'
;
import
{
getDb
}
from
'
../migrations-utils/db
'
;
export
const
up
=
async
()
=>
{
try
{
const
db
:
Db
=
await
getDb
();
// Change ids of the freeWorkShop category
const
categories
=
await
db
.
collection
(
'
categories
'
).
find
().
toArray
();
const
cursor
=
db
.
collection
(
'
categories
'
).
find
({
id
:
'
freeWorkShop
'
});
let
category
;
while
((
category
=
await
cursor
.
next
()))
{
const
modules
=
[
{
id
:
'
yes
'
,
name
:
'
Accompagnements gratuits
'
,
},
{
id
:
'
underCondition
'
,
name
:
'
Accompagnements gratuits sous conditions
'
,
},
{
id
:
'
no
'
,
name
:
'
Accompagnements payants
'
,
},
];
await
db
.
collection
(
'
categories
'
).
updateOne
(
{
_id
:
category
.
_id
},
{
$set
:
{
modules
:
modules
},
}
);
}
// Change freeWorkShop id of structures
const
structures
=
await
db
.
collection
(
'
structures
'
).
find
().
toArray
();
for
(
const
structure
of
structures
)
{
let
freeWorkShopValue
:
string
;
if
(
structure
.
categories
.
freeWorkShop
===
'
Oui
'
)
{
freeWorkShopValue
=
'
yes
'
;
}
else
if
(
structure
.
categories
.
freeWorkShop
===
'
Oui, sous condition
'
)
{
freeWorkShopValue
=
'
underCondition
'
;
}
else
if
(
structure
.
categories
.
freeWorkShop
===
'
Non
'
)
{
freeWorkShopValue
=
'
no
'
;
}
await
db
.
collection
(
'
structures
'
)
.
updateOne
({
_id
:
structure
.
_id
},
{
$set
:
{
'
categories.freeWorkShop
'
:
freeWorkShopValue
}
});
}
console
.
log
(
`Update done: freeWorkShops ids fixed.`
);
}
catch
(
error
)
{
console
.
error
(
'
Error while fixing freeWorkShops ids:
'
,
error
);
}
};
export
const
down
=
async
()
=>
{
try
{
const
db
:
Db
=
await
getDb
();
// Change ids of the freeWorkShop category
const
categories
=
await
db
.
collection
(
'
categories
'
).
find
().
toArray
();
const
cursor
=
db
.
collection
(
'
categories
'
).
find
({
id
:
'
freeWorkShop
'
});
let
category
;
while
((
category
=
await
cursor
.
next
()))
{
const
modules
=
[
{
id
:
'
Oui
'
,
name
:
'
Accompagnements gratuits
'
,
},
{
id
:
'
Oui, sous condition
'
,
name
:
'
Accompagnements gratuits sous conditions
'
,
},
{
id
:
'
Non
'
,
name
:
'
Accompagnements payants
'
,
},
];
await
db
.
collection
(
'
categories
'
).
updateOne
(
{
_id
:
category
.
_id
},
{
$set
:
{
modules
:
modules
},
}
);
}
// Change freeWorkShop id of structures
const
structures
=
await
db
.
collection
(
'
structures
'
).
find
().
toArray
();
for
(
const
structure
of
structures
)
{
let
freeWorkShopValue
:
string
;
if
(
structure
.
categories
.
freeWorkShop
===
'
yes
'
)
{
freeWorkShopValue
=
'
Oui
'
;
}
else
if
(
structure
.
categories
.
freeWorkShop
===
'
underCondition
'
)
{
freeWorkShopValue
=
'
Oui, sous condition
'
;
}
else
if
(
structure
.
categories
.
freeWorkShop
===
'
no
'
)
{
freeWorkShopValue
=
'
Non
'
;
}
await
db
.
collection
(
'
structures
'
)
.
updateOne
({
_id
:
structure
.
_id
},
{
$set
:
{
'
categories.freeWorkShop
'
:
freeWorkShopValue
}
});
}
console
.
log
(
`Downgrade done: freeWorkShops ids reverted.`
);
}
catch
(
error
)
{
console
.
error
(
'
Error reverting freeWorkShop ids:
'
,
error
);
}
};
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