-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake-sql-schema-files.sh
executable file
·58 lines (47 loc) · 1.35 KB
/
make-sql-schema-files.sh
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
#!/usr/bin/env bash
SCHEMA_DIR="./src/lib/backend/db/schema"
TAXONOMY="${SCHEMA_DIR}/taxonomy"
TAXONOMY_SQL="${TAXONOMY}.sql"
TAXONOMY_TS="${TAXONOMY}.ts"
{ echo "import sql from 'sql-template-tag'"
echo
echo "export const schemaTaxonomy = sql\`"
cat "${TAXONOMY_SQL}"
echo "\`"
} > ${TAXONOMY_TS}
SUMMARIES="${SCHEMA_DIR}/summaries"
SUMMARIES_SQL="${SUMMARIES}.sql"
SUMMARIES_TS="${SUMMARIES}.ts"
{ echo "import sql from 'sql-template-tag'"
echo
echo "export const schemaSummaries = sql\`"
cat "${SUMMARIES_SQL}"
echo "\`"
} > ${SUMMARIES_TS}
SECRECS="${SCHEMA_DIR}/seqrecs"
SECRECS_SQL="${SECRECS}.sql"
SECRECS_TS="${SECRECS}.ts"
{ echo "import sql from 'sql-template-tag'"
echo
echo "export const schemaSeqRecs = sql\`"
cat "${SECRECS_SQL}"
echo "\`"
} > ${SECRECS_TS}
SEQUENCES="${SCHEMA_DIR}/sequences"
SEQUENCES_SQL="${SEQUENCES}.sql"
SEQUENCES_TS="${SEQUENCES}.ts"
{ echo "import sql from 'sql-template-tag'"
echo
echo "export const schemaSequences = sql\`"
cat "${SEQUENCES_SQL}"
echo "\`"
} > ${SEQUENCES_TS}
COLLECTIONS="${SCHEMA_DIR}/collections"
COLLECTIONS_SQL="${COLLECTIONS}.sql"
COLLECTIONS_TS="${COLLECTIONS}.ts"
{ echo "import sql from 'sql-template-tag'"
echo
echo "export const schemaCollections = sql\`"
cat "${COLLECTIONS_SQL}"
echo "\`"
} > ${COLLECTIONS_TS}