diff --git a/backend/internal/service/import_service.go b/backend/internal/service/import_service.go index 1c0ec7cf..278c0b15 100644 --- a/backend/internal/service/import_service.go +++ b/backend/internal/service/import_service.go @@ -61,7 +61,7 @@ func (s *ImportService) ImportFromZip(ctx context.Context, r *zip.Reader) error // ImportDatabase only imports the database data from the given DatabaseExport struct. func (s *ImportService) ImportDatabase(dbData DatabaseExport) error { - err := s.resetSchema(dbData.Version, dbData.Provider) + err := s.resetSchema(dbData.Version) if err != nil { return err } @@ -144,7 +144,7 @@ func (s *ImportService) importUploads(ctx context.Context, files []*zip.File) er } // resetSchema drops the existing schema and migrates to the target version -func (s *ImportService) resetSchema(targetVersion uint, exportDbProvider string) error { +func (s *ImportService) resetSchema(targetVersion uint) error { sqlDb, err := s.db.DB() if err != nil { return fmt.Errorf("failed to get sql.DB: %w", err) @@ -155,11 +155,19 @@ func (s *ImportService) resetSchema(targetVersion uint, exportDbProvider string) return fmt.Errorf("failed to get migrate instance: %w", err) } + if s.db.Name() == "sqlite" { + s.db.Exec("PRAGMA foreign_keys = OFF;") + } + err = m.Drop() if err != nil { return fmt.Errorf("failed to drop existing schema: %w", err) } + if s.db.Name() == "sqlite" { + defer s.db.Exec("PRAGMA foreign_keys = ON;") + } + // Needs to be called again to re-create the schema_migrations table m, err = utils.GetEmbeddedMigrateInstance(sqlDb) if err != nil { diff --git a/tests/resources/export/database.json b/tests/resources/export/database.json index 1461420a..940ad1de 100644 --- a/tests/resources/export/database.json +++ b/tests/resources/export/database.json @@ -1,6 +1,6 @@ { "provider": "sqlite", - "version": 20251117141000, + "version": 20251219000000, "tableOrder": ["users", "user_groups", "oidc_clients"], "tables": { "api_keys": [ @@ -63,6 +63,7 @@ "dark_image_type": null, "id": "3654a746-35d4-4321-ac61-0bdcff2b4055", "image_type": "png", + "is_group_restricted": false, "is_public": false, "launch_url": "https://nextcloud.local", "logout_callback_urls": "WyJodHRwOi8vbmV4dGNsb3VkL2F1dGgvbG9nb3V0L2NhbGxiYWNrIl0=", @@ -79,6 +80,7 @@ "dark_image_type": null, "id": "606c7782-f2b1-49e5-8ea9-26eb1b06d018", "image_type": null, + "is_group_restricted": true, "is_public": false, "launch_url": null, "logout_callback_urls": "bnVsbA==", @@ -95,6 +97,7 @@ "dark_image_type": null, "id": "7c21a609-96b5-4011-9900-272b8d31a9d1", "image_type": null, + "is_group_restricted": true, "is_public": false, "launch_url": null, "logout_callback_urls": "WyJodHRwOi8vdGFpbHNjYWxlL2F1dGgvbG9nb3V0L2NhbGxiYWNrIl0=", @@ -111,6 +114,7 @@ "dark_image_type": null, "id": "c48232ff-ff65-45ed-ae96-7afa8a9b443b", "image_type": null, + "is_group_restricted": false, "is_public": false, "launch_url": null, "logout_callback_urls": "bnVsbA==", @@ -143,6 +147,7 @@ "expires_at": "2025-11-25T13:39:02Z", "id": "bf877753-4ea4-4c9c-bbbd-e198bb201cb8", "token": "HPe6k6uiDRRVuAQV", + "device_token": null, "user_id": "f4b89dc2-62fb-46bf-9f5f-c34f4eafe93e" }, { @@ -150,6 +155,7 @@ "expires_at": "2025-11-25T12:39:01Z", "id": "d3afae24-fe2d-4a98-abec-cf0b8525096a", "token": "YCGDtftvsvYWiXd0", + "device_token": null, "user_id": "f4b89dc2-62fb-46bf-9f5f-c34f4eafe93e" }, { @@ -157,6 +163,7 @@ "expires_at": "2025-11-25T13:39:02Z", "id": "defd5164-9d9b-4228-bbce-708e33f49360", "token": "one-time-token", + "device_token": null, "user_id": "f4b89dc2-62fb-46bf-9f5f-c34f4eafe93e" } ], @@ -194,6 +201,12 @@ "usage_limit": 1 } ], + "signup_tokens_user_groups": [ + { + "signup_token_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", + "user_group_id": "c7ae7c01-28a3-4f3c-9572-1ee734ea8368" + } + ], "user_authorized_oidc_clients": [ { "client_id": "3654a746-35d4-4321-ac61-0bdcff2b4055", diff --git a/tests/specs/application-configuration.spec.ts b/tests/specs/application-configuration.spec.ts index a0a82692..3e78f406 100644 --- a/tests/specs/application-configuration.spec.ts +++ b/tests/specs/application-configuration.spec.ts @@ -127,7 +127,7 @@ test.describe('Update application images', () => { .getByLabel('Light Mode Logo') .setInputFiles('resources/images/pingvin-share-logo.png'); await page.getByLabel('Dark Mode Logo').setInputFiles('resources/images/cloud-logo.png'); - await page.getByLabel('Email Logo').setInputFiles('assets/pingvin-share-logo.png'); + await page.getByLabel('Email Logo').setInputFiles('resources/images/pingvin-share-logo.png'); await page .getByLabel('Default Profile Picture') .setInputFiles('resources/images/pingvin-share-logo.png'); @@ -158,7 +158,7 @@ test.describe('Update application images', () => { test('should only allow png/jpeg for email logo', async ({ page }) => { const emailLogoInput = page.getByLabel('Email Logo'); - await emailLogoInput.setInputFiles('assets/cloud-logo.svg'); + await emailLogoInput.setInputFiles('resources/images/cloud-logo.svg'); await page.getByRole('button', { name: 'Save' }).last().click(); await expect(page.locator('[data-type="error"]')).toHaveText( diff --git a/tests/specs/cli.spec.ts b/tests/specs/cli.spec.ts index b7c8e1b9..e6116575 100644 --- a/tests/specs/cli.spec.ts +++ b/tests/specs/cli.spec.ts @@ -287,7 +287,6 @@ function runExportToStdout(): Buffer { '--path', '-' ]); - fs.writeFileSync('export-stdout.txt', res); return res; }