-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
-
45
-
46
-
47
-
48
-
49
-
50
-
51
-
52
-
53
-
54
-
55
-
56
-
57
-
58
-
59
-
60
-
61
-
62
-
63
-
64
-
65
-
66
-
67
-
68
-
69
-
70
-
71
-
72
-
73
-
74
-
75
-
76
-
77
-
78
-
79
-
80
-
81
-
82
-
83
-
84
-
85
-
86
-
87
-
88
-
89
-
90
-
91
-
92
-
93
-
94
-
95
-
96
// SPDX-FileCopyrightText: 2024 Shota FUJI <pockawoooh@gmail.com>
// SPDX-License-Identifier: AGPL-3.0-only
import { createRandomBytes, packDate } from "../helpers";
import type { Migration } from "./types";
export const v6: Migration = async (_db, transaction) => {
const store = transaction.objectStore("workspaces");
for await (const cursor of store.iterate()) {
const defs = cursor.value.leaveDefinitions;
await cursor.update({
...cursor.value,
// 労働基準法 第三十九条 第十項 で定義されている「出勤したものとみなす」休業に
// ついてはどんな会社でも必ず必須となるため一律で登録する。
leaveDefinitions: [
{
id:
defs.find(
(def) => def.createdBy === "system" && def.displayName === "育児休業",
)?.id || `lv-${self.crypto.randomUUID()}`,
displayName: "育児休業",
updateKey: createRandomBytes(),
createdBy: "system",
revisions: [
{
id: `lr-${self.crypto.randomUUID()}`,
// 法律第七十九号
startAtPackedDate: packDate({
year: 1994,
month: 4,
day: 1,
}),
snapshot: {
isWorkerDeemedToBeWorked: true,
},
},
],
},
{
id:
defs.find(
(def) => def.createdBy === "system" && def.displayName === "介護休業",
)?.id || `lv-${self.crypto.randomUUID()}`,
displayName: "介護休業",
updateKey: createRandomBytes(),
createdBy: "system",
revisions: [
{
id: `lr-${self.crypto.randomUUID()}`,
// 法律第百七号
startAtPackedDate: packDate({
year: 1995,
month: 10,
day: 1,
}),
snapshot: {
isWorkerDeemedToBeWorked: true,
},
},
],
},
{
id:
defs.find(
(def) => def.createdBy === "system" && def.displayName === "産前産後休業",
)?.id || `lv-${self.crypto.randomUUID()}`,
displayName: "産前産後休業",
updateKey: createRandomBytes(),
createdBy: "system",
revisions: [
{
id: `lr-${self.crypto.randomUUID()}`,
// 最初からある (法律第四十九号)
// 三十九条の施行年月日は調べてもわからなかったので早い方 (遅い方は11/1)
// ただぶっちゃけ昔のことだからシステム運用的にはどっちでもいい。
// こんな昔のデータを入れるとしたら付与日数なんかも過去の計算式を用意
// する必要があるため、あくまでも記録・教育的な側面のデータ。
startAtPackedDate: packDate({
year: 1947,
month: 9,
day: 1,
}),
snapshot: {
isWorkerDeemedToBeWorked: true,
},
},
],
},
...defs.filter((def) => def.createdBy !== "system"),
],
});
}
};