<commit_before><?php
/**
 *
 * @filesource   dbstorage_create.php
 * @created      23.10.2017
 * @author       Smiley <<EMAIL>>
 * @copyright    2017 Smiley
 * @license      MIT
 */

namespace chillerlan\OAuthCLI;

use chillerlan\Database\Connection;
use chillerlan\OAuthTest\Storage\DBTest;

/** @var \chillerlan\Database\Connection $db */
$db = null;

require_once __DIR__.'/bootstrap_cli.php';

createTable($db, DBTest::TABLE_TOKEN, DBTest::TABLE_PROVIDER);

/**
 * @param \chillerlan\Database\Connection $db
 * @param string                          $token_table
 * @param string                          $provider_table
 *
 * @return bool|\chillerlan\Database\Result
 */
function createTable(Connection $db, string $token_table, string $provider_table){
	$db->connect();

	$db->raw('DROP TABLE IF EXISTS '.$token_table);
	$db->create
		->table($token_table)
		->primaryKey('label')
		->varchar('label', 32, null, false)
		->int('user_id',10, null, false)
		->varchar('provider_id', 30, '', false)
		->text('token', null, true)
		->text('state')
		->int('expires',10, null, false)
		->execute();

	$db->raw('DROP TABLE IF EXISTS '.$provider_table);
	$db->create
		->table($provider_table)
		->primaryKey('provider_id')
		->tinyint('provider_id',10, null, false, 'UNSIGNED AUTO_INCREMENT')
		->varchar('servicename', 30, '', false)
		->execute();

	$providers = [
		['provider_id' => 1, 'servicename' => 'Discogs'],
		['provider_id' => 2, 'servicename' => 'Twitter'],
		['provider_id' => 3, 'servicename' => 'Flickr'],
		['provider_id' => 4, 'servicename' => 'Foursquare'],
		['provider_id' => 5, 'servicename' => 'GitHub'],
		['provider_id' => 6, 'servicename' => 'Gitter'],
		['provider_id' => 7, 'servicename' => 'Google'],
		['provider_id' => 8, 'servicename' => 'Instagram'],
		['provider_id' => 9, 'servicename' => 'MusicBrainz'],
		['provider_id' => 10, 'servicename' => 'SoundCloud'],
		['provider_id' => 11, 'servicename' => 'Discord'],
		['provider_id' => 12, 'servicename' => 'Spotify'],
		['provider_id' => 13, 'servicename' => 'Twitch'],
		['provider_id' => 14, 'servicename' => 'Vimeo'],
		['provider_id' => 15, 'servicename' => 'LastFM'],
		['provider_id' => 16, 'servicename' => 'GuildWars2'],
		['provider_id' => 17, 'servicename' => 'Tumblr'],
		['provider_id' => 18, 'servicename' => 'Patreon'],
		['provider_id' => 19, 'servicename' => 'Twitter2'],
		['provider_id' => 20, 'servicename' => 'Wordpress'],
		['provider_id' => 21, 'servicename' => 'DeviantArt'],
		['provider_id' => 22, 'servicename' => 'YahooSocial'],
		['provider_id' => 23, 'servicename' => 'Deezer'],
		['provider_id' => 24, 'servicename' => 'Mixcloud'],
		['provider_id' => 25, 'servicename' => 'Slack'],
		['provider_id' => 26, 'servicename' => 'Amazon'],
	];

	return $db->insert
		->into($provider_table)
		->values($providers)
		->execute();
}

<commit_msg>:octocat:<commit_after><?php
/**
 *
 * @filesource   dbstorage_create.php
 * @created      23.10.2017
 * @author       Smiley <<EMAIL>>
 * @copyright    2017 Smiley
 * @license      MIT
 */

namespace chillerlan\OAuthCLI;

use chillerlan\Database\Connection;
use chillerlan\OAuthTest\Storage\TestDBStorage;

/** @var \chillerlan\Database\Connection $db */
$db = null;

require_once __DIR__.'/bootstrap_cli.php';

createTable($db, TestDBStorage::TABLE_TOKEN, TestDBStorage::TABLE_PROVIDER);

/**
 * @param \chillerlan\Database\Connection $db
 * @param string                          $token_table
 * @param string                          $provider_table
 *
 * @return bool|\chillerlan\Database\Result
 */
function createTable(Connection $db, string $token_table, string $provider_table){
	$db->connect();

	$db->raw('DROP TABLE IF EXISTS '.$token_table);
	$db->create
		->table($token_table)
		->primaryKey('label')
		->varchar('label', 32, null, false)
		->int('user_id',10, null, false)
		->varchar('provider_id', 30, '', false)
		->text('token', null, true)
		->text('state')
		->int('expires',10, null, false)
		->execute();

	$db->raw('DROP TABLE IF EXISTS '.$provider_table);
	$db->create
		->table($provider_table)
		->primaryKey('provider_id')
		->tinyint('provider_id',10, null, false, 'UNSIGNED AUTO_INCREMENT')
		->varchar('servicename', 30, '', false)
		->execute();

	$providers = [
		['provider_id' => 1, 'servicename' => 'Discogs'],
		['provider_id' => 2, 'servicename' => 'Twitter'],
		['provider_id' => 3, 'servicename' => 'Flickr'],
		['provider_id' => 4, 'servicename' => 'Foursquare'],
		['provider_id' => 5, 'servicename' => 'GitHub'],
		['provider_id' => 6, 'servicename' => 'Gitter'],
		['provider_id' => 7, 'servicename' => 'Google'],
		['provider_id' => 8, 'servicename' => 'Instagram'],
		['provider_id' => 9, 'servicename' => 'MusicBrainz'],
		['provider_id' => 10, 'servicename' => 'SoundCloud'],
		['provider_id' => 11, 'servicename' => 'Discord'],
		['provider_id' => 12, 'servicename' => 'Spotify'],
		['provider_id' => 13, 'servicename' => 'Twitch'],
		['provider_id' => 14, 'servicename' => 'Vimeo'],
		['provider_id' => 15, 'servicename' => 'LastFM'],
		['provider_id' => 16, 'servicename' => 'GuildWars2'],
		['provider_id' => 17, 'servicename' => 'Tumblr'],
		['provider_id' => 18, 'servicename' => 'Patreon'],
		['provider_id' => 19, 'servicename' => 'Twitter2'],
		['provider_id' => 20, 'servicename' => 'Wordpress'],
		['provider_id' => 21, 'servicename' => 'DeviantArt'],
		['provider_id' => 22, 'servicename' => 'YahooSocial'],
		['provider_id' => 23, 'servicename' => 'Deezer'],
		['provider_id' => 24, 'servicename' => 'Mixcloud'],
		['provider_id' => 25, 'servicename' => 'Slack'],
		['provider_id' => 26, 'servicename' => 'Amazon'],
	];

	return $db->insert
		->into($provider_table)
		->values($providers)
		->execute();
}


{'fraction_non_alphanumeric': 0.21876638126856543, 'fraction_numerical': 0.024113227328324306, 'mean_word_length': 4.5197685631629705, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 157, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5252108', 'n_tokens_mistral': 2305, 'n_tokens_neox': 2075, 'n_words': 402}