class CreateTempTokens < ActiveRecord::Migration def self.up execute( <<-SQL CREATE TABLE public.temp_tokens ( id character varying(64) DEFAULT public.uuid_generate_v4() NOT NULL, token character varying(64), user_id VARCHAR(64) NOT NULL REFERENCES users(id) ON DELETE CASCADE, purpose character varying(64) NOT NULL DEFAULT 'video_join_musician', created_at timestamp without time zone DEFAULT now() NOT NULL, expired_at timestamp without time zone); SQL ) execute("CREATE INDEX index_temp_tokens_purpose ON public.temp_tokens USING btree (purpose);") end def self.down execute("DROP INDEX IF EXISTS index_temp_tokens_purpose") execute("DROP TABLE public.temp_tokens") end end