GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Test the pre-migration read with a full-schema row again · projectsend/projectsend@c208867

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • tests/Feature/Platform
    • ExternalStorageSettingsTest.php
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎tests/Feature/Platform/ExternalStorageSettingsTest.php‎

Copy file name to clipboardExpand all lines: tests/Feature/Platform/ExternalStorageSettingsTest.php
+48-4Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
expect(config("filesystems.disks.{$location->disk}.secret"))->toBe('super-secret-access-key');
9191
});
9292

93-
test('apply() is a no-op when not fully configured', function () {
93+
test('apply() leaves a bucket that is not fully configured unregistered', function () {
9494
$location = bucketLocation();
9595
DB::table('storage_locations')->where('id', $location->id)->update(['secret' => null]);
9696

@@ -158,7 +158,7 @@
158158
->and(resolvedDiskFor(User::factory()->client()->create()))->toBe($location->disk);
159159
});
160160

161-
test('a real upload lands on the external disk once the backend is active, and local uploads made before activation are unaffected', function () {
161+
test('a real upload lands on the bucket once it is the default, and local uploads made before are unaffected', function () {
162162
Storage::fake('files');
163163

164164
uploadImageFile($this->admin);
@@ -178,8 +178,8 @@
178178
->and($externalFile->disk)->toBe($location->disk);
179179
Storage::disk($location->disk)->assertExists($externalFile->path);
180180

181-
// The first file, uploaded before activation, still resolves to local
182-
// disk and is unaffected by the backend switch (no migration tool).
181+
// The first file, uploaded before the switch, still resolves to local
182+
// disk and is unaffected by it (no migration tool).
183183
Storage::disk('files')->assertExists($localFile->refresh()->path);
184184
expect($localFile->disk)->toBe('files');
185185
});
@@ -254,6 +254,27 @@
254254
expect(resolvedDiskFor($this->admin))->toBe('files_external');
255255
});
256256

257+
test('before the storage locations migration, the old external storage row is read as before', function () {
258+
// Boot happens before `artisan migrate`, so every upgrade passes
259+
// through a window where this code meets the previous schema. Files
260+
// already in the bucket must keep resolving, and new uploads must not
261+
// quietly start landing on the local disk.
262+
withoutStorageLocationsTable();
263+
ExternalStorageSettings::query()->create([
264+
'active' => true,
265+
'key' => 'AKIAEXAMPLE',
266+
'secret' => 'shh',
267+
'bucket' => 'my-bucket',
268+
'region' => 'us-east-1',
269+
]);
270+
271+
applyStorage();
272+
273+
expect(config('filesystems.disks.files_external.bucket'))->toBe('my-bucket')
274+
->and(config('filesystems.disks.files_external.secret'))->toBe('shh')
275+
->and(resolvedDiskFor($this->admin))->toBe('files_external');
276+
});
277+
257278
test('the migration carries the old row over on its own disk name, as the default only if it was switched on', function (bool $active) {
258279
resetStorageLocationsMigration(function () use ($active): void {
259280
ExternalStorageSettings::query()->create([
@@ -280,6 +301,29 @@
280301
->and($local->is_default)->toBe(! $active);
281302
})->with(['switched on' => true, 'switched off' => false]);
282303

304+
test('the migration does not leave the pre-migration picture in the boot cache', function () {
305+
// The real upgrade: the `migrate` process boots first, against the old
306+
// schema, and caches what it sees there. Nobody flushes afterwards.
307+
withoutStorageLocationsTable();
308+
ExternalStorageSettings::query()->create([
309+
'active' => false,
310+
'key' => 'AKIAEXAMPLE',
311+
'secret' => 'shh',
312+
'bucket' => 'my-bucket',
313+
'region' => 'us-east-1',
314+
]);
315+
app(ExternalStorageConfigApplier::class)->apply();
316+
317+
$migration = require database_path('migrations/2026_10_09_090000_create_storage_locations_tables.php');
318+
$migration->up();
319+
320+
// The next process boots on whatever the cache now holds.
321+
app(ExternalStorageConfigApplier::class)->apply();
322+
323+
expect(array_column(app(ExternalStorageConfigApplier::class)->externalLocations(), 'disk'))->toContain('files_external')
324+
->and(config('filesystems.disks.files_external.bucket'))->toBe('my-bucket');
325+
});
326+
283327
// ---- Where a client's uploads go ---------------------------------------
284328

285329
test('a client uploads to their first location, or the one they asked for if it is theirs', function () {

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.