-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-migration.sh
More file actions
executable file
·46 lines (32 loc) · 953 Bytes
/
create-migration.sh
File metadata and controls
executable file
·46 lines (32 loc) · 953 Bytes
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
#!/usr/bin/env sh
set +eux
function usage () {
echo "usage: create-migration \"description of migration\""
exit 1;
}
[[ -z $1 || $# -gt 1 ]] && usage
description=${1// /_}
year=$(date "+%Y")
month=$(date "+%m")
day=$(date "+%d")
hour=$(date "+%H")
minute=$(date "+%M")
seconds=$(date "+%S")
repo_root=$(git rev-parse --show-toplevel)
timestamp=${year}_${month}_${day}_${hour}_${minute}_${seconds}
migration_name=${timestamp}_${description}
file_name=${repo_root}/src/BoxToTabletop/Migrations/${migration_name}.fs
class_name=_${migration_name}
echo "Writing new migration to ${file_name}"
cat >"${file_name}" <<EOF
namespace BoxToTabletop.Migrations
open FluentMigrator
[<Migration(${timestamp}L)>]
type ${class_name} () =
inherit Migration ()
override __.Up () = ()
override __.Down () = ()
EOF
project_file=${repo_root}/src/BoxToTabletop/BoxToTabletop.fsproj
# trigger a reload to make tooling happy
touch "${project_file}"