Created
August 24, 2022 20:37
-
-
Save brycesch/796d5dfbd3e42c960c3db1a7a9b227f3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'pg' | |
uri = '' | |
file = File.open('tmp/write.txt', 'w') | |
while true do | |
begin | |
conn = PG.connect( uri ) | |
conn.exec( "INSERT INTO account_deletion_tokens VALUES (1, null, null, null, null, null, NOW(), NOW());" ) do |result| | |
file.write("#{Time.now.to_i} - write success\n") | |
end | |
rescue Exception => e | |
file.write("#{Time.now.to_i} - write fail\n") | |
end | |
sleep(1) | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'pg' | |
uri = '' | |
file = File.open('tmp/read.txt', 'w') | |
while true do | |
begin | |
conn = PG.connect( uri ) | |
conn.exec( "SELECT * FROM pg_stat_activity limit 1" ) do |result| | |
file.write("#{Time.now.to_i} - read success\n") | |
end | |
rescue Exception => e | |
puts e | |
file.write("#{Time.now.to_i} - read fail \n") | |
end | |
sleep(1) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create EXTENSION postgres_fdw; | |
DROP SCHEMA fgapi; | |
CREATE SCHEMA fgapi; | |
DROP SERVER temp_fg; | |
CREATE SERVER temp_fg | |
FOREIGN DATA WRAPPER postgres_fdw | |
OPTIONS (host HOST, dbname 'fg', port '5432'); | |
DROP USER MAPPING for root server temp_fg; | |
CREATE USER MAPPING FOR root | |
SERVER temp_fg | |
OPTIONS (user 'fgapi', password 'PASSWORD'); | |
DROP FOREIGN TABLE fgapi.temp_uploads; | |
CREATE FOREIGN TABLE fgapi.temp_uploads ( | |
"id" int8, | |
"asset_id" varchar(255), | |
"content_type" varchar(255), | |
"object_key" text, | |
"created_at" timestamptz, | |
"updated_at" timestamptz, | |
"user_id" int8, | |
"ip" varchar | |
) | |
SERVER temp_fg | |
OPTIONS (schema_name 'public', table_name 'uploads'); | |
INSERT INTO public.uploads (asset_id, content_type, object_key, created_at, updated_at, user_id, ip) | |
SELECT asset_id, content_type, object_key, created_at, updated_at, user_id, ip | |
FROM fgapi.temp_uploads old | |
where not exists (select * from public.uploads where asset_id = old.asset_id) | |
order by id DESC | |
limit 1000; | |
DROP FOREIGN TABLE fgapi.temp_media_variants; | |
CREATE FOREIGN TABLE fgapi.temp_media_variants ( | |
"id" int8, | |
"asset_id" varchar(255), | |
"asset_type" varchar(255), | |
"suffix" varchar(255), | |
"created_at" timestamptz, | |
"updated_at" timestamptz, | |
"path" varchar(255), | |
"file_extension" varchar(255), | |
"metadata" json | |
) | |
SERVER temp_fg | |
OPTIONS (schema_name 'public', table_name 'media_variants'); | |
INSERT INTO public.media_variants (asset_id, asset_type, suffix, created_at, updated_at, path, file_extension, metadata) | |
SELECT asset_id, asset_type, suffix, created_at, updated_at, path, file_extension, metadata | |
FROM fgapi.temp_media_variants old | |
where not exists (select * from public.media_variants where asset_id = old.asset_id) | |
order by id DESC | |
limit 1000; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'pg' | |
uri = '' | |
file = File.open('tmp/write.txt', 'w') | |
while true do | |
begin | |
conn = PG.connect( uri ) | |
conn.exec( "INSERT INTO account_deletion_tokens VALUES (0, null, null, null, null, null, NOW(), NOW());" ) do |result| | |
file.write("#{Time.now.to_i} - write success\n") | |
end | |
rescue Exception => e | |
file.write("#{Time.now.to_i} - write fail\n") | |
end | |
sleep(1) | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment