This repository has been archived by the owner on Apr 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
195 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/bash | ||
|
||
if [ $# -lt 3 ]; | ||
then | ||
echo "Usage: $(basename $0) <DB_HOST> <DB_USER> <DB_NAME> [<DB_PASS>]" && exit 1 | ||
fi | ||
|
||
if [ $# -eq 3 ]; | ||
then | ||
echo -n "DB password: " | ||
read -s DB_pass | ||
else | ||
DB_pass=$4 | ||
fi | ||
|
||
DB_host=$1 | ||
DB_user=$2 | ||
DB=$3 | ||
|
||
test -d $DB || mkdir -p $DB | ||
|
||
echo | ||
echo "Dumping tables into separate SQL command files for database '$DB'" | ||
|
||
tbl_count=0 | ||
|
||
for t in $(mysql -NBA -h $DB_host -u $DB_user -p$DB_pass -D $DB -e 'show tables') | ||
do | ||
echo "DUMPING TABLE: $t" | ||
mysqldump --compact --no-data -h $DB_host -u $DB_user -p$DB_pass $DB $t | sed 's/ AUTO_INCREMENT=[0-9]*//g' | sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' > $DB/$t.sql | ||
(( tbl_count++ )) | ||
done | ||
|
||
echo "$tbl_count tables dumped from database '$DB'" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
[ $# -lt 1 ] && echo "Usage: $(basename $0) <DB_NAME>" && exit 1 | ||
|
||
DB=$1 | ||
|
||
echo "Creating initial dump script for '$DB'" | ||
|
||
cat <(echo "SET FOREIGN_KEY_CHECKS=0;") > fresh_deploy_$DB.sql | ||
|
||
cat <(echo "CREATE DATABASE $DB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;;") >> fresh_deploy_$DB.sql | ||
|
||
cat <(echo "USE $DB;") >> fresh_deploy_$DB.sql | ||
|
||
FILES=$DB/*.sql | ||
for f in $FILES | ||
do | ||
if [ "$f" == "$DB/RefData.sql" ] | ||
then | ||
continue; | ||
fi | ||
echo "Processing $f..." | ||
cat $f >> fresh_deploy_$DB.sql | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/*!40101 SET @saved_cs_client = @@character_set_client */; | ||
/*!40101 SET character_set_client = utf8 */; | ||
CREATE TABLE `Feeds` ( | ||
`id` int(11) NOT NULL AUTO_INCREMENT, | ||
`Name` text COLLATE utf8mb4_unicode_ci NOT NULL, | ||
`Handle` text COLLATE utf8mb4_unicode_ci NOT NULL, | ||
`ScreenNames` text COLLATE utf8mb4_unicode_ci NOT NULL, | ||
`Key` text COLLATE utf8mb4_unicode_ci NOT NULL, | ||
`Secret` text COLLATE utf8mb4_unicode_ci NOT NULL, | ||
PRIMARY KEY (`id`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; | ||
/*!40101 SET character_set_client = @saved_cs_client */; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/*!40101 SET @saved_cs_client = @@character_set_client */; | ||
/*!40101 SET character_set_client = utf8 */; | ||
CREATE TABLE `Items` ( | ||
`id` int(11) NOT NULL AUTO_INCREMENT, | ||
`Hash` char(40) COLLATE utf8mb4_unicode_ci NOT NULL, | ||
`ScreenName` varchar(15) COLLATE utf8mb4_unicode_ci DEFAULT NULL, | ||
`id_str` varchar(24) COLLATE utf8mb4_unicode_ci DEFAULT NULL, | ||
`Url` text COLLATE utf8mb4_unicode_ci, | ||
`created_at` int(10) unsigned NOT NULL, | ||
PRIMARY KEY (`id`), | ||
UNIQUE KEY `Hash` (`Hash`), | ||
KEY `created_at` (`created_at`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; | ||
/*!40101 SET character_set_client = @saved_cs_client */; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/*!40101 SET @saved_cs_client = @@character_set_client */; | ||
/*!40101 SET character_set_client = utf8 */; | ||
CREATE TABLE `Meta` ( | ||
`Name` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL, | ||
`Value` text COLLATE utf8mb4_unicode_ci NOT NULL, | ||
PRIMARY KEY (`Name`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; | ||
/*!40101 SET character_set_client = @saved_cs_client */; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
'use strict'; | ||
|
||
const config = require('../config'); | ||
const mysql = require('mysql2'); | ||
|
||
module.exports = function() { | ||
const pool = mysql.createPool(config.mysql); | ||
return { | ||
query: function(sql, params) { | ||
return new Promise((resolve, reject) => { | ||
if (typeof sql !== 'string') { | ||
return reject(new Error('Missing query string')); | ||
} | ||
if (params !== undefined && params.constructor !== Array) { | ||
return reject(new Error('Params must be an array')); | ||
} | ||
pool.getConnection((err, conn) => { | ||
if (err) { return reject(err); } | ||
conn.query(sql, params, (error, res) => { | ||
conn.release(); | ||
if (error) { return reject(error); } | ||
return resolve(res); | ||
}); | ||
}); | ||
}); | ||
}, | ||
end: function() { | ||
return new Promise((resolve, reject) => { | ||
pool.end((err) => { | ||
if (err) { return reject(err); } | ||
console.log('Closing database.'); | ||
return resolve(); | ||
}); | ||
}); | ||
} | ||
}; | ||
}; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.