Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

27 changes: 27 additions & 0 deletions services/celest_cloud_hub/lib/src/context.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import 'package:celest/src/config/config_values.dart';
import 'package:celest/src/core/context.dart' as core;
import 'package:celest_cloud_hub/src/deploy/fly/fly_api.dart';
import 'package:celest_cloud_hub/src/deploy/fly/fly_ctl.dart';
import 'package:celest_cloud_hub/src/deploy/fly/fly_gql.dart';
import 'package:graphql/client.dart';

export 'package:celest/src/core/context.dart' show ContextKey;

Expand All @@ -23,4 +26,28 @@ extension type Context._(core.Context _ctx) implements core.Context {
);
return _ctx.put(_flyContextKey, flyApi);
}

FlyGql get flyGql {
const contextKey = core.ContextKey<FlyGql>('FlyGqlClient');
if (_ctx.get(contextKey) case final flyGql?) {
return flyGql;
}
final client = GraphQLClient(
cache: GraphQLCache(store: InMemoryStore()),
link: AuthLink(
getToken: () => 'FlyV1 $flyAuthToken',
).concat(HttpLink('https://api.fly.io/graphql')),
);
final flyGql = FlyGql(client);
return _ctx.put(contextKey, flyGql);
}

FlyCtl get flyCtl {
const contextKey = core.ContextKey<FlyCtl>('FlyCtl');
if (_ctx.get(contextKey) case final flyCtl?) {
return flyCtl;
}
final flyCtl = FlyCtl(flyAuthToken: flyAuthToken);
return _ctx.put(contextKey, flyCtl);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ final class CloudHubDatabase extends $CloudHubDatabase
}

@override
int get schemaVersion => 2;
int get schemaVersion => 1;

static final Entity rootOrg = Entity(
uid: const EntityUid.of('Celest::Organization', 'celest-dev'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,23 +177,14 @@ CREATE TABLE IF NOT EXISTS project_environment_states (
-- The ID of the linked project environment.
project_environment_id TEXT NOT NULL PRIMARY KEY,

-- The domain name of the project environment.
domain_name TEXT,

-- The name of the project environment's Fly app.
fly_app_name TEXT,

-- The name of the project environment's Fly volume.
--
-- Different Fly commands require the use of the name of the ID,
-- thus we store both.
fly_volume_name TEXT,

-- The ID of the project environment's Fly volume.
--
-- Different Fly commands require the use of the name of the ID,
-- thus we store both.
fly_volume_id TEXT,
-- The domain name of the project environment.
domain_name TEXT,

CONSTRAINT fk_project_environment_state_project_environment_id FOREIGN KEY (project_environment_id) REFERENCES project_environments(id)
ON UPDATE CASCADE ON DELETE CASCADE
Expand Down Expand Up @@ -303,28 +294,24 @@ getProjectEnvironmentState:

upsertProjectEnvironmentState(
:projectEnvironmentId AS TEXT,
:domainName AS TEXT OR NULL,
:flyAppName AS TEXT OR NULL,
:flyVolumeName AS TEXT OR NULL,
:flyVolumeId AS TEXT OR NULL
:domainName AS TEXT OR NULL
):
INSERT INTO project_environment_states (
project_environment_id,
domain_name,
fly_app_name,
fly_volume_name,
fly_volume_id
domain_name
) VALUES (
:projectEnvironmentId,
:domainName,
:flyAppName,
:flyVolumeName,
:flyVolumeId
:domainName
)
ON CONFLICT (project_environment_id) DO UPDATE
SET
domain_name = coalesce(:domainName, domain_name),
fly_app_name = coalesce(:flyAppName, fly_app_name),
fly_volume_name = coalesce(:flyVolumeName, fly_volume_name),
fly_volume_id = coalesce(:flyVolumeId, fly_volume_id)
domain_name = coalesce(:domainName, domain_name)
RETURNING *;
Loading