Commit graph

138 commits

Author SHA1 Message Date
Prem Palanisamy
f05b55add7 test: use project API key for platform migration E2E; bump migration lock 2026-05-14 06:15:55 +01:00
Prem Palanisamy
bddde5f298 Merge remote-tracking branch 'origin/1.9.x' into feat-platform-db-access
# Conflicts:
#	app/controllers/api/migrations.php
#	composer.json
#	composer.lock
#	src/Appwrite/Platform/Workers/Migrations.php
2026-05-13 16:36:39 +01:00
premtsd-code
2e9841c9c2
Merge branch '1.9.x' into feat/skip-duplicates 2026-05-06 23:35:25 +05:30
Matej Bačo
ec927104fe
Merge pull request #12221 from appwrite/fix-variables-api-feature-parity
Feat: Variables API feature parity
2026-05-06 11:27:32 +02:00
Prem Palanisamy
f9c5f41a1a Merge remote-tracking branch 'origin/1.9.x' into feat/skip-duplicates
# Conflicts:
#	composer.lock
2026-05-06 09:53:13 +01:00
Matej Bačo
1ccf058c14 Fix failing tests 2026-05-06 10:19:30 +02:00
Prem Palanisamy
e63f9fd6a5 tests: send non-empty parent row data in TwoWayRecreate test
server-ce 1.9.x's tablesdb POST /rows tightened input validation: the
modular Documents/Create.php rejects `data => []` with a 400
"missing data" because TablesDB's Rows/Create.php inherits the strict
default of getSupportForEmptyDocument() = false (only DocumentsDB
overrides it to true). The test was relying on the older permissive
behavior to seed an empty parent row before the relationship cascade
links it.

Add a non-relationship `label` string column on the parents table and
populate it with `data => ['label' => 'p1']` so the POST passes the
empty-data guard. The test's actual assertion target — partner-side
pair-key dedup on DropAndRecreate — is unchanged.

Cascade fixes: testAppwriteMigrationOverwriteAttributeRecreate and
testAppwriteMigrationOverwriteSameSpecRecreate were failing in the
retry pass because TwoWayRecreate's bail at L1616 left source/dest
state uncleaned. Once TwoWayRecreate completes, those tests see a
clean project again.

Caught in CI run 25419479164 / job 74562934987 on the MongoDB
(dedicated) Migrations matrix.
2026-05-06 08:40:17 +01:00
ArnabChatterjee20k
bca876acaf Merge remote-tracking branch 'origin/1.9.x' into big-int 2026-05-05 18:55:11 +05:30
Prem Palanisamy
b1906e5eb9 Merge remote-tracking branch 'origin/1.9.x' into feat/skip-duplicates
# Conflicts:
#	app/controllers/api/migrations.php
#	composer.lock
2026-04-30 16:26:43 +01:00
Prem Palanisamy
d4e32af792 Migrate appwrite to OnDuplicate::Overwrite ('overwrite')
Maintainer review on utopia-php/migration#171 renamed
OnDuplicate::Upsert -> OnDuplicate::Overwrite (value 'upsert' ->
'overwrite') to align with Appwrite terms (skip / overwrite / fail).
Applying the cross-repo ripple here:

- app/controllers/api/migrations.php: 3 endpoint param descriptions
  updated ('upsert' -> 'overwrite' in the help text). The validator
  still uses OnDuplicate::values() so it auto-picks up the new value.
- tests/e2e/Services/Migrations/MigrationsBase.php: all
  'onDuplicate' => 'upsert' -> 'overwrite'; method names
  testAppwriteMigrationUpsert* -> testAppwriteMigrationOverwrite*;
  comments / assertion messages / local var names switched.
- Left untouched: utopia's upsertDocuments operation, transaction
  TransactionState 'upsert' action, Operation validator — those refer
  to the database-level upsert primitive, not the OnDuplicate enum.

composer.lock: utopia-php/migration 7d71505 -> b8ae7bc.
2026-04-30 11:45:33 +01:00
Chirag Aggarwal
9d7df34590 fix: clean up php 8.5 runtime deprecations 2026-04-29 14:47:05 +05:30
Prem Palanisamy
443f5cfb0e tests: switch attribute-recreate test to non-SDK change
After dropping createdAt from resolveSchemaAction, source-side recreate
no longer routes through DropAndRecreate via the outer decision. The
inner fallthrough still drops+recreates when the spec diff is a non-SDK
change, so this test now toggles 'array' (a non-SDK field) on recreate
to actually exercise the drop+recreate path it pins.

Also clarifies the two-way recreate test's docblock — with createdAt
gone and identical spec on recreate, it exercises spec-match + pair-key
dedup (both tolerate paths) rather than parent-side drop. End-state
assertions unchanged.
2026-04-28 05:55:38 +01:00
Prem Palanisamy
b6afef6efc tests: trim verbose multi-paragraph docblocks to one-liners 2026-04-28 04:44:19 +01:00
Prem Palanisamy
3fba7afd2e tests: pin spec-match guard + bump migration to c8d1789
testAppwriteMigrationUpsertSameSpecRecreateTolerates exercises the new
spec-match guard added in utopia-php/migration c8d1789. Source drops +
recreates a column with the EXACT same spec as before; createdAt
advances but specs match → action is forced to Tolerate. Asserts dest
column's $createdAt stays at first-migration value (proving Tolerate,
not DropAndRecreate). Row pass under Upsert still propagates source's
new row value.

Companion to testAppwriteMigrationUpsertAttributeRecreateDropsAndRecreates
which exercises the spec-DIFFERS path: same precondition (drop + recreate),
different outcome (DropAndRecreate vs Tolerate) gated on spec equality.

composer.lock: utopia-php/migration 24fd23b -> c8d1789 (spec-match guard).
2026-04-28 04:16:51 +01:00
Prem Palanisamy
b03c901fa7 tests: cover one-way DropAndRecreate + attribute-recreate scenarios
Two coverage gaps closed:

- testAppwriteMigrationUpsertOneWayRelationshipDropAndRecreate exercises
  the path that updateRelationshipInPlace gates off: one-way + onDelete
  change → returns false → falls through to DropAndRecreate via
  deleteRelationship. Coverage was lost when
  testAppwriteMigrationUpsertUpdatesRelationshipOnDeleteInPlace was
  converted to two-way to actually hit the in-place path.

- testAppwriteMigrationUpsertAttributeRecreateDropsAndRecreates pins
  the createdAt-different leaf path: source drops + recreates the
  attribute (createdAt advances), re-migration must DropAndRecreate
  on dest and re-flow the row data through the row pass. Companion to
  testAppwriteMigrationUpsertUpdatesAttributeInPlace which covers the
  same-createdAt + newer-updatedAt path.

Migration package already at 09c1b21 (the maintainability commit) from
the previous lock bump — no further composer.lock change needed.
2026-04-27 17:40:23 +01:00
Prem Palanisamy
c80c747e48 tests: pin two-way recreate partner-side dedup + bump migration
testAppwriteMigrationUpsertTwoWayRecreateSkipsPartnerSide exercises
the DropAndRecreate path on a two-way relationship that the partner-
side pair-key dedup guards. Source recreates the relationship between
runs, forcing parent-side createdAt diff. Test asserts the migration
completes cleanly and partner-table rows survive — without dedup, the
partner pass re-fires DropAndRecreate and destroys those rows.

composer.lock: utopia-php/migration c76de9a -> c13e77d (partner-side
pair-key dedup restored).
2026-04-27 14:45:39 +01:00
Prem Palanisamy
dfde1be035 tests: cover two-way relationship onDelete in-place update + bump migration
The previous version of this test created a one-way relationship,
which falls through to DropAndRecreate (one-way + onDelete change is
gated off in updateRelationshipInPlace because utopia's
updateRelationship partner-cascade throws on one-way). It never
exercised the in-place path it was named for.

Converted to two-way (parents.kids ↔ children.parent), and asserted
both parent- and partner-side onDelete on dest. Partner-side
assertion is the regression guard for the partner-meta refresh that
was missing from updateRelationshipInPlace.

composer.lock: utopia-php/migration a36d95f -> c76de9a (partner-side
onDelete sync fix).
2026-04-27 14:03:02 +01:00
Prem Palanisamy
5f8a32798d tests: SDK-aligned UpdateInPlace coverage + bump migration to a36d95f
Three new e2e tests in MigrationsBase covering the schema reconciliation
paths added in utopia-php/migration:

- testAppwriteMigrationUpsertUpdatesAttributeInPlace: PATCH source
  required/default (SDK-reachable), assert dest reflects change and the
  pre-existing row's column data is preserved (drop+recreate would have
  wiped it).
- testAppwriteMigrationSkipPreservesAttributeDrift: leaf-level analog
  of the existing container-drift Skip test — guards Skip from ever
  consulting timestamps.
- testAppwriteMigrationUpsertUpdatesRelationshipOnDeleteInPlace: PATCH
  source onDelete cascade->restrict (SDK-reachable), assert dest
  reflects change and structural fields (relationType, twoWay) untouched.

composer.lock: utopia-php/migration 6e6f825 -> a36d95f (mechanical
helpers replacement, parseTimestamp dedup, match dispatch, comment trim).
2026-04-27 12:32:37 +01:00
Prem Palanisamy
478a2a6e86 tests: Upsert drops orphan columns / Skip preserves them
testAppwriteMigrationUpsertDropsOrphanColumn: adds a column directly on
destination (simulating post-rename orphan or dest-only drift), runs
Upsert, asserts the orphan is dropped and source-declared column
survives. Covers the per-table orphan cleanup fired inside
createRecord before rows land.

testAppwriteMigrationSkipKeepsOrphanColumn: same setup, Skip mode.
Asserts the orphan survives, proving the cleanup is correctly gated
to Upsert only.
2026-04-24 07:30:29 +01:00
premtsd-code
07307c6131
Merge branch '1.9.x' into feat/skip-duplicates 2026-04-23 11:22:05 +05:30
Prem Palanisamy
0134832fb6 tests: cover Upsert UpdateInPlace for database/table + Skip preserves dest drift
Two new E2E tests exercising the schema-tolerance UpdateInPlace path
added in utopia-php/migration's DestinationAppwrite.

testAppwriteMigrationUpsertUpdatesContainerMetadata (positive):
- Fresh migration copies source database + table + column + row to dest.
- Mutates source database name (PUT /databases/:id) and table
  name/permissions/rowSecurity/enabled (PUT /tablesdb/:db/tables/:id).
- One-second sleep before mutation ensures source's $updatedAt is
  strictly greater than dest's at second granularity (strtotime
  comparison).
- Upsert re-migration asserts:
  - 'completed' status.
  - dest database name matches source's new name.
  - dest table name / enabled / rowSecurity match source's new values.
  - child row's 'name' attribute is untouched — UpdateInPlace only
    rewrites container metadata, not rows.

testAppwriteMigrationSkipPreservesContainerDrift (negative):
- Fresh migration, then mutate BOTH dest (simulating ops tightening
  permissions post-migration) and source (divergence).
- Skip re-migration asserts dest kept its tightened values — Skip's
  strict "don't touch" contract protects dev→prod cutover workflows
  from accidentally wiping ops-side drift on schema re-sync.

Both tests use performMigrationSync for strict 'completed' assertions.
Runtime ~18s combined. Existing testAppwriteMigrationRowsOnDuplicate
and testAppwriteMigrationReRunIsIdempotent regression-tested locally.
2026-04-23 06:22:26 +01:00
Prem Palanisamy
715bd40b4a Tighten A→A re-migration tests against utopia-php/migration schema tolerance
utopia-php/migration's DestinationAppwrite now handles schema tolerance on
re-migration (PR #171 on feat/skip-duplicates): it pre-checks destination
`_metadata` for each database / table / column / index and tolerates in
Skip/Upsert mode. Re-runs no longer produce schema-level errors, so the
E2E tests can drop the status-tolerant workaround and assert strict
'completed' outcomes.

Changes:

- composer.json: pin utopia-php/migration to dev-feat/skip-duplicates (aliased
  to 1.9.99 for stability resolution). Will be replaced with a fixed 1.10.0
  tag once the migration PR lands.

- testAppwriteMigrationRowsOnDuplicate: replace the tolerant
  runMigrationAssertingRowSuccess helper with performMigrationSync on the
  Skip and Upsert re-runs. Asserts 'completed' status on every run,
  destination row content matches the expected value per mode (Mutated
  preserved on Skip, Original restored on Upsert). Helper method removed.

- testAppwriteMigrationReRunIsIdempotent (new): seeds two rows on source,
  runs the migration three times back-to-back (fresh, Skip re-run, Upsert
  re-run) against unchanged source data, asserts strict 'completed' on every
  run and row content is stable across all three. Exercises the
  schema-tolerance path end-to-end: every database/table/column on
  destination already exists with a matching spec, so DestinationAppwrite's
  pre-check returns Tolerate for every resource.
2026-04-22 16:38:32 +01:00
Chirag Aggarwal
b2d24080b9 Stabilize database e2e CI retries 2026-04-22 18:08:45 +05:30
Prem Palanisamy
d0603c4d28 tests: add Appwrite->Appwrite row onDuplicate test with tolerant poller 2026-04-20 16:38:59 +01:00
Prem Palanisamy
fc6bd7232e tests: add Appwrite->Appwrite row migration onDuplicate test 2026-04-20 14:50:57 +01:00
Prem Palanisamy
e878b0b403 tests: cover onDuplicate on JSON import endpoint + column readiness wait 2026-04-20 14:43:45 +01:00
Prem Palanisamy
8fa28257be Migrations: replace overwrite/skip with onDuplicate enum string, bump database to 5.3.22 2026-04-20 10:28:05 +01:00
Prem Palanisamy
c5fe71684a Add E2E tests for CSV import overwrite/skip flags
Three new test methods in MigrationsBase, following the existing
testCreateCSVImport setup pattern:

- testCreateCSVImportSkipDuplicates
  Seeds documents.csv, mutates one row, re-imports with skip=true.
  Asserts the mutated row keeps its mutated value (not overwritten
  by the CSV's original value) and the row count stays at 100.

- testCreateCSVImportOverwrite
  Seeds documents.csv, mutates one row, re-imports with overwrite=true.
  Asserts the mutated row is restored to the CSV's original value
  (proving upsertDocuments actually replaced the row) and the row
  count stays at 100.

- testCreateCSVImportDefaultFailsOnDuplicate
  Regression guard: re-imports documents.csv with no flags. Asserts
  the migration goes to status=failed with errors populated, proving
  the default duplicate-throws behavior is preserved.

All three share a prepareCsvImportFixture() helper that sets up
database + table (name, age columns) + bucket + documents.csv
upload. Returns the known first-row id + original name/age so tests
can mutate and assert on a predictable row.

Reuses the existing documents.csv fixture (100 rows with \$id as the
first column). No new fixture files needed.
2026-04-15 14:23:02 +01:00
ArnabChatterjee20k
229ab28427 Merge remote-tracking branch 'origin/1.9.x' into big-int 2026-04-09 11:15:59 +05:30
Chirag Aggarwal
983adf3ffd Fix analyze regressions in PHPStan cleanup 2026-04-01 11:00:26 +05:30
Chirag Aggarwal
f2ea0b9b48 Fix PHPStan baseline cleanup issues (part 2) 2026-04-01 10:20:20 +05:30
ArnabChatterjee20k
3c20ea47f5 Merge remote-tracking branch 'origin/1.9.x' into big-int 2026-04-01 09:51:07 +05:30
Prem Palanisamy
5d1009b324 fix: correct resourceType routing, schemaless validation, and E2E tests for migrations
- Add getDatabaseResourceType() helper to map database types to resource constants
- Use database-specific resourceType for CSV/JSON import/export instead of hardcoded TYPE_DATABASE
- Skip attribute validation for schemaless databases (DocumentsDB/VectorsDB) in exports
- Parse JSON export queries in migration worker
- Restore MigrationsBase from 1.9.x and append VectorsDB/DocumentsDB E2E tests
2026-03-31 12:35:18 +01:00
ArnabChatterjee20k
2fb54e0846 Add BigInt support with dedicated bigintRange format and update related logic 2026-03-30 18:59:24 +05:30
ArnabChatterjee20k
e5d818ba44 updated 2026-03-30 17:38:24 +05:30
ArnabChatterjee20k
a9ed74c6a8 added tests to migration 2026-03-30 16:11:42 +05:30
Prem Palanisamy
ee1ca5ace6 fix: remove email verification from vectorsdb export test (tested separately) 2026-03-26 11:36:50 +00:00
Prem Palanisamy
b36472f0da add E2E tests for vectorsdb and documentsdb JSON import/export 2026-03-26 11:24:14 +00:00
Darshan
098f7aa3e3 update: comment. 2026-03-26 06:43:49 +00:00
Darshan
f8c8c17757 add: tests;
fix: tests.
2026-03-26 06:43:49 +00:00
Jake Barnby
8666bf1325
Merge branch '1.9.x' into revert-11585-revert-11402-sync-mongodb 2026-03-24 03:03:02 +00:00
Prem Palanisamy
e2f2ce3da8 Change console-key endpoint from GET to POST 2026-03-23 13:46:58 +00:00
Prem Palanisamy
374e1f8782 Add unit tests for scopedProjectId and source fields in Key::decode() 2026-03-23 13:46:58 +00:00
Prem Palanisamy
4020335aac Add E2E test for platform migration 2026-03-23 13:46:58 +00:00
Matej Bačo
01142bba2c Merge branch '1.8.x' into feat-public-project-variables-api 2026-03-23 12:21:06 +01:00
ArnabChatterjee20k
c7907932e4
Revert "Revert "Documentsdb + vectordb (latest)"" 2026-03-19 20:30:42 +05:30
ArnabChatterjee20k
9917f95dfd
Revert "Documentsdb + vectordb (latest)" 2026-03-19 19:18:27 +05:30
Matej Bačo
8af0efafd4 Merge branch '1.8.x' into feat-public-project-variables-api 2026-03-19 14:17:26 +01:00
ArnabChatterjee20k
feddd77066 fixed analyze 2026-03-19 17:02:27 +05:30
Matej Bačo
564f56e0f5 Finalize tests 2026-03-18 16:12:47 +01:00