Skip to content

Commit 9045b89

Browse files
committed
Make paths more consistent
1 parent ee3a225 commit 9045b89

1 file changed

Lines changed: 18 additions & 10 deletions

File tree

docs/prepare-db-upgrade-downgrade.md

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -139,38 +139,46 @@ You might also choose to test with a real-world database.
139139

140140
#### Creating the scripts manually
141141

142-
To create both directions manually, without using `prepare-db-upgrade.sh`:
142+
To create both directions manually, without using `prepare-db-upgrade.sh`, run the following
143+
commands from the repository root. First set `lang` to the language directory and `schema_file`
144+
to the repository-relative path of its `.dbscheme` file. For example, for Go:
145+
146+
```sh
147+
lang=go
148+
schema_file=go/ql/lib/go.dbscheme
149+
```
143150

144151
1. Get the hashes of the old `.dbscheme` from `main` and the new `.dbscheme` from
145152
your branch. For example:
146153

147154
```sh
148-
old_hash=$(git show main:ql/lib/<mylang>.dbscheme | git hash-object --stdin)
149-
new_hash=$(git hash-object ql/lib/<mylang>.dbscheme)
155+
old_hash=$(git show "main:$schema_file" | git hash-object --stdin)
156+
new_hash=$(git hash-object "$schema_file")
150157
```
151158

152159
2. Create the upgrade directory using the old hash and the downgrade directory using the
153160
new hash:
154161

155162
```sh
156-
mkdir -p ql/lib/upgrades/$old_hash
157-
mkdir -p downgrades/$new_hash
163+
upgrade_dir="$lang/ql/lib/upgrades/$old_hash"
164+
downgrade_dir="$lang/downgrades/$new_hash"
165+
mkdir -p "$upgrade_dir" "$downgrade_dir"
158166
```
159167

160168
3. Populate the upgrade directory. Here, `old.dbscheme` is the schema from `main`, and
161-
`<mylang>.dbscheme` is the new target schema:
169+
the other `.dbscheme` file is the new target schema:
162170

163171
```sh
164-
git show main:ql/lib/<mylang>.dbscheme > ql/lib/upgrades/$old_hash/old.dbscheme
165-
cp ql/lib/<mylang>.dbscheme ql/lib/upgrades/$old_hash/<mylang>.dbscheme
172+
git show "main:$schema_file" > "$upgrade_dir/old.dbscheme"
173+
cp "$schema_file" "$upgrade_dir/$(basename "$schema_file")"
166174
```
167175

168176
4. Populate the downgrade directory in the opposite direction. For a downgrade, the new
169177
schema is called `old.dbscheme`, because it is the schema before the downgrade step:
170178

171179
```sh
172-
cp ql/lib/<mylang>.dbscheme downgrades/$new_hash/old.dbscheme
173-
git show main:ql/lib/<mylang>.dbscheme > downgrades/$new_hash/<mylang>.dbscheme
180+
cp "$schema_file" "$downgrade_dir/old.dbscheme"
181+
git show "main:$schema_file" > "$downgrade_dir/$(basename "$schema_file")"
174182
```
175183

176184
5. Create an `upgrade.properties` file in each directory. The file in the upgrade directory

0 commit comments

Comments
 (0)