status-im/status-go

View on GitHub
appdatabase/migrations/sql/1682073779_settings_table_remove_latest_derived_path_column.up.sql

Summary

Maintainability
Test Coverage
CREATE TABLE settings_bu (
  address VARCHAR NOT NULL,
  chaos_mode BOOLEAN DEFAULT false,
  currency VARCHAR DEFAULT 'usd',
  current_network VARCHAR NOT NULL,
  custom_bootnodes BLOB,
  custom_bootnodes_enabled BLOB,
  dapps_address VARCHAR NOT NULL,
  eip1581_address VARCHAR,
  fleet VARCHAR,
  hide_home_tooltip BOOLEAN DEFAULT false,
  installation_id VARCHAR NOT NULL,
  key_uid VARCHAR NOT NULL,
  keycard_instance_uid VARCHAR,
  keycard_paired_on UNSIGNED BIGINT,
  keycard_pairing VARCHAR,
  last_updated UNSIGNED BIGINT,
  log_level VARCHAR,
  mnemonic VARCHAR,
  name VARCHAR NOT NULL,
  networks BLOB NOT NULL,
  node_config BLOB,
  notifications_enabled BOOLEAN DEFAULT false,
  photo_path BLOB NOT NULL,
  pinned_mailservers BLOB,
  preferred_name VARCHAR,
  preview_privacy BOOLEAN DEFAULT false,
  public_key VARCHAR NOT NULL,
  remember_syncing_choice BOOLEAN DEFAULT false,
  signing_phrase VARCHAR NOT NULL,
  stickers_packs_installed BLOB,
  stickers_recent_stickers BLOB,
  syncing_on_mobile_network BOOLEAN DEFAULT false,
  synthetic_id VARCHAR DEFAULT 'id' PRIMARY KEY,
  usernames BLOB,
  wallet_root_address VARCHAR NOT NULL,
  wallet_set_up_passed BOOLEAN DEFAULT false,
  wallet_visible_tokens VARCHAR,
  stickers_packs_pending BLOB,
  waku_enabled BOOLEAN DEFAULT false,
  waku_bloom_filter_mode BOOLEAN DEFAULT false,
  appearance INT NOT NULL DEFAULT 0,
  remote_push_notifications_enabled BOOLEAN DEFAULT FALSE,
  send_push_notifications BOOLEAN DEFAULT TRUE,
  push_notifications_server_enabled BOOLEAN DEFAULT FALSE,
  push_notifications_from_contacts_only BOOLEAN DEFAULT FALSE,
  push_notifications_block_mentions BOOLEAN DEFAULT FALSE,
  webview_allow_permission_requests BOOLEAN DEFAULT FALSE,
  use_mailservers BOOLEAN DEFAULT TRUE,
  link_preview_request_enabled BOOLEAN DEFAULT TRUE,
  link_previews_enabled_sites BLOB,
  profile_pictures_visibility INT NOT NULL DEFAULT 1,
  anon_metrics_should_send BOOLEAN DEFAULT false,
  messages_from_contacts_only BOOLEAN DEFAULT FALSE,
  default_sync_period INTEGER DEFAULT 777600, -- 9 days
  current_user_status BLOB,
  send_status_updates BOOLEAN DEFAULT TRUE,
  gif_recents BLOB,
  gif_favorites BLOB,
  opensea_enabled BOOLEAN DEFAULT false,
  profile_pictures_show_to INT NOT NULL DEFAULT 1,
  telemetry_server_url VARCHAR NOT NULL DEFAULT "",
  backup_enabled BOOLEAN DEFAULT TRUE,
  last_backup INT NOT NULL DEFAULT 0,
  backup_fetched BOOLEAN DEFAULT FALSE,
  auto_message_enabled BOOLEAN DEFAULT FALSE,
  gif_api_key TEXT NOT NULL DEFAULT "",
  display_name TEXT NOT NULL DEFAULT "",
  test_networks_enabled BOOLEAN NOT NULL DEFAULT FALSE,
  mutual_contact_enabled BOOLEAN DEFAULT FALSE,
  bio TEXT NOT NULL DEFAULT "",
  mnemonic_removed BOOLEAN NOT NULL DEFAULT FALSE
) WITHOUT ROWID;

INSERT INTO settings_bu SELECT
  address,
  chaos_mode,
  currency,
  current_network,
  custom_bootnodes,
  custom_bootnodes_enabled,
  dapps_address,
  eip1581_address,
  fleet,
  hide_home_tooltip,
  installation_id,
  key_uid,
  keycard_instance_uid,
  keycard_paired_on,
  keycard_pairing,
  last_updated UNSIGNED,
  log_level,
  mnemonic,
  name,
  networks,
  node_config,
  notifications_enabled,
  photo_path,
  pinned_mailservers,
  preferred_name,
  preview_privacy,
  public_key,
  remember_syncing_choice,
  signing_phrase,
  stickers_packs_installed,
  stickers_recent_stickers,
  syncing_on_mobile_network,
  synthetic_id,
  usernames,
  wallet_root_address,
  wallet_set_up_passed,
  wallet_visible_tokens,
  stickers_packs_pending,
  waku_enabled,
  waku_bloom_filter_mode,
  appearance,
  remote_push_notifications_enabled,
  send_push_notifications,
  push_notifications_server_enabled,
  push_notifications_from_contacts_only,
  push_notifications_block_mentions,
  webview_allow_permission_requests,
  use_mailservers,
  link_preview_request_enabled,
  link_previews_enabled_sites,
  profile_pictures_visibility,
  anon_metrics_should_send,
  messages_from_contacts_only,
  default_sync_period,
  current_user_status,
  send_status_updates,
  gif_recents,
  gif_favorites,
  opensea_enabled,
  profile_pictures_show_to,
  telemetry_server_url,
  backup_enabled,
  last_backup,
  backup_fetched,
  auto_message_enabled,
  gif_api_key,
  display_name,
  test_networks_enabled,
  mutual_contact_enabled,
  bio,
  mnemonic_removed
FROM settings;

DROP TABLE settings;

ALTER TABLE settings_bu RENAME TO settings;

UPDATE settings SET default_sync_period = 777600; -- 9 days