Exemplo n.º 1
0
 public static function boot()
 {
     self::creating(function ($custom_field) {
         if (in_array($custom_field->db_column_name(), Schema::getColumnListing(DB::getTablePrefix() . CustomField::$table_name))) {
             //field already exists when making a new custom field; fail.
             return false;
         }
         return DB::statement("ALTER TABLE " . DB::getTablePrefix() . CustomField::$table_name . " ADD COLUMN (" . $custom_field->db_column_name() . " TEXT)");
     });
     self::updating(function ($custom_field) {
         //print("    SAVING CALLBACK FIRING!!!!!    ");
         if ($custom_field->isDirty("name")) {
             //print("DIRTINESS DETECTED!");
             //$fields=array_keys($custom_field->getAttributes());
             //;
             //add timestamp fields, add id column
             //array_push($fields,$custom_field->getKeyName());
             /*if($custom_field::timestamps) {
             
                     }*/
             //print("Fields are: ".print_r($fields,true));
             if (in_array($custom_field->db_column_name(), Schema::getColumnListing(CustomField::$table_name))) {
                 //field already exists when renaming a custom field
                 return false;
             }
             return DB::statement("UPDATE " . CustomField::$table_name . " RENAME " . self::name_to_db_name($custom_field->get_original("name")) . " TO " . $custom_field->db_column_name());
         }
         return true;
     });
     self::deleting(function ($custom_field) {
         return DB::statement("ALTER TABLE " . CustomField::$table_name . " DROP COLUMN " . $custom_field->db_column_name());
     });
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::table('image_files', function ($table) {
         $table->text('attributes');
     });
     DB::statement('ALTER TABLE `' . DB::getTablePrefix() . 'image_files` CHANGE `attributes` `attributes` TEXT NOT NULL AFTER `size`');
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     //
     $prefix = DB::getTablePrefix();
     DB::statement('ALTER TABLE ' . $prefix . 'users MODIFY phone varchar(20) null');
     DB::statement('ALTER TABLE ' . $prefix . 'users MODIFY jobtitle varchar(50) null');
 }
Exemplo n.º 4
0
 public function orderByMessengers($sortOrder = 'asc')
 {
     $prefix = \DB::getTablePrefix();
     $this->queryBuilder()->selectRaw(sprintf('* , (SELECT COUNT(*) FROM "%1$smessengers" WHERE "%1$smessengers"."contact_id" = "%1$scontacts"."id") as "messengers_count"', $prefix));
     $this->queryBuilder()->orderBy('messengers_count', $sortOrder);
     return $this;
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     /**
      * Since L4 doesn't support specifying collation for tables/text fields, 
      * An empty table (only contains ID) is created first. 
      */
     Schema::create($this->table, function ($table) {
         $table->bigIncrements('ID');
     });
     /**
      * Table collation is specified with raw MySQL SQL statement. 
      */
     $table_w_prefix = DB::getTablePrefix() . $this->table;
     DB::statement("ALTER TABLE `{$table_w_prefix}`\n            DEFAULT CHARACTER SET ascii COLLATE ascii_general_ci;");
     /**
      * ... Then all the actual data fields are added. 
      */
     Schema::table($this->table, function ($table) {
         $table->string('queue_name');
         $table->enum('status', ['deleted', 'pending', 'running']);
         $table->integer('attempts')->unsigned();
         $table->longText('payload');
         $table->bigInteger('fireon');
     });
 }
Exemplo n.º 6
0
 /**
  * 取得未删除的信息
  *
  * @return array
  * @todo 数据量多时,查找属于指定分类,推荐位,标签三个的文章时使用redis集合交集处理,避免查询消耗。
  */
 public function AllContents($search = [])
 {
     $prefix = \DB::getTablePrefix();
     $currentQuery = $this->select(['article_main.*', 'users.name'])->leftJoin('users', 'article_main.user_id', '=', 'users.id')->leftJoin('article_classify_relation', 'article_main.id', '=', 'article_classify_relation.article_id')->leftJoin('article_classify', 'article_classify_relation.classify_id', '=', 'article_classify.id')->leftJoin('article_position_relation', 'article_main.id', '=', 'article_position_relation.article_id')->leftJoin('article_tag_relation', 'article_main.id', '=', 'article_tag_relation.article_id')->orderBy('article_main.id', 'desc')->where('article_main.is_delete', self::IS_DELETE_NO)->groupBy('article_main.id')->distinct();
     if (isset($search['keyword']) && !empty($search['keyword'])) {
         $currentQuery->where('article_main.title', 'like', "%{$search['keyword']}%");
     }
     if (isset($search['username']) && !empty($search['username'])) {
         $currentQuery->where('article_main.user_id', $search['username']);
     }
     if (isset($search['classify']) && !empty($search['classify'])) {
         $currentQuery->where('article_classify_relation.classify_id', $search['classify']);
     }
     if (isset($search['position']) && !empty($search['position'])) {
         $currentQuery->where('article_position_relation.position_id', $search['position']);
     }
     if (isset($search['tag']) && !empty($search['tag'])) {
         $currentQuery->where('article_tag_relation.tag_id', $search['tag']);
     }
     if (isset($search['timeFrom'], $search['timeTo']) and !empty($search['timeFrom']) and !empty($search['timeTo'])) {
         $search['timeFrom'] = strtotime($search['timeFrom']);
         $search['timeTo'] = strtotime($search['timeTo']);
         $currentQuery->whereBetween('article_main.write_time', [$search['timeFrom'], $search['timeTo']]);
     }
     $total = count($currentQuery->get()->all());
     $currentQuery->forPage($page = Paginator::resolveCurrentPage(), $perPage = self::PAGE_NUMS);
     $result = $currentQuery->get()->all();
     return new LengthAwarePaginator($result, $total, $perPage, $page, ['path' => Paginator::resolveCurrentPath()]);
 }
Exemplo n.º 7
0
 public static function boot()
 {
     self::creating(function ($custom_field) {
         if (in_array($custom_field->db_column_name(), \Schema::getColumnListing(\DB::getTablePrefix() . CustomField::$table_name))) {
             //field already exists when making a new custom field; fail.
             return false;
         }
         \Schema::table(\DB::getTablePrefix() . \App\Models\CustomField::$table_name, function ($table) use($custom_field) {
             $table->text($custom_field->db_column_name())->nullable();
         });
     });
     self::updating(function ($custom_field) {
         if ($custom_field->isDirty("name")) {
             if (in_array($custom_field->db_column_name(), \Schema::getColumnListing(CustomField::$table_name))) {
                 //field already exists when renaming a custom field
                 return false;
             }
             return \DB::statement("UPDATE " . CustomField::$table_name . " RENAME " . self::name_to_db_name($custom_field->get_original("name")) . " TO " . $custom_field->db_column_name());
         }
         return true;
     });
     self::deleting(function ($custom_field) {
         return \DB::statement("ALTER TABLE " . CustomField::$table_name . " DROP COLUMN " . $custom_field->db_column_name());
     });
 }
Exemplo n.º 8
0
    public function getLog($offset = 0, $limit = 20)
    {
        $offset = intval($offset);
        $limit = intval($limit);
        $controller = $this;
        $data = DB::select(DB::raw('SELECT MIN(`created_at`) AS `start`,
				MAX(`created_at`) AS `end`,
				MAX(UNIX_TIMESTAMP(`created_at`)) - MIN(UNIX_TIMESTAMP(`created_at`)) + 1 `duration`,
				`success`
			FROM (
				SELECT
					`t`.`id`,
					`t`.`created_at`,
					if (@last_success = success, @group, @group:=@group+1) group_number,
						@last_success := success as success
				FROM `' . DB::getTablePrefix() . 'checks_results` AS `t`
				CROSS JOIN (
					SELECT @last_status := null, @group:=0
				) as `init_vars`
				ORDER BY `t`.`created_at`
			) q
			GROUP BY `group_number`
			ORDER BY `start` DESC
			LIMIT ' . $offset . ', ' . $limit . ''));
        $data = array_map(function ($date) use($controller) {
            return array('start' => new \Carbon\Carbon($date->start), 'end' => new \Carbon\Carbon($date->end), 'duration' => $date->duration, 'duration_locale' => $controller->minutesToHuman($date->duration), 'success' => (bool) $date->success);
        }, $data);
        return $data;
    }
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     Schema::table('role_user', function (Blueprint $table) {
         $table->dropForeign('role_user_user_id_foreign');
         $table->dropForeign('role_user_role_id_foreign');
     });
     DB::statement("ALTER TABLE " . DB::getTablePrefix() . "role_user\n\t\t\tCHANGE user_id user_id INT(11) NOT NULL,\n\t\t\tCHANGE role_id role_id INT(11) NOT NULL");
 }
Exemplo n.º 10
0
 /**
  * 取得一篇文章主表和副表的信息
  *
  * @param int $articleId 文章的ID
  * @return array
  */
 public function getContentDetailByArticleId($articleId)
 {
     $articleId = (int) $articleId;
     $this->prefix = \DB::getTablePrefix();
     $currentQuery = $this->select(\DB::raw($this->prefix . 'article_main.*, ' . $this->prefix . 'article_detail.content, group_concat(DISTINCT ' . $this->prefix . 'article_classify.name) as classnames, group_concat(DISTINCT ' . $this->prefix . 'article_tags.name) as tagsnames'))->leftJoin('article_detail', 'article_main.id', '=', 'article_detail.article_id')->leftJoin('article_classify_relation', 'article_classify_relation.article_id', '=', 'article_main.id')->leftJoin('article_classify', 'article_classify_relation.classify_id', '=', 'article_classify.id')->leftJoin('article_tag_relation', 'article_tag_relation.article_id', '=', 'article_main.id')->leftJoin('article_tags', 'article_tag_relation.tag_id', '=', 'article_tags.id')->where('article_main.is_delete', self::IS_DELETE_NO)->where('article_main.status', self::STATUS_YES)->where('article_main.id', $articleId)->first();
     $info = $currentQuery->toArray();
     return $info;
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     $prefix = DB::getTablePrefix();
     DB::statement('ALTER TABLE ' . $prefix . 'licenses MODIFY order_number varchar(50) null');
     DB::statement('ALTER TABLE ' . $prefix . 'licenses MODIFY notes varchar(255) null');
     DB::statement('ALTER TABLE ' . $prefix . 'licenses MODIFY license_name varchar(100) null');
     DB::statement('ALTER TABLE ' . $prefix . 'licenses MODIFY license_email varchar(120) null');
 }
Exemplo n.º 12
0
 public function run()
 {
     $sql = 'insert into ' . DB::getTablePrefix() . 'roles (role, role_name) values (?, ?)';
     DB::insert($sql, array('admin', 'Админ'));
     DB::insert($sql, array('moderator', 'Модератор'));
     DB::insert($sql, array('user', 'Пользователь'));
     DB::insert($sql, array('messageSender', 'Отправитель сообщений'));
     DB::insert($sql, array('messageSubscriber', 'Подписчик на получение сообщений'));
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     DB::statement('ALTER TABLE ' . DB::getTablePrefix() . 'asset_logs MODIFY column asset_type varchar(100) null');
     DB::statement('ALTER TABLE ' . DB::getTablePrefix() . 'asset_logs MODIFY column added_on timestamp default "0000-00-00 00:00:00"');
     Schema::table('asset_logs', function ($table) {
         $table->renameColumn('added_on', 'created_at');
         $table->timestamp('updated_at');
         $table->softDeletes();
     });
 }
 /**
  * Reverse the migrations.
  *
  * @return  void
  */
 public function down()
 {
     Schema::table(\Config::get('countries.table_name'), function () {
         DB::statement("ALTER TABLE " . DB::getTablePrefix() . \Config::get('countries.table_name') . " MODIFY country_code VARCHAR(3) NOT NULL DEFAULT ''");
         DB::statement("ALTER TABLE " . DB::getTablePrefix() . \Config::get('countries.table_name') . " MODIFY iso_3166_2 VARCHAR(2) NOT NULL DEFAULT ''");
         DB::statement("ALTER TABLE " . DB::getTablePrefix() . \Config::get('countries.table_name') . " MODIFY iso_3166_3 VARCHAR(3) NOT NULL DEFAULT ''");
         DB::statement("ALTER TABLE " . DB::getTablePrefix() . \Config::get('countries.table_name') . " MODIFY region_code VARCHAR(3) NOT NULL DEFAULT ''");
         DB::statement("ALTER TABLE " . DB::getTablePrefix() . \Config::get('countries.table_name') . " MODIFY sub_region_code VARCHAR(3) NOT NULL DEFAULT ''");
     });
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     //
     $prefix = DB::getTablePrefix();
     Schema::table('groups', function (Blueprint $table) {
         //
     });
     DB::statement('UPDATE ' . $prefix . 'groups SET permissions="{\\"admin\\":1,\\"users\\":1,\\"reports\\":1}" where id=1');
     DB::statement('UPDATE ' . $prefix . 'groups SET permissions="{\\"users\\":1,\\"reports\\":1}" where id=2');
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::table('settings', function (Blueprint $table) {
         $table->string('default_currency', 10)->nullable()->default(NULL);
     });
     DB::update('UPDATE `' . DB::getTablePrefix() . 'settings` SET `default_currency`="' . trans('general.currency') . '"');
     Schema::table('locations', function (Blueprint $table) {
         $table->string('currency', 10)->nullable()->default(NULL);
     });
     DB::update('UPDATE `' . DB::getTablePrefix() . 'locations` SET `currency`="' . trans('general.currency') . '"');
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     //
     // Schema::table('groups', function(Blueprint $table)
     // {
     // 	//
     // });
     DB::update('update ' . DB::getTablePrefix() . 'groups set permissions = ? where id = ?', ['{"admin":1,"users":1,"reports":1}', 1]);
     DB::update('update ' . DB::getTablePrefix() . 'groups set permissions = ? where id = ?', ['{"users":1,"reports":1}', 2]);
     // DB::statement('UPDATE '.$prefix.'groups SET permissions="{\"admin\":1,\"users\":1,\"reports\":1}" where id=1');
     // DB::statement('UPDATE '.$prefix.'groups SET permissions="{\"users\":1,\"reports\":1}" where id=2');
 }
 public static function getVehiclesLastPlace($vehicle_id = null)
 {
     $sub = Gps::select(\DB::raw('MAX(id) as id'))->groupBy('vehicle_id');
     $prefix = \DB::getTablePrefix();
     $vehicles = Gps::select('gps.id', 'vehicle_id', 'latitude', 'longitude', 'geofence')->join(\DB::raw("({$sub->toSql()}) as " . $prefix . "gps2"), 'gps.id', '=', 'gps2.id')->join('vehicles', 'vehicles.id', '=', 'gps.vehicle_id')->where('vehicles.company_id', Auth::user()['company_id']);
     if (!empty($vehicle_id)) {
         $vehicles = $vehicles->where('vehicle_id', $vehicle_id);
     }
     $vehicles = $vehicles->groupBy('vehicle_id')->get();
     $vehicles = self::getVehiclesGeofence($vehicles);
     return $vehicles;
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     //
     DB::update('update ' . DB::getTablePrefix() . 'assets SET assigned_to=NULL where assigned_to=0');
     Schema::table('status_labels', function ($table) {
         $table->boolean('deployable')->default(0);
         $table->boolean('pending')->default(0);
         $table->boolean('archived')->default(0);
         $table->text('notes')->nullable();
     });
     DB::statement('INSERT into ' . DB::getTablePrefix() . 'status_labels (user_id, name, deployable, pending, archived, notes) VALUES (1,"Pending",0,1,0,"These assets are not yet ready to be deployed, usually because of configuration or waiting on parts.")');
     DB::statement('INSERT into ' . DB::getTablePrefix() . 'status_labels (user_id, name, deployable, pending, archived, notes) VALUES (1,"Ready to Deploy",1,0,0,"These assets are ready to deploy.")');
     DB::statement('INSERT into ' . DB::getTablePrefix() . 'status_labels (user_id, name, deployable, pending, archived, notes) VALUES (1,"Archived",0,0,1,"These assets are no longer in circulation or viable.")');
 }
Exemplo n.º 20
0
 public static function fireAdvance($day, $iv = 0)
 {
     $queue = self::advanced();
     $prefix = \DB::getTablePrefix();
     $s = strtotime(date('Y-m-d H:i:s')) - strtotime(date('Y-m-d 00:00:00')) - 60;
     foreach ($queue as $k => $v) {
         if (isset($v['forcedDate'])) {
             self::setDateForced($prefix . $v['tbname'], $v['col'], $v['whereCol'], $v['whereVal'], $v['forcedDate']);
         } else {
             self::setDate($prefix . $v['tbname'], $v['col'], $v['whereCol'], $v['whereVal'], $day, -$s + $k + $iv);
         }
     }
     self::advanced('[clear]');
 }
 public function up()
 {
     Schema::create('participants', function (Blueprint $table) {
         $table->increments('id');
         $table->integer('thread_id')->unsigned()->nullable();
         $table->integer('user_id')->unsigned()->nullable();
         $table->timestamp('last_read')->nullable();
         $table->timestamps();
         $table->softDeletes();
         $table->foreign('thread_id')->references('id')->on('threads')->onDelete('cascade');
         $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
     });
     DB::statement('ALTER TABLE `' . DB::getTablePrefix() . 'participants` CHANGE COLUMN `last_read` `last_read` timestamp NULL DEFAULT NULL;');
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('activiteit', function (Blueprint $table) {
         $table->integer('id', true);
         $table->string('werkvorm', 45);
         $table->enum('organisatievorm', array('plenair', 'groepswerk', 'circuit'));
         $table->enum('werkvormsoort', array('ijsbreker', 'discussie', 'docent gecentreerd', 'werkopdracht', 'individuele werkopdracht'));
         $table->integer('tijd');
         $table->enum('intelligenties', array('VL', 'LM', 'VR', 'MR', 'LK', 'N', 'IR', 'IA'));
         $table->text('inhoud', 65535);
     });
     $table_prefix = DB::getTablePrefix();
     DB::statement("ALTER TABLE `" . $table_prefix . "activiteit` CHANGE `intelligenties` `intelligenties` SET('VL','LM','VR','MR','LK','N','IR','IA');");
 }
Exemplo n.º 23
0
 /**
  * 搜索查询取得文章列表信息
  * 
  * @return array
  */
 public function activeArticleInfoBySearch($object)
 {
     //\DB::connection()->enableQueryLog();
     if (!isset($object->sphinxResult_ArticleIds) or !is_array($object->sphinxResult_ArticleIds)) {
         return [];
     }
     $this->prefix = \DB::getTablePrefix();
     $currentQuery = $this->select(\DB::raw($this->prefix . 'article_main.*, group_concat(DISTINCT ' . $this->prefix . 'article_classify.name) as classnames, group_concat(DISTINCT ' . $this->prefix . 'article_tags.name) as tagsnames'))->leftJoin('article_classify_relation', 'article_classify_relation.article_id', '=', 'article_main.id')->leftJoin('article_classify', 'article_classify_relation.classify_id', '=', 'article_classify.id')->leftJoin('article_tag_relation', 'article_tag_relation.article_id', '=', 'article_main.id')->leftJoin('article_tags', 'article_tag_relation.tag_id', '=', 'article_tags.id')->where('article_main.is_delete', self::IS_DELETE_NO)->where('article_main.status', self::STATUS_YES)->whereIn('article_main.id', $object->sphinxResult_ArticleIds)->groupBy('article_main.id')->orderBy('article_main.id', 'desc');
     $total = $currentQuery->get()->count();
     $currentQuery->forPage($page = Paginator::resolveCurrentPage(), $perPage = 20);
     $data = $currentQuery->get()->all();
     //$queries = \DB::getQueryLog();
     //dd($total, $queries);
     return new LengthAwarePaginator($data, $total, $perPage, $page, ['path' => Paginator::resolveCurrentPath()]);
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     $prefix = DB::getTablePrefix();
     Schema::table('assets', function (Blueprint $table) {
         //
     });
     // DB::statement('UPDATE '.$prefix.'assets SET status_id="0" where status_id is null');
     // DB::statement('UPDATE '.$prefix.'assets SET purchase_cost=0 where purchase_cost is null');
     // DB::statement('UPDATE '.$prefix.'models SET eol=0 where eol is null');
     // DB::statement('UPDATE '.$prefix.'users SET location_id=0 where location_id is null');
     // DB::statement('UPDATE '.$prefix.'assets SET asset_tag=" " WHERE asset_tag is null');
     // DB::statement('UPDATE '.$prefix.'locations SET state=" " where state is null');
     // DB::statement('UPDATE '.$prefix.'models SET manufacturer_id="0" where manufacturer_id is null');
     // DB::statement('UPDATE '.$prefix.'models SET category_id="0" where category_id is null');
     // DB::statement('ALTER TABLE '.$prefix.'assets '
     //     . 'MODIFY COLUMN name VARCHAR(255) NULL , '
     //     . 'MODIFY COLUMN asset_tag VARCHAR(255) NOT NULL , '
     //     . 'MODIFY COLUMN purchase_cost DECIMAL(13,4) NOT NULL DEFAULT "0" , '
     //     . 'MODIFY COLUMN order_number VARCHAR(255) NULL  , '
     //     . 'MODIFY COLUMN assigned_to INT(11) NULL , '
     //     . 'MODIFY COLUMN notes TEXT NULL , '
     //     . 'MODIFY COLUMN archived TINYINT(1) NOT NULL DEFAULT "0" , '
     //     . 'MODIFY COLUMN depreciate TINYINT(1) NOT NULL DEFAULT "0"');
     //
     // DB::statement('ALTER TABLE '.$prefix.'licenses '
     //     . 'MODIFY COLUMN purchase_cost DECIMAL(13,4) NULL , '
     //     . 'MODIFY COLUMN depreciate TINYINT(1) NULL DEFAULT "0"');
     //
     // DB::statement('ALTER TABLE '.$prefix.'license_seats '
     //     . 'MODIFY COLUMN assigned_to INT(11) NULL ');
     //
     // DB::statement('ALTER TABLE '.$prefix.'locations '
     //     . 'MODIFY COLUMN state VARCHAR(255) NOT NULL ,'
     //     . 'MODIFY COLUMN address2 VARCHAR(255) NULL ,'
     //     . 'MODIFY COLUMN zip VARCHAR(10) NULL ');
     //
     // DB::statement('ALTER TABLE '.$prefix.'models '
     //     . 'MODIFY COLUMN modelno VARCHAR(255) NULL , '
     //     . 'MODIFY COLUMN manufacturer_id INT(11) NOT NULL , '
     //     . 'MODIFY COLUMN category_id INT(11) NOT NULL , '
     //     . 'MODIFY COLUMN depreciation_id INT(11) NOT NULL DEFAULT "0" , '
     //     . 'MODIFY COLUMN eol INT(11) NULL DEFAULT "0"');
     //
     // DB::statement('ALTER TABLE '.$prefix.'users '
     //     . 'MODIFY COLUMN first_name VARCHAR(255) NOT NULL , '
     //     . 'MODIFY COLUMN last_name VARCHAR(255) NOT NULL , '
     //     . 'MODIFY COLUMN location_id INT(11) NOT NULL');
 }
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $tables = explode(',', $this->argument('tables'));
     $prefix = \DB::getTablePrefix();
     foreach ($tables as $table) {
         $name = 'create_' . $table . '_table';
         $fields = $this->detectColumns($prefix . $table);
         $path = $this->option('path') . '/' . $name . '.php';
         $created = $this->generator->parse($name, $fields)->make($path, null);
         if ($created) {
             $this->info("Created migration {$path}");
         } else {
             $this->error("Could not create {$path} with: {$fields}");
         }
     }
 }
 /**
  * Run the migrations.
  */
 public function up()
 {
     Schema::create('calendar_date', function (Blueprint $table) {
         $table_name = DB::getTablePrefix() . $table->getTable();
         $table->increments('id');
         $table->enum('calendar', ['@#DGREGORIAN@', '@#DJULIAN@', '@#DFRENCH R@', '@#DHEBREW@', '@#DHIJRI@', '@#DJALALI@']);
         $table->tinyInteger('day');
         $table->enum('mon', ['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC', 'TSH', 'CSH', 'KSL', 'TVT', 'SHV', 'ADR', 'ADS', 'NSN', 'IYR', 'SVN', 'TMZ', 'AAV', 'ELL', 'VEND', 'BRUM', 'FRIM', 'NIVO', 'PLUV', 'VENT', 'GERM', 'FLOR', 'PRAI', 'MESS', 'THER', 'FRUC', 'COMP', 'MUHAR', 'SAFAR', 'RABIA', 'RABIT', 'JUMAA', 'JUMAT', 'RAJAB', 'SHAAB', 'RAMAD', 'SHAWW', 'DHUAQ', 'DHUAH', 'ARVA', 'ORDIB', 'KHORD', 'TIR', 'MORDA', 'SHAHR', 'MEHR', 'ABAN', 'AZAR', 'DEY', 'BAHMA', 'ESFAN']);
         $table->tinyInteger('month');
         $table->smallInteger('year');
         $table->boolean('leap_year');
         $table->enum('extra', ['', 'old-style']);
         $table->mediumInteger('julian_day')->index();
         $table->unique(['calendar', 'year', 'month', 'day', 'extra'], $table_name . '_ix1');
     });
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     // get newly added statuses from last migration
     $statuses = DB::select('select * from ' . DB::getTablePrefix() . 'status_labels where name="Pending" OR name="Ready to Deploy"');
     foreach ($statuses as $status) {
         if ($status->name == "Pending") {
             $pending_id = array($status->id);
         } elseif ($status->name == "Ready to Deploy") {
             $rtd_id = array($status->id);
         }
     }
     // Pending
     $pendings = DB::select('select * from ' . DB::getTablePrefix() . 'assets where status_id IS NULL AND physical=1 ');
     foreach ($pendings as $pending) {
         DB::update('update ' . DB::getTablePrefix() . 'assets set status_id = ? where status_id IS NULL AND physical=1', $pending_id);
     }
     // Ready to Deploy
     $rtds = DB::select('select * from ' . DB::getTablePrefix() . 'assets where status_id = 0 AND physical=1 ');
     foreach ($rtds as $rtd) {
         //DB::update('update users set votes = 100 where name = ?', array('John'));
         DB::update('update ' . DB::getTablePrefix() . 'assets set status_id = ? where status_id = 0 AND physical=1', $rtd_id);
     }
 }
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('posts', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('post_author', 36)->default('');
            $table->unsignedInteger('post_date')->default(0);
            $table->string('post_type', 20)->default('post');
            $table->string('post_status', 20)->default('publish');
            $table->text('post_title');
            $table->text('post_excerpt');
            $table->longText('post_content');
            $table->string('post_name', 200)->default('');
            $table->string('post_avatar', 255)->default('');
            $table->unsignedInteger('created_at');
            $table->unsignedInteger('updated_at');
            $table->unsignedInteger('deleted_at')->nullable();
        });
        // create trigger
        DB::unprepared('
CREATE TRIGGER tr_set_post_date BEFORE INSERT ON ' . DB::getTablePrefix() . 'posts FOR EACH ROW
IF NEW.post_date IS NULL OR NEW.post_date = 0 THEN
    SET NEW.post_date = UNIX_TIMESTAMP();
END IF');
    }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     //
     DB::statement('ALTER TABLE ' . DB::getTablePrefix() . 'licenses MODIFY column purchase_date date NULL');
 }
Exemplo n.º 30
0
 /**
  * 用于自动删除脏数据
  */
 public function clearDirtyTagRelationData()
 {
     $prefix = \DB::getTablePrefix();
     $whereRaw = "article_id in (select id from `{$prefix}article_main` where is_delete=" . ContentModel::IS_DELETE_YES . ")";
     return $this->whereRaw($whereRaw)->delete();
 }