mirror of
https://github.com/bitwarden/server.git
synced 2025-07-01 08:02:49 -05:00
remove billingupdater and old sqlupdate scripts
This commit is contained in:
@ -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>
|
@ -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 });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
||||
|
Reference in New Issue
Block a user