Skip to content

Instantly share code, notes, and snippets.

@unknowntpo
Last active September 2, 2022 03:22
Show Gist options
  • Save unknowntpo/6834a47b7ef31e4fe1ac2565a9ca76ab to your computer and use it in GitHub Desktop.
Save unknowntpo/6834a47b7ef31e4fe1ac2565a9ca76ab to your computer and use it in GitHub Desktop.
db_version_control.no-change
temp_id temp_c0 temp_username temp_version
4 old2 Eric 2
-- no change
with no_change as (
select * from join_table
where temp_id is not null and data_id is not null
)
-- set is_deleted to true, username to modifier for deleted data
update temp set username = 'Kevin'
where id in (select temp_id from no_change);
-- see which data is unchanged
with no_change as (
select * from join_table
where temp_id is not null and data_id is not null
) select temp_id, temp_c0, temp_username, temp_version from no_change;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment