-
Notifications
You must be signed in to change notification settings - Fork 4
/
20_create_dids.sh
executable file
·27 lines (22 loc) · 1.18 KB
/
20_create_dids.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
#!/bin/bash
echo "Configuring DIDs Table ..."
TABLE_EXISTS=$(mysql -h ${MYSQL_IP} -u ${MYSQL_USER} -p"${MYSQL_PASSWORD}" -D"${MYSQL_DATABASE}" -e \
"SELECT 1 FROM information_schema.tables WHERE table_schema = '${MYSQL_DATABASE}' AND table_name = 'dids';")
if [ -n "$TABLE_EXISTS" ]; then
echo "Table dids already exists"
else
echo "Creating dids table"
mysql -h ${MYSQL_IP} -u ${MYSQL_USER} -p"${MYSQL_PASSWORD}" -D"${MYSQL_DATABASE}" -e \
"INSERT INTO version (table_name, table_version) values ('dids','1');"
mysql -h ${MYSQL_IP} -u ${MYSQL_USER} -p"${MYSQL_PASSWORD}" -D"${MYSQL_DATABASE}" -e \
"CREATE TABLE dids (
id INT(10) UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL,
alias_username CHAR(64) DEFAULT '' NOT NULL,
alias_domain CHAR(64) DEFAULT '' NOT NULL,
username CHAR(64) DEFAULT '' NOT NULL,
domain CHAR(64) DEFAULT '' NOT NULL,
CONSTRAINT alias_idx UNIQUE (alias_username, alias_domain)
) ENGINE=InnoDB;"
mysql -h ${MYSQL_IP} -u ${MYSQL_USER} -p"${MYSQL_PASSWORD}" -D"${MYSQL_DATABASE}" -e \
"CREATE INDEX target_idx ON dids (username, domain);"
fi