Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaking changes since file IDs were removed #3

Closed
BytewaveMLP opened this issue Nov 12, 2016 · 1 comment
Closed

Breaking changes since file IDs were removed #3

BytewaveMLP opened this issue Nov 12, 2016 · 1 comment
Labels

Comments

@BytewaveMLP
Copy link
Owner

@BytewaveMLP BytewaveMLP commented Nov 12, 2016

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`;
@BytewaveMLP
Copy link
Owner Author

@BytewaveMLP BytewaveMLP commented Jun 5, 2017

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

@BytewaveMLP BytewaveMLP closed this Jun 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant