<?php 

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

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

    /**
     * Run the migrations
     *
     * @return void
     */
    public function up()
    {
		self::$connection->execute('
			CREATE TABLE public.users
			(
			  id uuid NOT NULL DEFAULT uuid_generate_v4(),
			  name character varying(255) NOT NULL,
			  email character varying(255) NOT NULL,
			  password character(60) NOT NULL,
			  must_change_password boolean DEFAULT true,
			  profiles_id uuid NOT NULL,
			  active boolean DEFAULT true,
			  created timestamp without time zone DEFAULT now(),
			  creator uuid,
			  last_update timestamp without time zone,
			  last_updater uuid,
			  current_token uuid,
			  CONSTRAINT users_pkey PRIMARY KEY (id),
			  CONSTRAINT users_fk FOREIGN KEY (profiles_id)
				  REFERENCES public.profiles (id) MATCH SIMPLE
				  ON UPDATE NO ACTION ON DELETE NO ACTION
			)
			WITH (
			  OIDS=FALSE
			);
			ALTER TABLE public.users
			  OWNER TO postgres;

			insert into public.users values (\'00000000-0000-0000-0000-000000000000\',\'System\', \'jaga@kpk.go.id\' ,\'\', false, \'e3bc7d6f-b0f6-46de-b271-25b7497ad9f7\', true, now(), \'00000000-0000-0000-0000-000000000000\',  NULL, NULL);
			update public.profiles set creator = \'00000000-0000-0000-0000-000000000000\' where creator is null and id in (\'e3bc7d6f-b0f6-46de-b271-25b7497ad9f7\', \'ec26d5f5-244a-458f-a473-1e876b66c6a0\');

			alter table public.um_user add column um_user_new_password varchar(255);

		');
    }

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

    }

}
