<?php 

use Phalcon\Db\Column;
use Phalcon\Db\Index;
use Phalcon\Db\Reference;
use Phalcon\Mvc\Model\Migration;

/**
 * Class JwtDataMigration_105
 */
class JwtDataMigration_105 extends Migration
{
    /**
     * Define the table structure
     *
     * @return void
     */
    public function morph()
    {
        
    }

    /**
     * Run the migrations
     *
     * @return void
     */
    public function up()
    {
		self::$connection->execute('
			CREATE TABLE jaga.jwt_data
			(
				id serial NOT NULL,
				user_id integer NOT NULL,
				tenant_id integer not null default -1234,
				token text NOT NULL,
				refresh_token text NOT NULL,
				refresh_token_exp bigint NOT NULL,
				client text,
				status smallint NOT NULL DEFAULT 0,
				created_at timestamp without time zone NOT NULL DEFAULT now(),
				updated_at timestamp without time zone NOT NULL DEFAULT now(),
				deleted_at timestamp without time zone,
				PRIMARY KEY (id),
				FOREIGN KEY (user_id, tenant_id)
					REFERENCES public.um_user (um_id, um_tenant_id) MATCH SIMPLE
					ON UPDATE CASCADE
					ON DELETE NO ACTION
			);
		');
    }

    /**
     * Reverse the migrations
     *
     * @return void
     */
    public function down()
    {

    }

}
