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
#!/usr/bin/env python3
# Description: {{DESCRIPTION}}
=
=
=
= ==
# Example operations (remove or modify as needed):
# 1. Copy file from migration sub-dir to target location
# source_file = migrations_dir / migration_id / 'config.example.json'
# target_file = project_root / 'config' / 'config.json'
# target_file.parent.mkdir(parents=True, exist_ok=True)
# shutil.copy2(source_file, target_file)
# 2. Update a JSON file: remove one element and set another value
# config_path = project_root / 'config.json'
# with open(config_path) as f:
# config = json.load(f)
# config.pop('oldField', None)
# config.setdefault('settings', {})['newValue'] = 'updated'
# with open(config_path, 'w') as f:
# json.dump(config, f, indent=2)
# 3. Delete one directory and replace it with another
# old_dir = project_root / 'old-directory'
# new_dir_source = migrations_dir / migration_id / 'new-directory'
# new_dir_target = project_root / 'new-directory'
# shutil.rmtree(old_dir, ignore_errors=True)
# shutil.copytree(new_dir_source, new_dir_target)