<?php

namespace App\Database\Migrations;

use CodeIgniter\Database\Migration;

class DropOauthTables extends Migration
{
    public function up()
    {
        $this->forge->dropTable('wg_user_oauth');
        $this->forge->dropTable('wg_settings_oauth');
    }

    public function down()
    {
        $sql = "CREATE TABLE IF NOT EXISTS `wg_settings_oauth` (
            `id_oauth` int(11) NOT NULL AUTO_INCREMENT,
            `provider` enum('facebook','google','twitter','linkedin','github','instagram','slack','spotify','reddit','discord','dribbble','dropbox','gitlab','strava','tumblr','twitch','vkontakte','wordpress','yahoo','bitbucket','wechat') COLLATE latin1_general_ci NOT NULL,
            `key` varchar(200) COLLATE latin1_general_ci DEFAULT NULL,
            `secret` varchar(200) COLLATE latin1_general_ci DEFAULT NULL,
            `btn_class` varchar(50) COLLATE latin1_general_ci NOT NULL,
            `btn_text` varchar(50) COLLATE latin1_general_ci DEFAULT NULL,
            `show_text` tinyint(1) NOT NULL DEFAULT '0',
            `icon_class` varchar(50) COLLATE latin1_general_ci NOT NULL,
            `status` tinyint(1) NOT NULL DEFAULT '0',
            PRIMARY KEY (`id_oauth`)
          ) ENGINE=MyISAM AUTO_INCREMENT=22 DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;";
        $this->db->query($sql);

        $sql = "CREATE TABLE IF NOT EXISTS `wg_user_oauth` (
            `id_user_oauth` int(11) NOT NULL AUTO_INCREMENT,
            `user` varchar(35) COLLATE latin1_general_ci NOT NULL,
            `provider` enum('facebook','google','twitter','linkedin','github','instagram','slack','spotify','reddit','discord','dribbble','dropbox','gitlab','strava','tumblr','twitch','vkontakte','wordpress','yahoo','bitbucket') COLLATE latin1_general_ci NOT NULL,
            `identifier` varchar(50) COLLATE latin1_general_ci NOT NULL,
            `picture` varchar(150) COLLATE latin1_general_ci NOT NULL,
            `created_at` timestamp NOT NULL,
            `updated_at` timestamp NOT NULL ON UPDATE CURRENT_TIMESTAMP,
            PRIMARY KEY (`id_user_oauth`)
          ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;";
        $this->db->query($sql);
    }
}