From 0caacaa5aaa3da6048a418f1f2fcc16a6d0850e6 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Mon, 18 Sep 2017 16:20:52 -0400 Subject: [PATCH] remove billingupdater and old sqlupdate scripts --- bitwarden-core.sln | 7 --- util/BillingUpdater/BillingUpdater.csproj | 13 ----- util/BillingUpdater/Program.cs | 53 ------------------ .../2017-06-19_00_UserTwoFactorEnabled.sql | 16 ------ util/SqlUpdate/2017-06-30_00_UserPremium.sql | 19 ------- util/SqlUpdate/2017-07-07_00_OrgFields.sql | 26 --------- util/SqlUpdate/2017-07-28_00_Gateways.sql | 55 ------------------- util/SqlUpdate/2017-08-09_00_OrgSelfHost.sql | 26 --------- 8 files changed, 215 deletions(-) delete mode 100644 util/BillingUpdater/BillingUpdater.csproj delete mode 100644 util/BillingUpdater/Program.cs delete mode 100644 util/SqlUpdate/2017-06-19_00_UserTwoFactorEnabled.sql delete mode 100644 util/SqlUpdate/2017-06-30_00_UserPremium.sql delete mode 100644 util/SqlUpdate/2017-07-07_00_OrgFields.sql delete mode 100644 util/SqlUpdate/2017-07-28_00_Gateways.sql delete mode 100644 util/SqlUpdate/2017-08-09_00_OrgSelfHost.sql diff --git a/bitwarden-core.sln b/bitwarden-core.sln index e8e4ffc29..1a53a6172 100644 --- a/bitwarden-core.sln +++ b/bitwarden-core.sln @@ -39,8 +39,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Server", "util\Server\Serve EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Jobs", "src\Jobs\Jobs.csproj", "{7DCEBD8F-E5F3-4A3C-BD35-B64341590B74}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BillingUpdater", "util\BillingUpdater\BillingUpdater.csproj", "{A0FBA4DF-2F24-45A6-B188-EBDBD2FAF445}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Function", "util\Function\Function.csproj", "{A6C44A84-8E51-4C64-B9C4-7B7C23253345}" EndProject Global @@ -87,10 +85,6 @@ Global {7DCEBD8F-E5F3-4A3C-BD35-B64341590B74}.Debug|Any CPU.Build.0 = Debug|Any CPU {7DCEBD8F-E5F3-4A3C-BD35-B64341590B74}.Release|Any CPU.ActiveCfg = Release|Any CPU {7DCEBD8F-E5F3-4A3C-BD35-B64341590B74}.Release|Any CPU.Build.0 = Release|Any CPU - {A0FBA4DF-2F24-45A6-B188-EBDBD2FAF445}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A0FBA4DF-2F24-45A6-B188-EBDBD2FAF445}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A0FBA4DF-2F24-45A6-B188-EBDBD2FAF445}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A0FBA4DF-2F24-45A6-B188-EBDBD2FAF445}.Release|Any CPU.Build.0 = Release|Any CPU {A6C44A84-8E51-4C64-B9C4-7B7C23253345}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A6C44A84-8E51-4C64-B9C4-7B7C23253345}.Debug|Any CPU.Build.0 = Debug|Any CPU {A6C44A84-8E51-4C64-B9C4-7B7C23253345}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -109,7 +103,6 @@ Global {EF2164EF-1FC0-4518-A2ED-CE02D3630B00} = {DD5BD056-4AAE-43EF-BBD2-0B569B8DA84E} {66B0A682-658A-4A82-B606-A077A4871448} = {DD5BD056-4AAE-43EF-BBD2-0B569B8DA84E} {7DCEBD8F-E5F3-4A3C-BD35-B64341590B74} = {DD5BD056-4AAE-43EF-BBD2-0B569B8DA84D} - {A0FBA4DF-2F24-45A6-B188-EBDBD2FAF445} = {DD5BD056-4AAE-43EF-BBD2-0B569B8DA84E} {A6C44A84-8E51-4C64-B9C4-7B7C23253345} = {DD5BD056-4AAE-43EF-BBD2-0B569B8DA84E} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/util/BillingUpdater/BillingUpdater.csproj b/util/BillingUpdater/BillingUpdater.csproj deleted file mode 100644 index 2bd0da58b..000000000 --- a/util/BillingUpdater/BillingUpdater.csproj +++ /dev/null @@ -1,13 +0,0 @@ - - - - Exe - netcoreapp2.0 - Bit.BillingUpdater - - - - - - - diff --git a/util/BillingUpdater/Program.cs b/util/BillingUpdater/Program.cs deleted file mode 100644 index 979b4e116..000000000 --- a/util/BillingUpdater/Program.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System; -using System.Data.SqlClient; -using System.Threading.Tasks; -using Bit.Core.Models.Table; -using Dapper; -using Stripe; - -namespace Bit.BillingUpdater -{ - public class Program - { - public static void Main(string[] args) - { - MainAsync().Wait(); - } - - public async static Task MainAsync() - { - var connectionString = ""; - var stripeApiKey = ""; - var stripeSubscriptionService = new StripeSubscriptionService(stripeApiKey); - - using(var connection = new SqlConnection(connectionString)) - { - //Paid orgs - - var orgs = await connection.QueryAsync( - "SELECT * FROM [Organization] WHERE [Enabled] = 1 AND AND GatewaySubscriptionId IS NOT NULL"); - - foreach(var org in orgs) - { - DateTime? expDate = null; - if(org.Gateway == Core.Enums.GatewayType.Stripe) - { - var sub = await stripeSubscriptionService.GetAsync(org.GatewaySubscriptionId); - if(sub != null) - { - expDate = sub.CurrentPeriodEnd; - } - } - - if(expDate.HasValue) - { - Console.WriteLine("Updating org {0} exp to {1}.", org.Id, expDate.Value); - await connection.ExecuteAsync( - "UPDATE [Organization] SET [ExpirationDate] = @Date WHERE [Id] = @Id", - new { Date = expDate, Id = org.Id }); - } - } - } - } - } -} diff --git a/util/SqlUpdate/2017-06-19_00_UserTwoFactorEnabled.sql b/util/SqlUpdate/2017-06-19_00_UserTwoFactorEnabled.sql deleted file mode 100644 index c89147027..000000000 --- a/util/SqlUpdate/2017-06-19_00_UserTwoFactorEnabled.sql +++ /dev/null @@ -1,16 +0,0 @@ -alter table [user] drop column twofactorenabled -go - -alter table [user] drop column [twofactorprovider] -go - -drop view [dbo].[UserView] -go - -CREATE VIEW [dbo].[UserView] -AS -SELECT - * -FROM - [dbo].[User] -GO diff --git a/util/SqlUpdate/2017-06-30_00_UserPremium.sql b/util/SqlUpdate/2017-06-30_00_UserPremium.sql deleted file mode 100644 index 29004a0ad..000000000 --- a/util/SqlUpdate/2017-06-30_00_UserPremium.sql +++ /dev/null @@ -1,19 +0,0 @@ -alter table [user] add [Premium] BIT NULL -go - -update [user] set [premium] = 0 -go - -alter table [user] alter column [premium] BIT NOT NULL -go - -drop view [dbo].[UserView] -go - -CREATE VIEW [dbo].[UserView] -AS -SELECT - * -FROM - [dbo].[User] -GO diff --git a/util/SqlUpdate/2017-07-07_00_OrgFields.sql b/util/SqlUpdate/2017-07-07_00_OrgFields.sql deleted file mode 100644 index a3e13354d..000000000 --- a/util/SqlUpdate/2017-07-07_00_OrgFields.sql +++ /dev/null @@ -1,26 +0,0 @@ -alter table [organization] add [UseTotp] BIT NULL -go - -alter table [organization] add [MaxStorageGb] SMALLINT NULL -go - --- all but free plans -update [organization] -set -[UseTotp] = CASE WHEN [organization].[plantype] != 0 THEN 1 ELSE 0 END, -[MaxStorageGb] = CASE WHEN [organization].[plantype] != 0 THEN 1 ELSE NULL END -go - -alter table [organization] alter column [UseTotp] BIT NOT NULL -go - -drop view [dbo].[OrganizationView] -go - -CREATE VIEW [dbo].[OrganizationView] -AS -SELECT - * -FROM - [dbo].[Organization] -GO diff --git a/util/SqlUpdate/2017-07-28_00_Gateways.sql b/util/SqlUpdate/2017-07-28_00_Gateways.sql deleted file mode 100644 index ab9236a5d..000000000 --- a/util/SqlUpdate/2017-07-28_00_Gateways.sql +++ /dev/null @@ -1,55 +0,0 @@ -EXEC sp_rename 'dbo.User.StripeSubscriptionId', 'GatewaySubscriptionId', 'COLUMN'; -GO -EXEC sp_rename 'dbo.User.StripeCustomerId', 'GatewayCustomerId', 'COLUMN'; -GO - -EXEC sp_rename 'dbo.Organization.StripeSubscriptionId', 'GatewaySubscriptionId', 'COLUMN'; -GO -EXEC sp_rename 'dbo.Organization.StripeCustomerId', 'GatewayCustomerId', 'COLUMN'; -GO - - - - - -alter table [user] add [Gateway] TINYINT NULL -go - -alter table [organization] add [Gateway] TINYINT NULL -go - - - -update [user] set [Gateway] = 0 where GatewaySubscriptionId IS NOT NULL -go - -update [organization] set [Gateway] = 0 where GatewaySubscriptionId IS NOT NULL -go - - - - -drop view [dbo].[OrganizationView] -go - -CREATE VIEW [dbo].[OrganizationView] -AS -SELECT - * -FROM - [dbo].[Organization] -GO - - - - -drop view [dbo].[UserView] -go - -CREATE VIEW [dbo].[UserView] -AS -SELECT - * -FROM - [dbo].[User] -GO diff --git a/util/SqlUpdate/2017-08-09_00_OrgSelfHost.sql b/util/SqlUpdate/2017-08-09_00_OrgSelfHost.sql deleted file mode 100644 index 92bfae5c3..000000000 --- a/util/SqlUpdate/2017-08-09_00_OrgSelfHost.sql +++ /dev/null @@ -1,26 +0,0 @@ -alter table [Organization] add [SelfHost] BIT NULL -go - - -update [Organization] set [SelfHost] = 0 -go - -update [Organization] set [SelfHost] = 1 where PlanType = 4 or PlanType = 5 -go - - -alter table [Organization] alter column [SelfHost] BIT NOT NULL -go - - -drop view [dbo].[OrganizationView] -go - -CREATE VIEW [dbo].[OrganizationView] -AS -SELECT - * -FROM - [dbo].[Organization] -GO -