Skip to content

Breaking changes since file IDs were removed #3

Closed

Description

@BytewaveMLP

I recently removed file IDs from all routes, favoring owner IDs instead. As a result, you will need to use the following two snippets of code to migrate your database schema. Run the following in order, the first being PHP and the second SQL.

<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);

require __DIR__ . '/../vendor/autoload.php';

use \Sleeti\Models\User;
use \Sleeti\Models\File;

$settings = json_decode(file_get_contents(__DIR__ . '/../config/config.json'), true);

$capsule = new \Illuminate\Database\Capsule\Manager;
$capsule->addConnection($settings['db'] ?? []);
$capsule->setAsGlobal();
$capsule->bootEloquent();

$files = File::all();

foreach ($files as $file) {
	$file->filename = $file->id . ($file->filename !== null ? '-' . $file->filename : '') . ($file->ext !== null ? '.' . $file->ext : '');
	$file->save();
}
ALTER TABLE `uploaded_files`
  DROP `ext`;

Activity

  1. BytewaveMLP commented on Jun 5, 2017

    @BytewaveMLP
    OwnerAuthor

    It's been almost a year. If anyone still needs this, they can find it in the closed issues I guess. :>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions