<?php

namespace KupShop\CDNBundle\Resources\upgrade;

class CDNUpgrade extends \UpgradeNew
{
    public function check_VideosTable()
    {
        if (findModule(\Modules::VIDEOS)) {
            return $this->checkTableExists('videos');
        }

        return false;
    }

    /** Create table videos */
    public function upgrade_VideosTable()
    {
        sqlQuery(
            'create table videos
(
	id_photo int(11) unsigned not null,
	id_cdn varchar(255) not null,
	data mediumtext null,
	filename varchar(255) not null,
	constraint videos_pk
		primary key (id_photo),
	constraint videos_photos_id_fk
		foreign key (id_photo) references photos (id)
			on update cascade on delete cascade
);
'
        );
        $this->upgradeOK();
    }
}
