From 50a91cd725d24d8ba39c4839a7da7a5df816137b Mon Sep 17 00:00:00 2001 From: "Daniel J. Summers" Date: Fri, 19 Aug 2022 15:37:48 -0400 Subject: [PATCH] Remove v8 migration code (and prior) --- src/PrayerTracker/App.fs | 46 +--------------- src/Publish-App.ps1 | 3 -- src/names-to-lower.sql | 110 --------------------------------------- src/search-sql.txt | 27 ---------- 4 files changed, 1 insertion(+), 185 deletions(-) delete mode 100644 src/Publish-App.ps1 delete mode 100644 src/names-to-lower.sql delete mode 100644 src/search-sql.txt diff --git a/src/PrayerTracker/App.fs b/src/PrayerTracker/App.fs index d7484a8..b78c96a 100644 --- a/src/PrayerTracker/App.fs +++ b/src/PrayerTracker/App.fs @@ -214,47 +214,6 @@ module Configure = /// The web application module App = - open System.Text - open Microsoft.Extensions.DependencyInjection - open Npgsql - open Npgsql.FSharp - open PrayerTracker.Entities - - let migratePasswords (app : IWebHost) = - task { - let config = app.Services.GetService () - use conn = new NpgsqlConnection (config.GetConnectionString "PrayerTracker") - do! conn.OpenAsync () - let! v1Users = - Sql.existingConnection conn - |> Sql.query "SELECT id, password_hash FROM pt.pt_user WHERE salt IS NULL" - |> Sql.executeAsync (fun row -> UserId (row.uuid "id"), row.string "password_hash") - for userId, oldHash in v1Users do - let pw = Convert.ToBase64String [| 254uy; yield! (Encoding.UTF8.GetBytes oldHash) |] - let! _ = - Sql.existingConnection conn - |> Sql.query "UPDATE pt.pt_user SET password_hash = @hash WHERE id = @id" - |> Sql.parameters [ "@id", Sql.uuid userId.Value; "@hash", Sql.string pw ] - |> Sql.executeNonQueryAsync - () - printfn $"Updated {v1Users.Length} users with version 1 password" - let! v2Users = - Sql.existingConnection conn - |> Sql.query "SELECT id, password_hash, salt FROM pt.pt_user WHERE salt IS NOT NULL" - |> Sql.executeAsync (fun row -> UserId (row.uuid "id"), row.string "password_hash", row.uuid "salt") - for userId, oldHash, salt in v2Users do - let pw = - Convert.ToBase64String - [| 255uy; yield! (salt.ToByteArray ()); yield! (Encoding.UTF8.GetBytes oldHash) |] - let! _ = - Sql.existingConnection conn - |> Sql.query "UPDATE pt.pt_user SET password_hash = @hash WHERE id = @id" - |> Sql.parameters [ "@id", Sql.uuid userId.Value; "@hash", Sql.string pw ] - |> Sql.executeNonQueryAsync - () - printfn $"Updated {v2Users.Length} users with version 2 password" - } |> Async.AwaitTask |> Async.RunSynchronously - open System.IO [] @@ -270,8 +229,5 @@ module App = .ConfigureLogging(Configure.logging) .Configure(System.Action Configure.app) .Build() - if args.Length > 0 then - if args[0] = "migrate-passwords" then migratePasswords app - else printfn $"Unrecognized option {args[0]}" - else app.Run () + if args.Length > 0 then printfn $"Unrecognized option {args[0]}" else app.Run () 0 diff --git a/src/Publish-App.ps1 b/src/Publish-App.ps1 deleted file mode 100644 index fd7b8bd..0000000 --- a/src/Publish-App.ps1 +++ /dev/null @@ -1,3 +0,0 @@ -Set-Location PrayerTracker -dotnet publish -c Release -r linux-x64 -p:PublishSingleFile=true --self-contained false -Set-Location bin\Release\net6.0\linux-x64\publish \ No newline at end of file diff --git a/src/names-to-lower.sql b/src/names-to-lower.sql deleted file mode 100644 index 013ee3b..0000000 --- a/src/names-to-lower.sql +++ /dev/null @@ -1,110 +0,0 @@ --- Church -ALTER TABLE pt."Church" RENAME COLUMN "ChurchId" TO id; -ALTER TABLE pt."Church" RENAME COLUMN "Name" TO church_name; -ALTER TABLE pt."Church" RENAME COLUMN "City" TO city; -ALTER TABLE pt."Church" RENAME COLUMN "ST" TO state; -ALTER TABLE pt."Church" RENAME COLUMN "HasVirtualPrayerRoomInterface" TO has_vps_interface; -ALTER TABLE pt."Church" RENAME COLUMN "InterfaceAddress" TO interface_address; -ALTER TABLE pt."Church" RENAME CONSTRAINT "PK_Church" TO pk_church; -ALTER TABLE pt."Church" RENAME TO church; - --- List Preference -ALTER TABLE pt."ListPreference" RENAME COLUMN "SmallGroupId" TO small_group_id; -ALTER TABLE pt."ListPreference" RENAME COLUMN "DaysToExpire" TO days_to_expire; -ALTER TABLE pt."ListPreference" RENAME COLUMN "DaysToKeepNew" TO days_to_keep_new; -ALTER TABLE pt."ListPreference" RENAME COLUMN "LongTermUpdateWeeks" TO long_term_update_weeks; -ALTER TABLE pt."ListPreference" RENAME COLUMN "EmailFromName" TO email_from_name; -ALTER TABLE pt."ListPreference" RENAME COLUMN "EmailFromAddress" TO email_from_address; -ALTER TABLE pt."ListPreference" RENAME COLUMN "ListFonts" TO fonts; -ALTER TABLE pt."ListPreference" RENAME COLUMN "HeadingColor" TO heading_color; -ALTER TABLE pt."ListPreference" RENAME COLUMN "LineColor" TO line_color; -ALTER TABLE pt."ListPreference" RENAME COLUMN "HeadingFontSize" TO heading_font_size; -ALTER TABLE pt."ListPreference" RENAME COLUMN "TextFontSize" TO text_font_size; -ALTER TABLE pt."ListPreference" RENAME COLUMN "RequestSort" TO request_sort; -ALTER TABLE pt."ListPreference" RENAME COLUMN "GroupPassword" TO group_password; -ALTER TABLE pt."ListPreference" RENAME COLUMN "DefaultEmailType" TO default_email_type; -ALTER TABLE pt."ListPreference" RENAME COLUMN "IsPublic" TO is_public; -ALTER TABLE pt."ListPreference" RENAME COLUMN "TimeZoneId" TO time_zone_id; -ALTER TABLE pt."ListPreference" RENAME COLUMN "PageSize" TO page_size; -ALTER TABLE pt."ListPreference" RENAME COLUMN "AsOfDateDisplay" TO as_of_date_display; -ALTER TABLE pt."ListPreference" RENAME CONSTRAINT "PK_ListPreference" TO pk_list_preference; -ALTER TABLE pt."ListPreference" RENAME CONSTRAINT "FK_ListPreference_SmallGroup_SmallGroupId" TO fk_list_preference_small_group_id; -ALTER TABLE pt."ListPreference" DROP CONSTRAINT "FK_ListPreference_TimeZone_TimeZoneId"; -ALTER TABLE pt."ListPreference" RENAME TO list_preference; - -ALTER INDEX pt."IX_ListPreference_TimeZoneId" RENAME TO ix_list_preference_time_zone_id; - -ALTER TABLE pt.list_preference ALTER COLUMN email_from_address SET DEFAULT 'prayer@bitbadger.solutions'; -ALTER TABLE pt.list_preference ALTER COLUMN fonts SET DEFAULT 'native'; - --- Small Group Member -ALTER TABLE pt."Member" RENAME COLUMN "MemberId" TO id; -ALTER TABLE pt."Member" RENAME COLUMN "SmallGroupId" TO small_group_id; -ALTER TABLE pt."Member" RENAME COLUMN "MemberName" TO member_name; -ALTER TABLE pt."Member" RENAME COLUMN "Email" TO email; -ALTER TABLE pt."Member" RENAME COLUMN "Format" TO email_format; -ALTER TABLE pt."Member" RENAME CONSTRAINT "PK_Member" TO pk_member; -ALTER TABLE pt."Member" RENAME CONSTRAINT "FK_Member_SmallGroup_SmallGroupId" TO fk_member_small_group_id; -ALTER TABLE pt."Member" RENAME TO member; - -ALTER INDEX pt."IX_Member_SmallGroupId" RENAME TO ix_member_small_group_id; - --- Prayer Request -ALTER TABLE pt."PrayerRequest" RENAME COLUMN "PrayerRequestId" TO id; -ALTER TABLE pt."PrayerRequest" RENAME COLUMN "RequestType" TO request_type; -ALTER TABLE pt."PrayerRequest" RENAME COLUMN "UserId" TO user_id; -ALTER TABLE pt."PrayerRequest" RENAME COLUMN "SmallGroupId" TO small_group_id; -ALTER TABLE pt."PrayerRequest" RENAME COLUMN "EnteredDate" TO entered_date; -ALTER TABLE pt."PrayerRequest" RENAME COLUMN "UpdatedDate" TO updated_date; -ALTER TABLE pt."PrayerRequest" RENAME COLUMN "Requestor" TO requestor; -ALTER TABLE pt."PrayerRequest" RENAME COLUMN "Text" TO request_text; -ALTER TABLE pt."PrayerRequest" RENAME COLUMN "NotifyChaplain" TO notify_chaplain; -ALTER TABLE pt."PrayerRequest" RENAME COLUMN "Expiration" TO expiration; -ALTER TABLE pt."PrayerRequest" RENAME CONSTRAINT "PK_PrayerRequest" TO pk_prayer_request; -ALTER TABLE pt."PrayerRequest" RENAME CONSTRAINT "FK_PrayerRequest_User_UserId" TO fk_prayer_request_user_id; -ALTER TABLE pt."PrayerRequest" RENAME CONSTRAINT "FK_PrayerRequest_SmallGroup_SmallGroupId" TO fk_prayer_request_small_group_id; -ALTER TABLE pt."PrayerRequest" RENAME TO prayer_request; - -ALTER INDEX pt."IX_PrayerRequest_UserId" RENAME TO ix_prayer_request_user_id; -ALTER INDEX pt."IX_PrayerRequest_SmallGroupId" RENAME TO ix_prayer_request_small_group_id; -ALTER INDEX pt."IX_PrayerRequest_Requestor_TRGM" RENAME TO ix_prayer_request_trgm_requestor; -ALTER INDEX pt."IX_PrayerRequest_Text_TRGM" RENAME TO ix_prayer_request_trgm_request_text; --- Small Group -ALTER TABLE pt."SmallGroup" RENAME COLUMN "SmallGroupId" TO id; -ALTER TABLE pt."SmallGroup" RENAME COLUMN "ChurchId" TO church_id; -ALTER TABLE pt."SmallGroup" RENAME COLUMN "Name" TO group_name; -ALTER TABLE pt."SmallGroup" RENAME CONSTRAINT "PK_SmallGroup" TO pk_small_group; -ALTER TABLE pt."SmallGroup" RENAME CONSTRAINT "FK_SmallGroup_Church_ChurchId" TO fk_small_group_church_id; -ALTER TABLE pt."SmallGroup" RENAME TO small_group; - -ALTER INDEX pt."IX_SmallGroup_ChurchId" RENAME TO ix_small_group_church_id; - --- Time Zone (goes away) -DROP TABLE pt."TimeZone"; - --- User -ALTER TABLE pt."User" RENAME COLUMN "UserId" TO id; -ALTER TABLE pt."User" RENAME COLUMN "FirstName" TO first_name; -ALTER TABLE pt."User" RENAME COLUMN "LastName" TO last_name; -ALTER TABLE pt."User" RENAME COLUMN "EmailAddress" TO email; -ALTER TABLE pt."User" RENAME COLUMN "IsSystemAdmin" TO is_admin; -ALTER TABLE pt."User" RENAME COLUMN "PasswordHash" TO password_hash; -ALTER TABLE pt."User" RENAME COLUMN "Salt" TO salt; -ALTER TABLE pt."User" RENAME CONSTRAINT "PK_User" TO pk_pt_user; -ALTER TABLE pt."User" RENAME TO pt_user; -ALTER TABLE pt.pt_user ADD COLUMN last_seen timestamptz; - --- User / Small Group -ALTER TABLE pt."User_SmallGroup" RENAME COLUMN "UserId" TO user_id; -ALTER TABLE pt."User_SmallGroup" RENAME COLUMN "SmallGroupId" TO small_group_id; -ALTER TABLE pt."User_SmallGroup" RENAME CONSTRAINT "PK_User_SmallGroup" TO pk_user_small_group; -ALTER TABLE pt."User_SmallGroup" RENAME CONSTRAINT "FK_User_SmallGroup_User_UserId" TO fk_user_small_group_user_id; -ALTER TABLE pt."User_SmallGroup" RENAME CONSTRAINT "FK_User_SmallGroup_SmallGroup_SmallGroupId" TO fk_user_small_group_small_group_id; -ALTER TABLE pt."User_SmallGroup" RENAME TO user_small_group; - -ALTER INDEX pt."IX_User_SmallGroup_SmallGroupId" RENAME TO ix_user_small_group_small_group_id; - --- #41 - change to timestamptz -SET TimeZone = 'UTC'; -ALTER TABLE pt.prayer_request ALTER COLUMN entered_date TYPE timestamptz; -ALTER TABLE pt.prayer_request ALTER COLUMN updated_date TYPE timestamptz; diff --git a/src/search-sql.txt b/src/search-sql.txt deleted file mode 100644 index 6edad08..0000000 --- a/src/search-sql.txt +++ /dev/null @@ -1,27 +0,0 @@ -create extension pg_trgm; -set search_path=pt,public; -create index "IX_PrayerRequest_Requestor_TRGM" on "PrayerRequest" using GIN (COALESCE("Requestor", '') gin_trgm_ops); -create index "IX_PrayerRequest_Text_TRGM" on "PrayerRequest" using GIN ("Text" gin_trgm_ops); -alter table "ListPreference" add column "PageSize" int not null default 100; -alter table "ListPreference" add column "AsOfDateDisplay" varchar(1) not null default 'N'; -/* RequestType to 1 character code */ -update "PrayerRequest" set "RequestType" = 'C' where "RequestType" = 'Current'; -update "PrayerRequest" set "RequestType" = 'L' where "RequestType" = 'Recurring'; -update "PrayerRequest" set "RequestType" = 'P' where "RequestType" = 'Praise'; -update "PrayerRequest" set "RequestType" = 'E' where "RequestType" = 'Expecting'; -update "PrayerRequest" set "RequestType" = 'A' where "RequestType" = 'Announcement'; -alter table "PrayerRequest" alter column "RequestType" set data type varchar(1); -/* Change expiration to a 1-character code field */ -alter table "PrayerRequest" add column "Expiration" varchar(1); -update "PrayerRequest" set "Expiration" = case when "IsManuallyExpired" then 'F' when "DoNotExpire" then 'M' else 'A' end; -alter table "PrayerRequest" alter column "Expiration" set not null; -alter table "PrayerRequest" drop column "DoNotExpire"; -alter table "PrayerRequest" drop column "IsManuallyExpired"; -/* Change e-mail type to 1-character code field in list preferences and members */ -update "ListPreference" set "DefaultEmailType" = 'H' where "DefaultEmailType" = 'Html'; -update "ListPreference" set "DefaultEmailType" = 'P' where "DefaultEmailType" = 'Text'; -alter table "ListPreference" alter column "DefaultEmailType" set default 'H'; -alter table "ListPreference" alter column "DefaultEmailType" set data type varchar(1); -update "Member" set "Format" = 'H' where "Format" = 'Html'; -update "Member" set "Format" = 'P' where "Format" = 'Text'; -alter table "Member" alter column "Format" set data type varchar(1);