File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
coderd/database/migrations Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ # Naming the fixture is optional, if missing, the name of the latest
4
+ # migration will be used.
5
+ #
6
+ # Usage:
7
+ # ./create_fixture
8
+ # ./create_fixture name of fixture
9
+ # ./create_fixture "name of fixture"
10
+ # ./create_fixture name_of_fixture
11
+
12
+ set -euo pipefail
13
+
14
+ SCRIPT_DIR=$( dirname " ${BASH_SOURCE[0]} " )
15
+ (
16
+ cd " $SCRIPT_DIR "
17
+
18
+ # if migration name is an empty string exit
19
+ [[ -z " ${* } " ]] && (echo " Must provide a fixture name" && exit 1)
20
+
21
+ latest_migration=$( basename " $( find . -maxdepth 1 -name " *.up.sql" | sort -n | tail -n 1) " )
22
+ if [[ -n " ${* } " ]]; then
23
+ name=$*
24
+ name=${name// / _}
25
+ num=${latest_migration%% _* }
26
+ latest_migration=" ${num} _${name} .up.sql"
27
+ fi
28
+
29
+ filename=" $( pwd) /testdata/fixtures/$latest_migration "
30
+ touch " $filename "
31
+ echo " $filename "
32
+ echo " Edit fixture and commit it."
33
+ )
You can’t perform that action at this time.
0 commit comments