1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-25 12:45:18 +01:00

remove billingupdater and old sqlupdate scripts

This commit is contained in:
Kyle Spearrin 2017-09-18 16:20:52 -04:00
parent a10d0f24ee
commit 0caacaa5aa
8 changed files with 0 additions and 215 deletions

View File

@ -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

View File

@ -1,13 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<RootNamespace>Bit.BillingUpdater</RootNamespace>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Core\Core.csproj" />
</ItemGroup>
</Project>

View File

@ -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<Organization>(
"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 });
}
}
}
}
}
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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