Open Bug 1697730 Opened 3 years ago Updated 3 years ago

Use UPDATE statement to update the DEFAULT values in ALTER statement in migrations

Categories

(Core :: Storage: Cache API, defect, P3)

defect

Tracking

()

People

(Reporter: tt, Unassigned)

References

Details

See analyze in https://bugzilla.mozilla.org/show_bug.cgi?id=1687685#c15 and discussion/more detail in https://phabricator.services.mozilla.com/D107237.

We might want to add UPDATE statements for the other old ALTER statements which set a DEFAULT value.
For instance,

nsresult MigrateFrom23To24(mozIStorageConnection& aConn, bool& aRewriteSchema) {
  MOZ_ASSERT(!NS_IsMainThread());

  // Add the request_url_fragment column.
  CACHE_TRY(aConn.ExecuteSimpleSQL(
      "ALTER TABLE entries "
      "ADD COLUMN request_url_fragment TEXT NOT NULL DEFAULT ''"_ns));

+  CACHE_TRY(aConn.ExecuteSimpleSQL(
+      "UPDATE entries Set request_url_fragment = '';"_ns));
+
  CACHE_TRY(aConn.SetSchemaVersion(24));

We also need to check what the value is after the schema rewrite for those DEFAULT values in ALTER statements. If the behavior is undefined or unexpected, then we might need to have another upgrade to fix them.

Severity: -- → S3
You need to log in before you can comment on or make changes to this bug.