diff --git a/.github/workflows/celest_cloud_hub.yaml b/.github/workflows/celest_cloud_hub.yaml index 21b592907..549795858 100644 --- a/.github/workflows/celest_cloud_hub.yaml +++ b/.github/workflows/celest_cloud_hub.yaml @@ -41,9 +41,13 @@ jobs: uses: subosito/flutter-action@e938fdf56512cc96ef2f93601a5a40bde3801046 # 2.19.0 with: cache: true + - name: Setup Fly + uses: superfly/flyctl-actions/setup-flyctl@63da3ecc5e2793b98a3f2519b3d75d4f4c11cec2 # master - name: Get Packages working-directory: services/celest_cloud_hub run: dart pub upgrade - name: Test working-directory: services/celest_cloud_hub run: dart test --fail-fast -j1 + env: + FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} diff --git a/services/celest_cloud_core/lib/src/model/resource_name.dart b/services/celest_cloud_core/lib/src/model/resource_name.dart index 489cde3ee..257e7ac22 100644 --- a/services/celest_cloud_core/lib/src/model/resource_name.dart +++ b/services/celest_cloud_core/lib/src/model/resource_name.dart @@ -42,6 +42,17 @@ extension type ResourceName(_ResourceNameInfo _info) { )); } + /// Tries to parse a resource name string into a [ResourceName] object. + /// + /// Returns `null` if the parsing fails for any reason. + static ResourceName? tryParse(String name) { + try { + return ResourceName.parse(name); + } on Object { + return null; + } + } + /// A map of resource pattern types to their Cedar entity types. static const Map entityTypes = { 'operations': EntityTypeName('Celest::Operation'), @@ -55,6 +66,9 @@ extension type ResourceName(_ResourceNameInfo _info) { /// The resource type for this resource. ResourceType get type => _info.type; + /// The identifier of this resource. + String get id => uid.id; + /// The unique identifier for this resource. EntityUid get uid => _info.uid; diff --git a/services/celest_cloud_hub/Makefile b/services/celest_cloud_hub/Makefile new file mode 100644 index 000000000..15c513998 --- /dev/null +++ b/services/celest_cloud_hub/Makefile @@ -0,0 +1,16 @@ +lib/src/database/schema/*.drift.dart: lib/src/database/schema/*.drift + @echo "Generating Drift code..." + @dart run build_runner build --delete-conflicting-outputs + +lib/src/database/cloud_hub_database.steps.dart: lib/src/database/cloud_hub_database.dart lib/src/database/schema/*.drift.dart + @echo "Generating migration steps..." + @dart run drift_dev make-migrations + +drift: lib/src/database/cloud_hub_database.steps.dart + +cedar: lib/src/auth/*.cedar + @echo "Generating Cedar code..." + @dart run tool/generate_policy_set.dart + +.PHONY: drift cedar +all: drift cedar diff --git a/services/celest_cloud_hub/bin/deploy_test.dart b/services/celest_cloud_hub/bin/deploy_test.dart deleted file mode 100644 index b77b0db13..000000000 --- a/services/celest_cloud_hub/bin/deploy_test.dart +++ /dev/null @@ -1,138 +0,0 @@ -import 'dart:io'; - -import 'package:celest_ast/celest_ast.dart' as ast; -import 'package:celest_cli/src/sdk/sdk_finder.dart'; -import 'package:celest_cloud/celest_cloud.dart'; -import 'package:celest_cloud_hub/src/database/cloud_hub_database.dart'; -import 'package:celest_cloud_hub/src/deploy/fly/fly_deployment_engine.dart'; -import 'package:celest_cloud_hub/src/services/service_mixin.dart'; -import 'package:crypto/crypto.dart'; -import 'package:file/local.dart'; -import 'package:http/http.dart' as http; -import 'package:logging/logging.dart'; -import 'package:process/process.dart'; -import 'package:pub_semver/pub_semver.dart'; - -const fileSystem = LocalFileSystem(); -const processManager = LocalProcessManager(); - -Future main() async { - Logger.root.level = Level.ALL; - Logger.root.onRecord.listen((record) { - print( - '[${record.loggerName.split('.').last}] ${record.level}: ${record.message}', - ); - }); - - const sdkFinder = DartSdkFinder(); - final sdk = (await sdkFinder.findSdk()).sdk; - - const helloWorld = r''' -import 'dart:io'; - -Future main() async { - final port = int.parse(Platform.environment['PORT'] ?? '8080'); - final server = await HttpServer.bind(InternetAddress.anyIPv4, port); - print('Listening on http://localhost:$port'); - await for (final request in server) { - request.response.write('Hello, world!'); - await request.response.close(); - } -} -'''; - final tmpDir = fileSystem.systemTempDirectory.createTempSync('celest_').path; - await fileSystem - .directory(tmpDir) - .childFile('hello_world.dart') - .writeAsString(helloWorld); - - print('Compiling server'); - final res = await processManager.run([ - sdk.dartAotRuntime, - sdk.frontendServerAotSnapshot, - '--sdk-root', - sdk.sdkPath, - '--platform', - sdk.vmPlatformProductDill, - '--aot', - '--tfa', - '--no-support-mirrors', - '--link-platform', - '--target=vm', - '-Ddart.vm.product=true', - '--output-dill=$tmpDir/celest.aot.dill', - '$tmpDir/hello_world.dart', - ]); - if (res.exitCode != 0) { - throw Exception('Failed to compile hello_world.dart:\n${res.stderr}'); - } - final bytes = await fileSystem.file('$tmpDir/celest.aot.dill').readAsBytes(); - - final db = CloudHubDatabase.memory(); - - print('Creating organization'); - final orgId = typeId('org'); - await db.organizationsDrift.createOrganization( - id: orgId, - organizationId: 'my-org', - state: 'ACTIVE', - displayName: 'My Organization', - ); - - print('Creating project'); - final projectId = typeId('prj'); - await db.projectsDrift.createProject( - id: projectId, - parentType: 'Celest::Organization', - parentId: orgId, - projectId: 'my-project', - state: 'ACTIVE', - regions: '', - ); - - print('Creating environment'); - final environmentId = typeId('env'); - final environment = - (await db.projectEnvironmentsDrift.createProjectEnvironment( - id: environmentId, - parentType: 'Celest::Project', - parentId: projectId, - projectEnvironmentId: 'production', - state: 'CREATING', - )).first; - final flyApiToken = Platform.environment['FLY_API_TOKEN']!; - final deploymentEngine = FlyDeploymentEngine( - db: db, - flyApiToken: flyApiToken, - projectAst: ast.ResolvedProject( - projectId: 'my-project', - environmentId: 'production', - sdkConfig: ast.SdkConfiguration( - celest: Version(1, 0, 9), - dart: ast.Sdk(type: ast.SdkType.dart, version: sdk.version), - ), - ), - kernelAsset: ( - type: ProjectAsset_Type.DART_KERNEL, - inline: bytes, - filename: 'main.aot.dill', - etag: md5.convert(bytes).toString(), - ), - flutterAssetsBundle: null, - environment: environment, - ); - - print('Deploying'); - final state = await deploymentEngine.deploy(); - deploymentEngine.close(); - - final uri = Uri.parse('https://${state.domainName}'); - final response = await http.get(uri); - if (response.statusCode != 200) { - throw http.ClientException( - 'Bad response: ${response.statusCode} ${response.body}', - uri, - ); - } - print(response.body); -} diff --git a/services/celest_cloud_hub/build.yaml b/services/celest_cloud_hub/build.yaml index 4384c35c4..fd99907db 100644 --- a/services/celest_cloud_hub/build.yaml +++ b/services/celest_cloud_hub/build.yaml @@ -13,6 +13,11 @@ targets: - lib/src/database/** - lib/src/model/** options: &options + databases: + cloud_hub_database: lib/src/database/cloud_hub_database.dart + schema_dir: drift_schema/ + test_dir: test/database/ + sql: dialect: sqlite options: diff --git a/services/celest_cloud_hub/dart_test.yaml b/services/celest_cloud_hub/dart_test.yaml new file mode 100644 index 000000000..f75353c59 --- /dev/null +++ b/services/celest_cloud_hub/dart_test.yaml @@ -0,0 +1,3 @@ +tags: + e2e: + timeout: 5m diff --git a/services/celest_cloud_hub/drift_schema/cloud_hub_database/drift_schema_v1.json b/services/celest_cloud_hub/drift_schema/cloud_hub_database/drift_schema_v1.json new file mode 100644 index 000000000..f70eb9c91 --- /dev/null +++ b/services/celest_cloud_hub/drift_schema/cloud_hub_database/drift_schema_v1.json @@ -0,0 +1 @@ +{"_meta":{"description":"This file contains a serialized version of schema entities for drift.","version":"1.2.0"},"options":{"store_date_time_values_as_text":false},"entities":[{"id":0,"references":[],"type":"table","data":{"name":"cloud_auth_users","was_declared_in_moor":true,"columns":[{"name":"user_id","getter_name":"userId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL PRIMARY KEY","default_dart":null,"default_client_dart":null,"dsl_features":["primary-key"]},{"name":"given_name","getter_name":"givenName","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"family_name","getter_name":"familyName","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"time_zone","getter_name":"timeZone","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"language_code","getter_name":"languageCode","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"create_time","getter_name":"createTime","moor_type":"double","nullable":false,"customConstraints":"NOT NULL DEFAULT (unixepoch('now', 'subsec'))","default_dart":"const CustomExpression('unixepoch(\\'now\\', \\'subsec\\')')","default_client_dart":null,"dsl_features":[]},{"name":"update_time","getter_name":"updateTime","moor_type":"double","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":[]}},{"id":1,"references":[],"type":"table","data":{"name":"cedar_types","was_declared_in_moor":true,"columns":[{"name":"fqn","getter_name":"fqn","moor_type":"string","nullable":false,"customConstraints":"NOT NULL PRIMARY KEY","default_dart":null,"default_client_dart":null,"dsl_features":["primary-key"]}],"is_virtual":false,"without_rowid":false,"constraints":[]}},{"id":2,"references":[1],"type":"table","data":{"name":"cedar_entities","was_declared_in_moor":true,"columns":[{"name":"entity_type","getter_name":"entityType","moor_type":"string","nullable":false,"customConstraints":"NOT NULL REFERENCES cedar_types(fqn)","default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"entity_id","getter_name":"entityId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"attribute_json","getter_name":"attributeJson","moor_type":"string","nullable":false,"customConstraints":"NOT NULL DEFAULT '{}'","default_dart":"const CustomExpression('\\'{}\\'')","default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const CedarAttributesConverter()","dart_type_name":"Map"}},{"name":"entity_json","getter_name":"entityJson","moor_type":"string","nullable":false,"customConstraints":"NOT NULL GENERATED ALWAYS AS (json_object('type', entity_type, 'id', entity_id)) VIRTUAL","default_dart":null,"default_client_dart":null,"dsl_features":["unknown"],"type_converter":{"dart_expr":"const CedarEntityUidConverter()","dart_type_name":"EntityUid"}}],"is_virtual":false,"without_rowid":true,"constraints":["CONSTRAINT cedar_entities_pk PRIMARY KEY(entity_type, entity_id)ON CONFLICT IGNORE"],"explicit_pk":["entity_type","entity_id"]}},{"id":3,"references":[0,2],"type":"trigger","data":{"on":0,"references_in_body":[0,2],"name":"cloud_auth_users_create_trg","sql":"CREATE TRIGGER IF NOT EXISTS cloud_auth_users_create_trg\nBEFORE INSERT ON cloud_auth_users\nBEGIN\n INSERT INTO cedar_entities(entity_type, entity_id)\n VALUES ('Celest::User', NEW.user_id);\nEND;"}},{"id":4,"references":[2],"type":"table","data":{"name":"cedar_relationships","was_declared_in_moor":true,"columns":[{"name":"entity_type","getter_name":"entityType","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"entity_id","getter_name":"entityId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"entity_json","getter_name":"entityJson","moor_type":"string","nullable":false,"customConstraints":"NOT NULL GENERATED ALWAYS AS (json_object('type', entity_type, 'id', entity_id)) VIRTUAL","default_dart":null,"default_client_dart":null,"dsl_features":["unknown"],"type_converter":{"dart_expr":"const CedarEntityUidConverter()","dart_type_name":"EntityUid"}},{"name":"parent_type","getter_name":"parentType","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"parent_id","getter_name":"parentId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"parent_json","getter_name":"parentJson","moor_type":"string","nullable":false,"customConstraints":"NOT NULL GENERATED ALWAYS AS (json_object('type', parent_type, 'id', parent_id)) VIRTUAL","default_dart":null,"default_client_dart":null,"dsl_features":["unknown"],"type_converter":{"dart_expr":"const CedarEntityUidConverter()","dart_type_name":"EntityUid"}}],"is_virtual":false,"without_rowid":true,"constraints":["CONSTRAINT cedar_relationships_pk PRIMARY KEY(entity_type, entity_id, parent_type, parent_id)ON CONFLICT IGNORE","CONSTRAINT cedar_relationships_fk_entity FOREIGN KEY(entity_type, entity_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE CASCADE","CONSTRAINT cedar_relationships_fk_parent FOREIGN KEY(parent_type, parent_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE CASCADE"],"explicit_pk":["entity_type","entity_id","parent_type","parent_id"]}},{"id":5,"references":[0,4,2],"type":"trigger","data":{"on":0,"references_in_body":[0,4,2],"name":"cloud_auth_users_delete_trg","sql":"CREATE TRIGGER IF NOT EXISTS cloud_auth_users_delete_trg\nAFTER DELETE ON cloud_auth_users\nBEGIN\n DELETE FROM cedar_relationships\n WHERE \n (entity_type = 'Celest::User' AND entity_id = OLD.user_id)\n OR (parent_type = 'Celest::User' AND parent_id = OLD.user_id);\n DELETE FROM cedar_entities\n WHERE\n entity_id = OLD.user_id\n AND entity_type = 'Celest::User';\nEND;"}},{"id":6,"references":[0],"type":"table","data":{"name":"cloud_auth_user_emails","was_declared_in_moor":true,"columns":[{"name":"user_id","getter_name":"userId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"email","getter_name":"email","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"is_verified","getter_name":"isVerified","moor_type":"bool","nullable":false,"customConstraints":"NOT NULL DEFAULT FALSE","default_dart":"const CustomExpression('FALSE')","default_client_dart":null,"dsl_features":[]},{"name":"is_primary","getter_name":"isPrimary","moor_type":"bool","nullable":false,"customConstraints":"NOT NULL DEFAULT FALSE","default_dart":"const CustomExpression('FALSE')","default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":true,"constraints":["CONSTRAINT cloud_auth_user_emails_pk PRIMARY KEY(user_id, email)","CONSTRAINT cloud_auth_user_emails_user_fk FOREIGN KEY(user_id)REFERENCES cloud_auth_users(user_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED"],"explicit_pk":["user_id","email"]}},{"id":7,"references":[0],"type":"table","data":{"name":"cloud_auth_user_phone_numbers","was_declared_in_moor":true,"columns":[{"name":"user_id","getter_name":"userId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"phone_number","getter_name":"phoneNumber","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"is_verified","getter_name":"isVerified","moor_type":"bool","nullable":false,"customConstraints":"NOT NULL DEFAULT FALSE","default_dart":"const CustomExpression('FALSE')","default_client_dart":null,"dsl_features":[]},{"name":"is_primary","getter_name":"isPrimary","moor_type":"bool","nullable":false,"customConstraints":"NOT NULL DEFAULT FALSE","default_dart":"const CustomExpression('FALSE')","default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":true,"constraints":["CONSTRAINT cloud_auth_user_phone_numbers_pk PRIMARY KEY(user_id, phone_number)","CONSTRAINT cloud_auth_user_phone_numbers_user_fk FOREIGN KEY(user_id)REFERENCES cloud_auth_users(user_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED"],"explicit_pk":["user_id","phone_number"]}},{"id":8,"references":[],"type":"table","data":{"name":"cloud_auth_projects","was_declared_in_moor":true,"columns":[{"name":"project_id","getter_name":"projectId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL PRIMARY KEY","default_dart":null,"default_client_dart":null,"dsl_features":["primary-key"]},{"name":"version","getter_name":"version","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"resolved_ast","getter_name":"resolvedAst","moor_type":"blob","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const ResolvedProjectConverter()","dart_type_name":"ResolvedProject"}},{"name":"etag","getter_name":"etag","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":[]}},{"id":9,"references":[8],"type":"table","data":{"name":"cloud_auth_apis","was_declared_in_moor":true,"columns":[{"name":"api_id","getter_name":"apiId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL PRIMARY KEY","default_dart":null,"default_client_dart":null,"dsl_features":["primary-key"]},{"name":"project_id","getter_name":"projectId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"resolved_ast","getter_name":"resolvedAst","moor_type":"blob","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const ResolvedApiConverter()","dart_type_name":"ResolvedApi"}},{"name":"etag","getter_name":"etag","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":["CONSTRAINT cloud_auth_apis_project_fk FOREIGN KEY(project_id)REFERENCES cloud_auth_projects(project_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED"]}},{"id":10,"references":[9],"type":"index","data":{"on":9,"name":"cloud_auth_apis_project_idx","sql":"CREATE INDEX IF NOT EXISTS cloud_auth_apis_project_idx ON cloud_auth_apis(project_id);","unique":false,"columns":[]}},{"id":11,"references":[9,2],"type":"trigger","data":{"on":9,"references_in_body":[9,2],"name":"cloud_auth_apis_create_trg","sql":"CREATE TRIGGER IF NOT EXISTS cloud_auth_apis_create_trg\nBEFORE INSERT ON cloud_auth_apis\nBEGIN\n INSERT INTO cedar_entities(entity_type, entity_id)\n VALUES ('Celest::Api', NEW.api_id);\nEND;"}},{"id":12,"references":[9,4,2],"type":"trigger","data":{"on":9,"references_in_body":[9,4,2],"name":"cloud_auth_apis_delete_trg","sql":"CREATE TRIGGER IF NOT EXISTS cloud_auth_apis_delete_trg\nAFTER DELETE ON cloud_auth_apis\nBEGIN\n DELETE FROM cedar_relationships\n WHERE \n entity_type = 'Celest::Api'\n AND entity_id = OLD.api_id;\n DELETE FROM cedar_relationships\n WHERE \n parent_type = 'Celest::Api'\n AND parent_id = OLD.api_id;\n DELETE FROM cedar_entities\n WHERE\n entity_type = 'Celest::Api'\n AND entity_id = OLD.api_id;\nEND;"}},{"id":13,"references":[9],"type":"table","data":{"name":"cloud_auth_functions","was_declared_in_moor":true,"columns":[{"name":"function_id","getter_name":"functionId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL PRIMARY KEY","default_dart":null,"default_client_dart":null,"dsl_features":["primary-key"]},{"name":"api_id","getter_name":"apiId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"resolved_ast","getter_name":"resolvedAst","moor_type":"blob","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const ResolvedFunctionConverter()","dart_type_name":"ResolvedCloudFunction"}},{"name":"etag","getter_name":"etag","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":["CONSTRAINT cloud_auth_functions_api_fk FOREIGN KEY(api_id)REFERENCES cloud_auth_apis(api_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED"]}},{"id":14,"references":[13],"type":"index","data":{"on":13,"name":"cloud_auth_functions_api_idx","sql":"CREATE INDEX IF NOT EXISTS cloud_auth_functions_api_idx ON cloud_auth_functions(api_id);","unique":false,"columns":[]}},{"id":15,"references":[13,2,4],"type":"trigger","data":{"on":13,"references_in_body":[13,2,4],"name":"cloud_auth_functions_create_trg","sql":"CREATE TRIGGER IF NOT EXISTS cloud_auth_functions_create_trg\nBEFORE INSERT ON cloud_auth_functions\nBEGIN\n INSERT INTO cedar_entities(entity_type, entity_id)\n VALUES ('Celest::Function', NEW.function_id);\n INSERT INTO cedar_relationships(entity_type, entity_id, parent_type, parent_id)\n VALUES ('Celest::Function', NEW.function_id, 'Celest::Api', NEW.api_id);\nEND;"}},{"id":16,"references":[13,4,2],"type":"trigger","data":{"on":13,"references_in_body":[13,4,2],"name":"cloud_auth_functions_delete_trg","sql":"CREATE TRIGGER IF NOT EXISTS cloud_auth_functions_delete_trg\nAFTER DELETE ON cloud_auth_functions\nBEGIN\n DELETE FROM cedar_relationships\n WHERE \n entity_type = 'Celest::Function'\n AND entity_id = OLD.function_id;\n DELETE FROM cedar_relationships\n WHERE \n parent_type = 'Celest::Function'\n AND parent_id = OLD.function_id;\n DELETE FROM cedar_entities\n WHERE\n entity_type = 'Celest::Function'\n AND entity_id = OLD.function_id;\nEND;"}},{"id":17,"references":[],"type":"table","data":{"name":"cloud_auth_meta","was_declared_in_moor":true,"columns":[{"name":"schema_version","getter_name":"schemaVersion","moor_type":"int","nullable":false,"customConstraints":"NOT NULL PRIMARY KEY","default_dart":null,"default_client_dart":null,"dsl_features":["primary-key"]}],"is_virtual":false,"without_rowid":false,"constraints":[]}},{"id":18,"references":[],"type":"table","data":{"name":"cloud_auth_crypto_keys","was_declared_in_moor":true,"columns":[{"name":"crypto_key_id","getter_name":"cryptoKeyId","moor_type":"blob","nullable":false,"customConstraints":"NOT NULL PRIMARY KEY","default_dart":null,"default_client_dart":null,"dsl_features":["primary-key"]},{"name":"key_purpose","getter_name":"keyPurpose","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"key_algorithm","getter_name":"keyAlgorithm","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"key_material","getter_name":"keyMaterial","moor_type":"blob","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"external_crypto_key_id","getter_name":"externalCryptoKeyId","moor_type":"string","nullable":true,"customConstraints":"UNIQUE","default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]}],"is_virtual":false,"without_rowid":false,"constraints":["CHECK(key_material IS NOT NULL OR external_crypto_key_id IS NOT NULL)"]}},{"id":19,"references":[18],"type":"index","data":{"on":18,"name":"cloud_auth_crypto_keys_external_crypto_key_id_idx","sql":"CREATE INDEX IF NOT EXISTS cloud_auth_crypto_keys_external_crypto_key_id_idx ON cloud_auth_crypto_keys(external_crypto_key_id);","unique":false,"columns":[]}},{"id":20,"references":[0,18],"type":"table","data":{"name":"cloud_auth_sessions","was_declared_in_moor":true,"columns":[{"name":"rowid","getter_name":"rowid","moor_type":"int","nullable":false,"customConstraints":"PRIMARY KEY AUTOINCREMENT","default_dart":null,"default_client_dart":null,"dsl_features":["auto-increment"]},{"name":"session_id","getter_name":"sessionId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL UNIQUE","default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"crypto_key_id","getter_name":"cryptoKeyId","moor_type":"blob","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"user_id","getter_name":"userId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"client_info","getter_name":"clientInfo","moor_type":"blob","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const SessionClientConverter()","dart_type_name":"SessionClient"}},{"name":"authentication_factor","getter_name":"authenticationFactor","moor_type":"blob","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const AuthenticationFactorConverter()","dart_type_name":"AuthenticationFactor"}},{"name":"state","getter_name":"state","moor_type":"blob","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const SessionStateConverter()","dart_type_name":"SessionState"}},{"name":"ip_address","getter_name":"ipAddress","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"external_session_id","getter_name":"externalSessionId","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"create_time","getter_name":"createTime","moor_type":"double","nullable":false,"customConstraints":"NOT NULL DEFAULT (unixepoch('now', 'subsec'))","default_dart":"const CustomExpression('unixepoch(\\'now\\', \\'subsec\\')')","default_client_dart":null,"dsl_features":[]},{"name":"update_time","getter_name":"updateTime","moor_type":"double","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"expire_time","getter_name":"expireTime","moor_type":"double","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":["CONSTRAINT cloud_auth_sessions_user_fk FOREIGN KEY(user_id)REFERENCES cloud_auth_users(user_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED","CONSTRAINT cloud_auth_sessions_key_fk FOREIGN KEY(crypto_key_id)REFERENCES cloud_auth_crypto_keys(crypto_key_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED"]}},{"id":21,"references":[20],"type":"index","data":{"on":20,"name":"cloud_auth_sessions_user_idx","sql":"CREATE INDEX IF NOT EXISTS cloud_auth_sessions_user_idx ON cloud_auth_sessions(user_id);","unique":false,"columns":[]}},{"id":22,"references":[20],"type":"index","data":{"on":20,"name":"cloud_auth_sessions_crypto_key_idx","sql":"CREATE INDEX IF NOT EXISTS cloud_auth_sessions_crypto_key_idx ON cloud_auth_sessions(crypto_key_id);","unique":false,"columns":[]}},{"id":23,"references":[20],"type":"index","data":{"on":20,"name":"cloud_auth_sessions_external_session_id_idx","sql":"CREATE INDEX IF NOT EXISTS cloud_auth_sessions_external_session_id_idx ON cloud_auth_sessions(external_session_id);","unique":false,"columns":[]}},{"id":24,"references":[20],"type":"trigger","data":{"on":20,"references_in_body":[20],"name":"cloud_auth_sessions_update_time_trg","sql":"CREATE TRIGGER IF NOT EXISTS cloud_auth_sessions_update_time_trg\nAFTER UPDATE ON cloud_auth_sessions\nBEGIN\n UPDATE cloud_auth_sessions\n SET update_time = unixepoch('now', 'subsec')\n WHERE rowid = OLD.rowid;\nEND;"}},{"id":25,"references":[20],"type":"table","data":{"name":"cloud_auth_otp_codes","was_declared_in_moor":true,"columns":[{"name":"rowid","getter_name":"rowid","moor_type":"int","nullable":false,"customConstraints":"PRIMARY KEY AUTOINCREMENT","default_dart":null,"default_client_dart":null,"dsl_features":["auto-increment"]},{"name":"session_id","getter_name":"sessionId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL UNIQUE","default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"resend_attempt","getter_name":"resendAttempt","moor_type":"int","nullable":false,"customConstraints":"NOT NULL DEFAULT 0","default_dart":"const CustomExpression('0')","default_client_dart":null,"dsl_features":[]},{"name":"verify_attempt","getter_name":"verifyAttempt","moor_type":"int","nullable":false,"customConstraints":"NOT NULL DEFAULT 0","default_dart":"const CustomExpression('0')","default_client_dart":null,"dsl_features":[]},{"name":"update_time","getter_name":"updateTime","moor_type":"double","nullable":false,"customConstraints":"NOT NULL DEFAULT (unixepoch('now', 'subsec'))","default_dart":"const CustomExpression('unixepoch(\\'now\\', \\'subsec\\')')","default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":["CONSTRAINT cloud_auth_otp_codes_session_id_fk FOREIGN KEY(session_id)REFERENCES cloud_auth_sessions(session_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED"]}},{"id":26,"references":[25],"type":"index","data":{"on":25,"name":"cloud_auth_otp_codes_session_id_idx","sql":"CREATE INDEX IF NOT EXISTS cloud_auth_otp_codes_session_id_idx ON cloud_auth_otp_codes(session_id);","unique":false,"columns":[]}},{"id":27,"references":[18,2],"type":"table","data":{"name":"cloud_auth_corks","was_declared_in_moor":true,"columns":[{"name":"cork_id","getter_name":"corkId","moor_type":"blob","nullable":false,"customConstraints":"NOT NULL PRIMARY KEY","default_dart":null,"default_client_dart":null,"dsl_features":["primary-key"]},{"name":"crypto_key_id","getter_name":"cryptoKeyId","moor_type":"blob","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"bearer_type","getter_name":"bearerType","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"bearer_id","getter_name":"bearerId","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"audience_type","getter_name":"audienceType","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"audience_id","getter_name":"audienceId","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"issuer_type","getter_name":"issuerType","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"issuer_id","getter_name":"issuerId","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"create_time","getter_name":"createTime","moor_type":"double","nullable":false,"customConstraints":"NOT NULL DEFAULT (unixepoch('now', 'subsec'))","default_dart":"const CustomExpression('unixepoch(\\'now\\', \\'subsec\\')')","default_client_dart":null,"dsl_features":[]},{"name":"expire_time","getter_name":"expireTime","moor_type":"double","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"last_use_time","getter_name":"lastUseTime","moor_type":"double","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":["CONSTRAINT cloud_auth_corks_crypto_key_fk FOREIGN KEY(crypto_key_id)REFERENCES cloud_auth_crypto_keys(crypto_key_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED","CONSTRAINT cloud_auth_corks_bearer_fk FOREIGN KEY(bearer_type, bearer_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED","CONSTRAINT cloud_auth_corks_audience_fk FOREIGN KEY(audience_type, audience_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED","CONSTRAINT cloud_auth_corks_issuer_fk FOREIGN KEY(issuer_type, issuer_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED"]}},{"id":28,"references":[27],"type":"index","data":{"on":27,"name":"cloud_auth_corks_crypto_key_idx","sql":"CREATE INDEX IF NOT EXISTS cloud_auth_corks_crypto_key_idx ON cloud_auth_corks(crypto_key_id);","unique":false,"columns":[]}},{"id":29,"references":[27],"type":"index","data":{"on":27,"name":"cloud_auth_corks_bearer_idx","sql":"CREATE INDEX IF NOT EXISTS cloud_auth_corks_bearer_idx ON cloud_auth_corks(bearer_type, bearer_id);","unique":false,"columns":[]}},{"id":30,"references":[27],"type":"index","data":{"on":27,"name":"cloud_auth_corks_audience_idx","sql":"CREATE INDEX IF NOT EXISTS cloud_auth_corks_audience_idx ON cloud_auth_corks(audience_type, audience_id);","unique":false,"columns":[]}},{"id":31,"references":[27],"type":"index","data":{"on":27,"name":"cloud_auth_corks_issuer_idx","sql":"CREATE INDEX IF NOT EXISTS cloud_auth_corks_issuer_idx ON cloud_auth_corks(issuer_type, issuer_id);","unique":false,"columns":[]}},{"id":32,"references":[4],"type":"index","data":{"on":4,"name":"cedar_relationships_fk_entity_idx","sql":"CREATE INDEX IF NOT EXISTS cedar_relationships_fk_entity_idx ON cedar_relationships(entity_type, entity_id);","unique":false,"columns":[]}},{"id":33,"references":[4],"type":"index","data":{"on":4,"name":"cedar_relationships_fk_parent_idx","sql":"CREATE INDEX IF NOT EXISTS cedar_relationships_fk_parent_idx ON cedar_relationships(parent_type, parent_id);","unique":false,"columns":[]}},{"id":34,"references":[],"type":"table","data":{"name":"cedar_policies","was_declared_in_moor":true,"columns":[{"name":"id","getter_name":"id","moor_type":"string","nullable":false,"customConstraints":"NOT NULL PRIMARY KEY","default_dart":null,"default_client_dart":null,"dsl_features":["primary-key"]},{"name":"policy_id","getter_name":"policyId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL UNIQUE","default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"policy","getter_name":"policy","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const CedarPolicyConverter()","dart_type_name":"Policy"}},{"name":"enforcement_level","getter_name":"enforcementLevel","moor_type":"int","nullable":false,"customConstraints":"NOT NULL DEFAULT 1","default_dart":"const CustomExpression('1')","default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":["CHECK(enforcement_level IN (0, 1))"]}},{"id":35,"references":[],"type":"table","data":{"name":"cedar_policy_templates","was_declared_in_moor":true,"columns":[{"name":"id","getter_name":"id","moor_type":"string","nullable":false,"customConstraints":"NOT NULL PRIMARY KEY","default_dart":null,"default_client_dart":null,"dsl_features":["primary-key"]},{"name":"template_id","getter_name":"templateId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL UNIQUE","default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"template","getter_name":"template","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const CedarPolicyConverter()","dart_type_name":"Policy"}}],"is_virtual":false,"without_rowid":false,"constraints":["CHECK(template IS NOT NULL OR template IS NOT NULL)"]}},{"id":36,"references":[35,2],"type":"table","data":{"name":"cedar_policy_template_links","was_declared_in_moor":true,"columns":[{"name":"id","getter_name":"id","moor_type":"string","nullable":false,"customConstraints":"NOT NULL PRIMARY KEY","default_dart":null,"default_client_dart":null,"dsl_features":["primary-key"]},{"name":"policy_id","getter_name":"policyId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL UNIQUE","default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"template_id","getter_name":"templateId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"principal_type","getter_name":"principalType","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"principal_id","getter_name":"principalId","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"resource_type","getter_name":"resourceType","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"resource_id","getter_name":"resourceId","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"enforcement_level","getter_name":"enforcementLevel","moor_type":"int","nullable":false,"customConstraints":"NOT NULL DEFAULT 1","default_dart":"const CustomExpression('1')","default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":["CHECK(principal_type IS NOT NULL AND principal_id IS NOT NULL OR resource_type IS NOT NULL AND resource_id IS NOT NULL)","CHECK(enforcement_level IN (0, 1))","CONSTRAINT cedar_policy_template_links_fk_template_id FOREIGN KEY(template_id)REFERENCES cedar_policy_templates(template_id)ON UPDATE CASCADE ON DELETE CASCADE","CONSTRAINT cedar_policy_template_links_fk_principal FOREIGN KEY(principal_type, principal_id)REFERENCES cedar_entities(entity_type, entity_id)ON DELETE CASCADE","CONSTRAINT cedar_policy_template_links_fk_resource FOREIGN KEY(resource_type, resource_id)REFERENCES cedar_entities(entity_type, entity_id)ON DELETE CASCADE"]}},{"id":37,"references":[36],"type":"index","data":{"on":36,"name":"cedar_policy_template_links_fk_template_id_idx","sql":"CREATE INDEX IF NOT EXISTS cedar_policy_template_links_fk_template_id_idx ON cedar_policy_template_links(template_id);","unique":false,"columns":[]}},{"id":38,"references":[36],"type":"index","data":{"on":36,"name":"cedar_policy_template_links_fk_principal_idx","sql":"CREATE INDEX IF NOT EXISTS cedar_policy_template_links_fk_principal_idx ON cedar_policy_template_links(principal_type, principal_id);","unique":false,"columns":[]}},{"id":39,"references":[36],"type":"index","data":{"on":36,"name":"cedar_policy_template_links_fk_resource_idx","sql":"CREATE INDEX IF NOT EXISTS cedar_policy_template_links_fk_resource_idx ON cedar_policy_template_links(resource_type, resource_id);","unique":false,"columns":[]}},{"id":40,"references":[],"type":"table","data":{"name":"cedar_authorization_logs","was_declared_in_moor":true,"columns":[{"name":"rowid","getter_name":"rowid","moor_type":"int","nullable":false,"customConstraints":"PRIMARY KEY AUTOINCREMENT","default_dart":null,"default_client_dart":null,"dsl_features":["auto-increment"]},{"name":"create_time","getter_name":"createTime","moor_type":"dateTime","nullable":false,"customConstraints":"NOT NULL DEFAULT (unixepoch('now', 'subsec'))","default_dart":"const CustomExpression('unixepoch(\\'now\\', \\'subsec\\')')","default_client_dart":null,"dsl_features":[]},{"name":"expire_time","getter_name":"expireTime","moor_type":"dateTime","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"principal_type","getter_name":"principalType","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"principal_id","getter_name":"principalId","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"action_type","getter_name":"actionType","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"action_id","getter_name":"actionId","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"resource_type","getter_name":"resourceType","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"resource_id","getter_name":"resourceId","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"context_json","getter_name":"contextJson","moor_type":"string","nullable":false,"customConstraints":"NOT NULL DEFAULT '{}'","default_dart":"const CustomExpression('\\'{}\\'')","default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const CedarAttributesConverter()","dart_type_name":"Map"}},{"name":"decision","getter_name":"decision","moor_type":"bool","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"reasons_json","getter_name":"reasonsJson","moor_type":"string","nullable":false,"customConstraints":"NOT NULL DEFAULT '[]'","default_dart":"const CustomExpression('\\'[]\\'')","default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const CedarAuthorizationReasonsConverter()","dart_type_name":"List"}},{"name":"errors_json","getter_name":"errorsJson","moor_type":"string","nullable":false,"customConstraints":"NOT NULL DEFAULT '[]'","default_dart":"const CustomExpression('\\'[]\\'')","default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const CedarAuthorizationErrorsConverter()","dart_type_name":"AuthorizationErrors"}}],"is_virtual":false,"without_rowid":false,"constraints":[]}},{"id":41,"references":[2],"type":"table","data":{"name":"user_memberships","was_declared_in_moor":true,"columns":[{"name":"membership_id","getter_name":"membershipId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL PRIMARY KEY","default_dart":null,"default_client_dart":null,"dsl_features":["primary-key"]},{"name":"user_id","getter_name":"userId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"parent_type","getter_name":"parentType","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"parent_id","getter_name":"parentId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"role","getter_name":"role","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"create_time","getter_name":"createTime","moor_type":"dateTime","nullable":false,"customConstraints":"NOT NULL DEFAULT (unixepoch('now', 'subsec'))","default_dart":"const CustomExpression('unixepoch(\\'now\\', \\'subsec\\')')","default_client_dart":null,"dsl_features":[]},{"name":"update_time","getter_name":"updateTime","moor_type":"dateTime","nullable":false,"customConstraints":"NOT NULL DEFAULT (unixepoch('now', 'subsec'))","default_dart":"const CustomExpression('unixepoch(\\'now\\', \\'subsec\\')')","default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":["CHECK(parent_type = 'Celest::Organization' OR parent_type = 'Celest::Project' OR parent_type = 'Celest::Project::Environment')","CONSTRAINT user_memberships_parent_fk FOREIGN KEY(parent_type, parent_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED"]}},{"id":42,"references":[41],"type":"index","data":{"on":41,"name":"user_memberships_parent_idx","sql":"CREATE INDEX IF NOT EXISTS user_memberships_parent_idx ON user_memberships(parent_type, parent_id);","unique":false,"columns":[]}},{"id":43,"references":[41,2,4],"type":"trigger","data":{"on":41,"references_in_body":[41,2,4],"name":"user_memberships_create_trg","sql":"CREATE TRIGGER IF NOT EXISTS user_memberships_create_trg\nBEFORE INSERT ON user_memberships\nBEGIN\n INSERT INTO cedar_entities(entity_type, entity_id, attribute_json)\n VALUES (\n NEW.parent_type || '::Member', \n NEW.membership_id, \n json_object(\n 'role', json_object(\n 'type', 'Celest::Role',\n 'id', NEW.role\n ), \n 'parent', json_object(\n 'type', NEW.parent_type, \n 'id', NEW.parent_id\n )\n )\n );\n INSERT INTO cedar_relationships(entity_type, entity_id, parent_type, parent_id)\n VALUES ('Celest::User', NEW.user_id, NEW.parent_type || '::Member', NEW.membership_id);\nEND;"}},{"id":44,"references":[41,2,4],"type":"trigger","data":{"on":41,"references_in_body":[41,2,4],"name":"user_memberships_update_trg","sql":"CREATE TRIGGER IF NOT EXISTS user_memberships_update_trg\nAFTER UPDATE ON user_memberships\nBEGIN\n UPDATE cedar_entities\n SET attribute_json = json_object(\n 'role', json_object(\n 'type', 'Celest::Role',\n 'id', NEW.role\n ), \n 'parent', json_object(\n 'type', OLD.parent_type,\n 'id', OLD.parent_id\n )\n )\n WHERE entity_id = OLD.membership_id AND entity_type = OLD.parent_type || '::Member';\n UPDATE cedar_relationships\n SET parent_id = NEW.role\n WHERE entity_id = OLD.membership_id AND entity_type = OLD.parent_type || '::Member' AND parent_type = 'Celest::Role';\nEND;"}},{"id":45,"references":[41,4,2],"type":"trigger","data":{"on":41,"references_in_body":[41,4,2],"name":"user_memberships_delete_trg","sql":"CREATE TRIGGER IF NOT EXISTS user_memberships_delete_trg\nAFTER DELETE ON user_memberships\nBEGIN\n DELETE FROM cedar_relationships\n WHERE \n entity_id = OLD.membership_id \n AND entity_type = OLD.parent_type || '::Member';\n DELETE FROM cedar_relationships\n WHERE\n parent_id = OLD.membership_id \n AND parent_type = OLD.parent_type || '::Member';\n DELETE FROM cedar_entities\n WHERE\n entity_id = OLD.membership_id\n AND entity_type = OLD.parent_type || '::Member';\nEND;"}},{"id":46,"references":[2],"type":"table","data":{"name":"organizations","was_declared_in_moor":true,"columns":[{"name":"id","getter_name":"id","moor_type":"string","nullable":false,"customConstraints":"NOT NULL PRIMARY KEY","default_dart":null,"default_client_dart":null,"dsl_features":["primary-key"]},{"name":"parent_type","getter_name":"parentType","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"parent_id","getter_name":"parentId","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"organization_id","getter_name":"organizationId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL UNIQUE","default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"state","getter_name":"state","moor_type":"string","nullable":false,"customConstraints":"NOT NULL DEFAULT 'CREATING'","default_dart":"const CustomExpression('\\'CREATING\\'')","default_client_dart":null,"dsl_features":[]},{"name":"display_name","getter_name":"displayName","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"create_time","getter_name":"createTime","moor_type":"dateTime","nullable":false,"customConstraints":"NOT NULL DEFAULT (unixepoch('now', 'subsec'))","default_dart":"const CustomExpression('unixepoch(\\'now\\', \\'subsec\\')')","default_client_dart":null,"dsl_features":[]},{"name":"update_time","getter_name":"updateTime","moor_type":"dateTime","nullable":false,"customConstraints":"NOT NULL DEFAULT (unixepoch('now', 'subsec'))","default_dart":"const CustomExpression('unixepoch(\\'now\\', \\'subsec\\')')","default_client_dart":null,"dsl_features":[]},{"name":"delete_time","getter_name":"deleteTime","moor_type":"dateTime","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"purge_time","getter_name":"purgeTime","moor_type":"dateTime","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"annotations","getter_name":"annotations","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"primary_region","getter_name":"primaryRegion","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"reconciling","getter_name":"reconciling","moor_type":"bool","nullable":false,"customConstraints":"NOT NULL DEFAULT FALSE","default_dart":"const CustomExpression('FALSE')","default_client_dart":null,"dsl_features":[]},{"name":"etag","getter_name":"etag","moor_type":"string","nullable":false,"customConstraints":"NOT NULL GENERATED ALWAYS AS (hex(md5(json_array(id, parent_type, parent_id, organization_id, state, display_name, create_time, update_time, delete_time, purge_time, annotations, primary_region, reconciling)))) STORED","default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]}],"is_virtual":false,"without_rowid":false,"constraints":["CONSTRAINT organizations_parent_fk FOREIGN KEY(parent_type, parent_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE SET NULL"]}},{"id":47,"references":[46,41],"type":"trigger","data":{"on":46,"references_in_body":[46,41],"name":"organizations_delete_user_memberships_trg","sql":"CREATE TRIGGER IF NOT EXISTS organizations_delete_user_memberships_trg\nAFTER DELETE ON organizations\nBEGIN\n DELETE FROM user_memberships\n WHERE\n parent_type = 'Celest::Organization'\n AND parent_id = OLD.id;\nEND;"}},{"id":48,"references":[2,46],"type":"table","data":{"name":"projects","was_declared_in_moor":true,"columns":[{"name":"id","getter_name":"id","moor_type":"string","nullable":false,"customConstraints":"NOT NULL PRIMARY KEY","default_dart":null,"default_client_dart":null,"dsl_features":["primary-key"]},{"name":"parent_type","getter_name":"parentType","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"parent_id","getter_name":"parentId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"project_id","getter_name":"projectId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"state","getter_name":"state","moor_type":"string","nullable":false,"customConstraints":"NOT NULL DEFAULT 'CREATING'","default_dart":"const CustomExpression('\\'CREATING\\'')","default_client_dart":null,"dsl_features":[]},{"name":"display_name","getter_name":"displayName","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"create_time","getter_name":"createTime","moor_type":"dateTime","nullable":false,"customConstraints":"NOT NULL DEFAULT (unixepoch('now', 'subsec'))","default_dart":"const CustomExpression('unixepoch(\\'now\\', \\'subsec\\')')","default_client_dart":null,"dsl_features":[]},{"name":"update_time","getter_name":"updateTime","moor_type":"dateTime","nullable":false,"customConstraints":"NOT NULL DEFAULT (unixepoch('now', 'subsec'))","default_dart":"const CustomExpression('unixepoch(\\'now\\', \\'subsec\\')')","default_client_dart":null,"dsl_features":[]},{"name":"delete_time","getter_name":"deleteTime","moor_type":"dateTime","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"purge_time","getter_name":"purgeTime","moor_type":"dateTime","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"annotations","getter_name":"annotations","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"regions","getter_name":"regions","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"reconciling","getter_name":"reconciling","moor_type":"bool","nullable":false,"customConstraints":"NOT NULL DEFAULT FALSE","default_dart":"const CustomExpression('FALSE')","default_client_dart":null,"dsl_features":[]},{"name":"etag","getter_name":"etag","moor_type":"string","nullable":false,"customConstraints":"NOT NULL GENERATED ALWAYS AS (hex(md5(json_array(id, parent_type, parent_id, project_id, state, display_name, create_time, update_time, delete_time, purge_time, annotations, regions, reconciling)))) STORED","default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]}],"is_virtual":false,"without_rowid":false,"constraints":["CHECK(parent_type = 'Celest::Organization')","CONSTRAINT projects_fk_parent FOREIGN KEY(parent_type, parent_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE CASCADE","CONSTRAINT projects_fk_organization FOREIGN KEY(parent_id)REFERENCES organizations(id)ON UPDATE CASCADE ON DELETE CASCADE","CONSTRAINT projects_uq_project_id UNIQUE(project_id, parent_id)"],"unique_keys":[["project_id","parent_id"]]}},{"id":49,"references":[48,41],"type":"trigger","data":{"on":48,"references_in_body":[48,41],"name":"projects_delete_user_memberships_trg","sql":"CREATE TRIGGER IF NOT EXISTS projects_delete_user_memberships_trg\nAFTER DELETE ON projects\nBEGIN\n DELETE FROM user_memberships\n WHERE\n parent_type = 'Celest::Project'\n AND parent_id = OLD.id;\nEND;"}},{"id":50,"references":[2,48],"type":"table","data":{"name":"project_environments","was_declared_in_moor":true,"columns":[{"name":"id","getter_name":"id","moor_type":"string","nullable":false,"customConstraints":"NOT NULL PRIMARY KEY","default_dart":null,"default_client_dart":null,"dsl_features":["primary-key"]},{"name":"parent_type","getter_name":"parentType","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"parent_id","getter_name":"parentId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"project_environment_id","getter_name":"projectEnvironmentId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"state","getter_name":"state","moor_type":"string","nullable":false,"customConstraints":"NOT NULL DEFAULT 'CREATING'","default_dart":"const CustomExpression('\\'CREATING\\'')","default_client_dart":null,"dsl_features":[]},{"name":"display_name","getter_name":"displayName","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"create_time","getter_name":"createTime","moor_type":"dateTime","nullable":false,"customConstraints":"NOT NULL DEFAULT (unixepoch('now', 'subsec'))","default_dart":"const CustomExpression('unixepoch(\\'now\\', \\'subsec\\')')","default_client_dart":null,"dsl_features":[]},{"name":"update_time","getter_name":"updateTime","moor_type":"dateTime","nullable":false,"customConstraints":"NOT NULL DEFAULT (unixepoch('now', 'subsec'))","default_dart":"const CustomExpression('unixepoch(\\'now\\', \\'subsec\\')')","default_client_dart":null,"dsl_features":[]},{"name":"delete_time","getter_name":"deleteTime","moor_type":"dateTime","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"annotations","getter_name":"annotations","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"reconciling","getter_name":"reconciling","moor_type":"bool","nullable":false,"customConstraints":"NOT NULL GENERATED ALWAYS AS (state IN ('CREATING', 'UPDATING', 'DELETING')) VIRTUAL","default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"etag","getter_name":"etag","moor_type":"string","nullable":false,"customConstraints":"NOT NULL GENERATED ALWAYS AS (hex(md5(json_array(id, parent_type, parent_id, project_environment_id, state, display_name, create_time, update_time, delete_time, annotations, reconciling)))) STORED","default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]}],"is_virtual":false,"without_rowid":false,"constraints":["CHECK(parent_type = 'Celest::Project')","CONSTRAINT project_environments_parent_fk FOREIGN KEY(parent_type, parent_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE CASCADE","CONSTRAINT project_environments_organization_fk FOREIGN KEY(parent_id)REFERENCES projects(id)ON UPDATE CASCADE ON DELETE CASCADE","CONSTRAINT project_environments_project_environment_id_unique_idx UNIQUE(project_environment_id, parent_id)"],"unique_keys":[["project_environment_id","parent_id"]]}},{"id":51,"references":[50,41],"type":"trigger","data":{"on":50,"references_in_body":[50,41],"name":"project_environments_delete_user_memberships_trg","sql":"CREATE TRIGGER IF NOT EXISTS project_environments_delete_user_memberships_trg\nAFTER DELETE ON project_environments\nBEGIN\n DELETE FROM user_memberships\n WHERE\n parent_type = 'Celest::Project::Environment'\n AND parent_id = OLD.id;\nEND;"}},{"id":52,"references":[50],"type":"index","data":{"on":50,"name":"project_environments_parent_idx","sql":"CREATE INDEX IF NOT EXISTS project_environments_parent_idx ON project_environments(parent_type, parent_id);","unique":false,"columns":[]}},{"id":53,"references":[50],"type":"trigger","data":{"on":50,"references_in_body":[50],"name":"project_environments_update_time_trg","sql":"CREATE TRIGGER IF NOT EXISTS project_environments_update_time_trg\nAFTER UPDATE ON project_environments\nBEGIN\n UPDATE project_environments\n SET update_time = unixepoch('now', 'subsec')\n WHERE id = OLD.id;\nEND;"}},{"id":54,"references":[50,2,4],"type":"trigger","data":{"on":50,"references_in_body":[50,2,4],"name":"project_environments_create_trg","sql":"CREATE TRIGGER IF NOT EXISTS project_environments_create_trg\nBEFORE INSERT ON project_environments\nBEGIN\n INSERT INTO cedar_entities(entity_type, entity_id)\n VALUES ('Celest::Project::Environment', NEW.id);\n INSERT INTO cedar_relationships(entity_type, entity_id, parent_type, parent_id)\n VALUES ('Celest::Project::Environment', NEW.id, NEW.parent_type, NEW.parent_id);\nEND;"}},{"id":55,"references":[50,4],"type":"trigger","data":{"on":50,"references_in_body":[50,4],"name":"project_environments_set_parent_trg","sql":"CREATE TRIGGER IF NOT EXISTS project_environments_set_parent_trg\nAFTER UPDATE OF parent_type, parent_id ON project_environments\nWHEN OLD.parent_type != NEW.parent_type OR OLD.parent_id != NEW.parent_id\nBEGIN\n UPDATE cedar_relationships\n SET \n parent_type = NEW.parent_type,\n parent_id = NEW.parent_id\n WHERE \n entity_id = OLD.id \n AND entity_type = 'Celest::Project::Environment';\nEND;"}},{"id":56,"references":[50,4,2],"type":"trigger","data":{"on":50,"references_in_body":[50,4,2],"name":"project_environments_delete_trg","sql":"CREATE TRIGGER IF NOT EXISTS project_environments_delete_trg\nAFTER DELETE ON project_environments\nBEGIN\n DELETE FROM cedar_relationships\n WHERE \n entity_id = OLD.id \n AND entity_type = 'Celest::Project::Environment';\n DELETE FROM cedar_entities\n WHERE\n entity_id = OLD.id\n AND entity_type = 'Celest::Project::Environment';\nEND;"}},{"id":57,"references":[50],"type":"table","data":{"name":"project_environment_asts","was_declared_in_moor":true,"columns":[{"name":"project_environment_id","getter_name":"projectEnvironmentId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL PRIMARY KEY","default_dart":null,"default_client_dart":null,"dsl_features":["primary-key"]},{"name":"ast","getter_name":"ast","moor_type":"blob","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"version","getter_name":"version","moor_type":"int","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"digest","getter_name":"digest","moor_type":"string","nullable":false,"customConstraints":"NOT NULL GENERATED ALWAYS AS (hex(md5(ast))) STORED","default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]}],"is_virtual":false,"without_rowid":true,"constraints":["CONSTRAINT fk_environment_metadata_project_environment_id FOREIGN KEY(project_environment_id)REFERENCES project_environments(id)ON UPDATE CASCADE ON DELETE CASCADE"]}},{"id":58,"references":[50],"type":"table","data":{"name":"project_environment_assets","was_declared_in_moor":true,"columns":[{"name":"project_environment_id","getter_name":"projectEnvironmentId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"type","getter_name":"type","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"bucket","getter_name":"bucket","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"name","getter_name":"name","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"etag","getter_name":"etag","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":true,"constraints":["PRIMARY KEY(project_environment_id, name)","CONSTRAINT fk_environment_assets_project_environment_id FOREIGN KEY(project_environment_id)REFERENCES project_environments(id)ON UPDATE CASCADE ON DELETE CASCADE"],"explicit_pk":["project_environment_id","name"]}},{"id":59,"references":[50],"type":"table","data":{"name":"project_environment_states","was_declared_in_moor":true,"columns":[{"name":"project_environment_id","getter_name":"projectEnvironmentId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL PRIMARY KEY","default_dart":null,"default_client_dart":null,"dsl_features":["primary-key"]},{"name":"fly_app_name","getter_name":"flyAppName","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"fly_volume_name","getter_name":"flyVolumeName","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"domain_name","getter_name":"domainName","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":true,"constraints":["CONSTRAINT fk_project_environment_state_project_environment_id FOREIGN KEY(project_environment_id)REFERENCES project_environments(id)ON UPDATE CASCADE ON DELETE CASCADE"]}},{"id":60,"references":[48],"type":"index","data":{"on":48,"name":"projects_fk_parent_idx","sql":"CREATE INDEX IF NOT EXISTS projects_fk_parent_idx ON projects(parent_type, parent_id);","unique":false,"columns":[]}},{"id":61,"references":[48],"type":"trigger","data":{"on":48,"references_in_body":[48],"name":"projects_update_time_trg","sql":"CREATE TRIGGER IF NOT EXISTS projects_update_time_trg\nAFTER UPDATE ON projects\nBEGIN\n UPDATE projects\n SET update_time = unixepoch('now', 'subsec')\n WHERE id = OLD.id;\nEND;"}},{"id":62,"references":[48,2,4],"type":"trigger","data":{"on":48,"references_in_body":[48,2,4],"name":"projects_create_trg","sql":"CREATE TRIGGER IF NOT EXISTS projects_create_trg\nBEFORE INSERT ON projects\nBEGIN\n INSERT INTO cedar_entities(entity_type, entity_id)\n VALUES ('Celest::Project', NEW.id);\n INSERT INTO cedar_relationships(entity_type, entity_id, parent_type, parent_id)\n VALUES ('Celest::Project', NEW.id, NEW.parent_type, NEW.parent_id);\nEND;"}},{"id":63,"references":[48,4],"type":"trigger","data":{"on":48,"references_in_body":[48,4],"name":"projects_set_parent_trg","sql":"CREATE TRIGGER IF NOT EXISTS projects_set_parent_trg\nAFTER UPDATE OF parent_type, parent_id ON projects\nWHEN OLD.parent_type != NEW.parent_type OR OLD.parent_id != NEW.parent_id\nBEGIN\n UPDATE cedar_relationships\n SET \n parent_type = NEW.parent_type,\n parent_id = NEW.parent_id\n WHERE \n entity_id = OLD.id \n AND entity_type = 'Celest::Project';\nEND;"}},{"id":64,"references":[48,4,2],"type":"trigger","data":{"on":48,"references_in_body":[48,4,2],"name":"projects_delete_trg","sql":"CREATE TRIGGER IF NOT EXISTS projects_delete_trg\nAFTER DELETE ON projects\nBEGIN\n DELETE FROM cedar_relationships\n WHERE \n entity_type = 'Celest::Project'\n AND entity_id = OLD.id;\n DELETE FROM cedar_relationships\n WHERE \n parent_type = 'Celest::Project'\n AND parent_id = OLD.id;\n DELETE FROM cedar_entities\n WHERE\n entity_id = OLD.id\n AND entity_type = 'Celest::Project';\nEND;"}},{"id":65,"references":[46],"type":"index","data":{"on":46,"name":"organizations_parent_idx","sql":"CREATE INDEX IF NOT EXISTS organizations_parent_idx ON organizations(parent_type, parent_id);","unique":false,"columns":[]}},{"id":66,"references":[46],"type":"trigger","data":{"on":46,"references_in_body":[46],"name":"organizations_update_time","sql":"CREATE TRIGGER IF NOT EXISTS organizations_update_time\nAFTER UPDATE ON organizations\nBEGIN\n UPDATE organizations\n SET update_time = unixepoch('now', 'subsec')\n WHERE id = OLD.id;\nEND;"}},{"id":67,"references":[46,2],"type":"trigger","data":{"on":46,"references_in_body":[46,2],"name":"organizations_create","sql":"CREATE TRIGGER IF NOT EXISTS organizations_create\nBEFORE INSERT ON organizations\nBEGIN\n INSERT INTO cedar_entities(entity_type, entity_id)\n VALUES ('Celest::Organization', NEW.id);\nEND;"}},{"id":68,"references":[46,4],"type":"trigger","data":{"on":46,"references_in_body":[46,4],"name":"organizations_create_parent","sql":"CREATE TRIGGER IF NOT EXISTS organizations_create_parent\nAFTER INSERT ON organizations\nWHEN NEW.parent_id IS NOT NULL\nBEGIN\n INSERT INTO cedar_relationships(entity_type, entity_id, parent_type, parent_id)\n VALUES ('Celest::Organization', NEW.id, NEW.parent_type, NEW.parent_id);\nEND;"}},{"id":69,"references":[46,4],"type":"trigger","data":{"on":46,"references_in_body":[46,4],"name":"organizations_add_parent","sql":"CREATE TRIGGER IF NOT EXISTS organizations_add_parent\nAFTER UPDATE OF parent_id ON organizations\nWHEN OLD.parent_id IS NULL AND NEW.parent_id IS NOT NULL\nBEGIN\n INSERT INTO cedar_relationships(entity_type, entity_id, parent_type, parent_id)\n VALUES ('Celest::Organization', NEW.id, NEW.parent_type, NEW.parent_id);\nEND;"}},{"id":70,"references":[46,4],"type":"trigger","data":{"on":46,"references_in_body":[46,4],"name":"organizations_set_parent","sql":"CREATE TRIGGER IF NOT EXISTS organizations_set_parent\nAFTER UPDATE OF parent_type, parent_id ON organizations\nWHEN (OLD.parent_type != NEW.parent_type OR OLD.parent_id != NEW.parent_id) AND NEW.parent_id IS NOT NULL\nBEGIN\n UPDATE cedar_relationships\n SET \n parent_type = NEW.parent_type,\n parent_id = NEW.parent_id\n WHERE \n entity_id = OLD.id \n AND entity_type = 'Celest::Organization';\nEND;"}},{"id":71,"references":[46,4],"type":"trigger","data":{"on":46,"references_in_body":[46,4],"name":"organizations_remove_parent","sql":"CREATE TRIGGER IF NOT EXISTS organizations_remove_parent\nAFTER UPDATE OF parent_id ON organizations\nWHEN OLD.parent_id IS NOT NULL AND NEW.parent_id IS NULL\nBEGIN\n DELETE FROM cedar_relationships\n WHERE \n entity_id = OLD.id \n AND entity_type = 'Celest::Organization'\n AND parent_id = OLD.parent_id\n AND parent_type = OLD.parent_type;\nEND;"}},{"id":72,"references":[46,4,2],"type":"trigger","data":{"on":46,"references_in_body":[46,4,2],"name":"organizations_delete","sql":"CREATE TRIGGER IF NOT EXISTS organizations_delete\nAFTER DELETE ON organizations\nBEGIN\n DELETE FROM cedar_relationships\n WHERE \n entity_type = 'Celest::Organization'\n AND entity_id = OLD.id;\n DELETE FROM cedar_relationships\n WHERE \n parent_type = 'Celest::Organization'\n AND parent_id = OLD.id;\n DELETE FROM cedar_entities\n WHERE\n entity_type = 'Celest::Organization'\n AND entity_id = OLD.id;\nEND;"}},{"id":73,"references":[],"type":"table","data":{"name":"operations","was_declared_in_moor":true,"columns":[{"name":"id","getter_name":"id","moor_type":"string","nullable":false,"customConstraints":"NOT NULL PRIMARY KEY","default_dart":null,"default_client_dart":null,"dsl_features":["primary-key"]},{"name":"metadata","getter_name":"metadata","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"response","getter_name":"response","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"error","getter_name":"error","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"done","getter_name":"done","moor_type":"bool","nullable":false,"customConstraints":"NOT NULL GENERATED ALWAYS AS (response IS NOT NULL OR error IS NOT NULL) VIRTUAL","default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"create_time","getter_name":"createTime","moor_type":"dateTime","nullable":false,"customConstraints":"NOT NULL DEFAULT (unixepoch('now', 'subsec'))","default_dart":"const CustomExpression('unixepoch(\\'now\\', \\'subsec\\')')","default_client_dart":null,"dsl_features":[]},{"name":"full_resource_name","getter_name":"fullResourceName","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"owner_type","getter_name":"ownerType","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"owner_id","getter_name":"ownerId","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"resource_type","getter_name":"resourceType","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"resource_id","getter_name":"resourceId","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":[]}},{"id":74,"references":[73],"type":"index","data":{"on":73,"name":"operations_fk_owner_idx","sql":"CREATE INDEX IF NOT EXISTS operations_fk_owner_idx ON operations(owner_type, owner_id);","unique":false,"columns":[]}},{"id":75,"references":[73],"type":"index","data":{"on":73,"name":"operations_fk_resource_idx","sql":"CREATE INDEX IF NOT EXISTS operations_fk_resource_idx ON operations(resource_type, resource_id);","unique":false,"columns":[]}},{"id":76,"references":[73,2],"type":"trigger","data":{"on":73,"references_in_body":[73,2],"name":"operations_trigger_create","sql":"CREATE TRIGGER IF NOT EXISTS operations_trigger_create\nBEFORE INSERT ON operations\nBEGIN\n INSERT INTO cedar_entities(entity_type, entity_id)\n VALUES ('Celest::Operation', NEW.id);\nEND;"}},{"id":77,"references":[73,4],"type":"trigger","data":{"on":73,"references_in_body":[73,4],"name":"operations_trigger_create_owner","sql":"CREATE TRIGGER IF NOT EXISTS operations_trigger_create_owner\nAFTER INSERT ON operations\nWHEN NEW.owner_id IS NOT NULL\nBEGIN\n INSERT INTO cedar_relationships(entity_type, entity_id, parent_type, parent_id)\n VALUES ('Celest::Operation', NEW.id, NEW.owner_type, NEW.owner_id);\nEND;"}},{"id":78,"references":[73,4],"type":"trigger","data":{"on":73,"references_in_body":[73,4],"name":"operations_trigger_create_resource","sql":"CREATE TRIGGER IF NOT EXISTS operations_trigger_create_resource\nAFTER INSERT ON operations\nWHEN NEW.resource_id IS NOT NULL\nBEGIN\n INSERT INTO cedar_relationships(entity_type, entity_id, parent_type, parent_id)\n VALUES ('Celest::Operation', NEW.id, NEW.resource_type, NEW.resource_id);\nEND;"}},{"id":79,"references":[73,4],"type":"trigger","data":{"on":73,"references_in_body":[73,4],"name":"operations_trigger_add_owner","sql":"CREATE TRIGGER IF NOT EXISTS operations_trigger_add_owner\nAFTER UPDATE OF owner_id ON operations\nWHEN OLD.owner_id IS NULL AND NEW.owner_id IS NOT NULL\nBEGIN\n INSERT INTO cedar_relationships(entity_type, entity_id, parent_type, parent_id)\n VALUES ('Celest::Operation', NEW.id, NEW.owner_type, NEW.owner_id);\nEND;"}},{"id":80,"references":[73,4],"type":"trigger","data":{"on":73,"references_in_body":[73,4],"name":"operations_trigger_add_resource","sql":"CREATE TRIGGER IF NOT EXISTS operations_trigger_add_resource\nAFTER UPDATE OF resource_id ON operations\nWHEN OLD.resource_id IS NULL AND NEW.resource_id IS NOT NULL\nBEGIN\n INSERT INTO cedar_relationships(entity_type, entity_id, parent_type, parent_id)\n VALUES ('Celest::Operation', NEW.id, NEW.resource_type, NEW.resource_id);\nEND;"}},{"id":81,"references":[73,4],"type":"trigger","data":{"on":73,"references_in_body":[73,4],"name":"operations_trigger_set_owner","sql":"CREATE TRIGGER IF NOT EXISTS operations_trigger_set_owner\nAFTER UPDATE OF owner_type, owner_id ON operations\nWHEN (OLD.owner_type != NEW.owner_type OR OLD.owner_id != NEW.owner_id) AND OLD.owner_id IS NOT NULL AND NEW.owner_id IS NOT NULL\nBEGIN\n UPDATE cedar_relationships\n SET \n parent_type = NEW.owner_type,\n parent_id = NEW.owner_id\n WHERE \n entity_id = OLD.id\n AND entity_type = 'Celest::Operation'\n AND parent_type = OLD.owner_type\n AND parent_id = OLD.owner_id;\nEND;"}},{"id":82,"references":[73,4],"type":"trigger","data":{"on":73,"references_in_body":[73,4],"name":"operations_trigger_set_resource","sql":"CREATE TRIGGER IF NOT EXISTS operations_trigger_set_resource\nAFTER UPDATE OF resource_type, resource_id ON operations\nWHEN (OLD.resource_type != NEW.resource_type OR OLD.resource_id != NEW.resource_id) AND OLD.resource_id IS NOT NULL AND NEW.resource_id IS NOT NULL\nBEGIN\n UPDATE cedar_relationships\n SET \n parent_type = NEW.resource_type,\n parent_id = NEW.resource_id\n WHERE \n entity_id = OLD.id\n AND entity_type = 'Celest::Operation'\n AND parent_type = OLD.resource_type\n AND parent_id = OLD.resource_id;\nEND;"}},{"id":83,"references":[73,4,2],"type":"trigger","data":{"on":73,"references_in_body":[73,4,2],"name":"operations_trigger_delete","sql":"CREATE TRIGGER IF NOT EXISTS operations_trigger_delete\nAFTER DELETE ON operations\nBEGIN\n DELETE FROM cedar_relationships\n WHERE \n entity_id = OLD.id\n AND entity_type = 'Celest::Operation';\n DELETE FROM cedar_entities\n WHERE\n entity_id = OLD.id\n AND entity_type = 'Celest::Operation';\nEND;"}}]} \ No newline at end of file diff --git a/services/celest_cloud_hub/drift_schema/cloud_hub_database/drift_schema_v2.json b/services/celest_cloud_hub/drift_schema/cloud_hub_database/drift_schema_v2.json new file mode 100644 index 000000000..ccb9b9a04 --- /dev/null +++ b/services/celest_cloud_hub/drift_schema/cloud_hub_database/drift_schema_v2.json @@ -0,0 +1 @@ +{"_meta":{"description":"This file contains a serialized version of schema entities for drift.","version":"1.2.0"},"options":{"store_date_time_values_as_text":false},"entities":[{"id":0,"references":[],"type":"table","data":{"name":"cloud_auth_users","was_declared_in_moor":true,"columns":[{"name":"user_id","getter_name":"userId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL PRIMARY KEY","default_dart":null,"default_client_dart":null,"dsl_features":["primary-key"]},{"name":"given_name","getter_name":"givenName","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"family_name","getter_name":"familyName","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"time_zone","getter_name":"timeZone","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"language_code","getter_name":"languageCode","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"create_time","getter_name":"createTime","moor_type":"double","nullable":false,"customConstraints":"NOT NULL DEFAULT (unixepoch('now', 'subsec'))","default_dart":"const CustomExpression('unixepoch(\\'now\\', \\'subsec\\')')","default_client_dart":null,"dsl_features":[]},{"name":"update_time","getter_name":"updateTime","moor_type":"double","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":[]}},{"id":1,"references":[],"type":"table","data":{"name":"cedar_types","was_declared_in_moor":true,"columns":[{"name":"fqn","getter_name":"fqn","moor_type":"string","nullable":false,"customConstraints":"NOT NULL PRIMARY KEY","default_dart":null,"default_client_dart":null,"dsl_features":["primary-key"]}],"is_virtual":false,"without_rowid":false,"constraints":[]}},{"id":2,"references":[1],"type":"table","data":{"name":"cedar_entities","was_declared_in_moor":true,"columns":[{"name":"entity_type","getter_name":"entityType","moor_type":"string","nullable":false,"customConstraints":"NOT NULL REFERENCES cedar_types(fqn)","default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"entity_id","getter_name":"entityId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"attribute_json","getter_name":"attributeJson","moor_type":"string","nullable":false,"customConstraints":"NOT NULL DEFAULT '{}'","default_dart":"const CustomExpression('\\'{}\\'')","default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const CedarAttributesConverter()","dart_type_name":"Map"}},{"name":"entity_json","getter_name":"entityJson","moor_type":"string","nullable":false,"customConstraints":"NOT NULL GENERATED ALWAYS AS (json_object('type', entity_type, 'id', entity_id)) VIRTUAL","default_dart":null,"default_client_dart":null,"dsl_features":["unknown"],"type_converter":{"dart_expr":"const CedarEntityUidConverter()","dart_type_name":"EntityUid"}}],"is_virtual":false,"without_rowid":true,"constraints":["CONSTRAINT cedar_entities_pk PRIMARY KEY(entity_type, entity_id)ON CONFLICT IGNORE"],"explicit_pk":["entity_type","entity_id"]}},{"id":3,"references":[0,2],"type":"trigger","data":{"on":0,"references_in_body":[0,2],"name":"cloud_auth_users_create_trg","sql":"CREATE TRIGGER IF NOT EXISTS cloud_auth_users_create_trg\nBEFORE INSERT ON cloud_auth_users\nBEGIN\n INSERT INTO cedar_entities(entity_type, entity_id)\n VALUES ('Celest::User', NEW.user_id);\nEND;"}},{"id":4,"references":[2],"type":"table","data":{"name":"cedar_relationships","was_declared_in_moor":true,"columns":[{"name":"entity_type","getter_name":"entityType","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"entity_id","getter_name":"entityId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"entity_json","getter_name":"entityJson","moor_type":"string","nullable":false,"customConstraints":"NOT NULL GENERATED ALWAYS AS (json_object('type', entity_type, 'id', entity_id)) VIRTUAL","default_dart":null,"default_client_dart":null,"dsl_features":["unknown"],"type_converter":{"dart_expr":"const CedarEntityUidConverter()","dart_type_name":"EntityUid"}},{"name":"parent_type","getter_name":"parentType","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"parent_id","getter_name":"parentId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"parent_json","getter_name":"parentJson","moor_type":"string","nullable":false,"customConstraints":"NOT NULL GENERATED ALWAYS AS (json_object('type', parent_type, 'id', parent_id)) VIRTUAL","default_dart":null,"default_client_dart":null,"dsl_features":["unknown"],"type_converter":{"dart_expr":"const CedarEntityUidConverter()","dart_type_name":"EntityUid"}}],"is_virtual":false,"without_rowid":true,"constraints":["CONSTRAINT cedar_relationships_pk PRIMARY KEY(entity_type, entity_id, parent_type, parent_id)ON CONFLICT IGNORE","CONSTRAINT cedar_relationships_fk_entity FOREIGN KEY(entity_type, entity_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE CASCADE","CONSTRAINT cedar_relationships_fk_parent FOREIGN KEY(parent_type, parent_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE CASCADE"],"explicit_pk":["entity_type","entity_id","parent_type","parent_id"]}},{"id":5,"references":[0,4,2],"type":"trigger","data":{"on":0,"references_in_body":[0,4,2],"name":"cloud_auth_users_delete_trg","sql":"CREATE TRIGGER IF NOT EXISTS cloud_auth_users_delete_trg\nAFTER DELETE ON cloud_auth_users\nBEGIN\n DELETE FROM cedar_relationships\n WHERE \n (entity_type = 'Celest::User' AND entity_id = OLD.user_id)\n OR (parent_type = 'Celest::User' AND parent_id = OLD.user_id);\n DELETE FROM cedar_entities\n WHERE\n entity_id = OLD.user_id\n AND entity_type = 'Celest::User';\nEND;"}},{"id":6,"references":[0],"type":"table","data":{"name":"cloud_auth_user_emails","was_declared_in_moor":true,"columns":[{"name":"user_id","getter_name":"userId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"email","getter_name":"email","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"is_verified","getter_name":"isVerified","moor_type":"bool","nullable":false,"customConstraints":"NOT NULL DEFAULT FALSE","default_dart":"const CustomExpression('FALSE')","default_client_dart":null,"dsl_features":[]},{"name":"is_primary","getter_name":"isPrimary","moor_type":"bool","nullable":false,"customConstraints":"NOT NULL DEFAULT FALSE","default_dart":"const CustomExpression('FALSE')","default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":true,"constraints":["CONSTRAINT cloud_auth_user_emails_pk PRIMARY KEY(user_id, email)","CONSTRAINT cloud_auth_user_emails_user_fk FOREIGN KEY(user_id)REFERENCES cloud_auth_users(user_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED"],"explicit_pk":["user_id","email"]}},{"id":7,"references":[0],"type":"table","data":{"name":"cloud_auth_user_phone_numbers","was_declared_in_moor":true,"columns":[{"name":"user_id","getter_name":"userId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"phone_number","getter_name":"phoneNumber","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"is_verified","getter_name":"isVerified","moor_type":"bool","nullable":false,"customConstraints":"NOT NULL DEFAULT FALSE","default_dart":"const CustomExpression('FALSE')","default_client_dart":null,"dsl_features":[]},{"name":"is_primary","getter_name":"isPrimary","moor_type":"bool","nullable":false,"customConstraints":"NOT NULL DEFAULT FALSE","default_dart":"const CustomExpression('FALSE')","default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":true,"constraints":["CONSTRAINT cloud_auth_user_phone_numbers_pk PRIMARY KEY(user_id, phone_number)","CONSTRAINT cloud_auth_user_phone_numbers_user_fk FOREIGN KEY(user_id)REFERENCES cloud_auth_users(user_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED"],"explicit_pk":["user_id","phone_number"]}},{"id":8,"references":[],"type":"table","data":{"name":"cloud_auth_projects","was_declared_in_moor":true,"columns":[{"name":"project_id","getter_name":"projectId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL PRIMARY KEY","default_dart":null,"default_client_dart":null,"dsl_features":["primary-key"]},{"name":"version","getter_name":"version","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"resolved_ast","getter_name":"resolvedAst","moor_type":"blob","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const ResolvedProjectConverter()","dart_type_name":"ResolvedProject"}},{"name":"etag","getter_name":"etag","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":[]}},{"id":9,"references":[8],"type":"table","data":{"name":"cloud_auth_apis","was_declared_in_moor":true,"columns":[{"name":"api_id","getter_name":"apiId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL PRIMARY KEY","default_dart":null,"default_client_dart":null,"dsl_features":["primary-key"]},{"name":"project_id","getter_name":"projectId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"resolved_ast","getter_name":"resolvedAst","moor_type":"blob","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const ResolvedApiConverter()","dart_type_name":"ResolvedApi"}},{"name":"etag","getter_name":"etag","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":["CONSTRAINT cloud_auth_apis_project_fk FOREIGN KEY(project_id)REFERENCES cloud_auth_projects(project_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED"]}},{"id":10,"references":[9],"type":"index","data":{"on":9,"name":"cloud_auth_apis_project_idx","sql":"CREATE INDEX IF NOT EXISTS cloud_auth_apis_project_idx ON cloud_auth_apis(project_id);","unique":false,"columns":[]}},{"id":11,"references":[9,2],"type":"trigger","data":{"on":9,"references_in_body":[9,2],"name":"cloud_auth_apis_create_trg","sql":"CREATE TRIGGER IF NOT EXISTS cloud_auth_apis_create_trg\nBEFORE INSERT ON cloud_auth_apis\nBEGIN\n INSERT INTO cedar_entities(entity_type, entity_id)\n VALUES ('Celest::Api', NEW.api_id);\nEND;"}},{"id":12,"references":[9,4,2],"type":"trigger","data":{"on":9,"references_in_body":[9,4,2],"name":"cloud_auth_apis_delete_trg","sql":"CREATE TRIGGER IF NOT EXISTS cloud_auth_apis_delete_trg\nAFTER DELETE ON cloud_auth_apis\nBEGIN\n DELETE FROM cedar_relationships\n WHERE \n entity_type = 'Celest::Api'\n AND entity_id = OLD.api_id;\n DELETE FROM cedar_relationships\n WHERE \n parent_type = 'Celest::Api'\n AND parent_id = OLD.api_id;\n DELETE FROM cedar_entities\n WHERE\n entity_type = 'Celest::Api'\n AND entity_id = OLD.api_id;\nEND;"}},{"id":13,"references":[9],"type":"table","data":{"name":"cloud_auth_functions","was_declared_in_moor":true,"columns":[{"name":"function_id","getter_name":"functionId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL PRIMARY KEY","default_dart":null,"default_client_dart":null,"dsl_features":["primary-key"]},{"name":"api_id","getter_name":"apiId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"resolved_ast","getter_name":"resolvedAst","moor_type":"blob","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const ResolvedFunctionConverter()","dart_type_name":"ResolvedCloudFunction"}},{"name":"etag","getter_name":"etag","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":["CONSTRAINT cloud_auth_functions_api_fk FOREIGN KEY(api_id)REFERENCES cloud_auth_apis(api_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED"]}},{"id":14,"references":[13],"type":"index","data":{"on":13,"name":"cloud_auth_functions_api_idx","sql":"CREATE INDEX IF NOT EXISTS cloud_auth_functions_api_idx ON cloud_auth_functions(api_id);","unique":false,"columns":[]}},{"id":15,"references":[13,2,4],"type":"trigger","data":{"on":13,"references_in_body":[13,2,4],"name":"cloud_auth_functions_create_trg","sql":"CREATE TRIGGER IF NOT EXISTS cloud_auth_functions_create_trg\nBEFORE INSERT ON cloud_auth_functions\nBEGIN\n INSERT INTO cedar_entities(entity_type, entity_id)\n VALUES ('Celest::Function', NEW.function_id);\n INSERT INTO cedar_relationships(entity_type, entity_id, parent_type, parent_id)\n VALUES ('Celest::Function', NEW.function_id, 'Celest::Api', NEW.api_id);\nEND;"}},{"id":16,"references":[13,4,2],"type":"trigger","data":{"on":13,"references_in_body":[13,4,2],"name":"cloud_auth_functions_delete_trg","sql":"CREATE TRIGGER IF NOT EXISTS cloud_auth_functions_delete_trg\nAFTER DELETE ON cloud_auth_functions\nBEGIN\n DELETE FROM cedar_relationships\n WHERE \n entity_type = 'Celest::Function'\n AND entity_id = OLD.function_id;\n DELETE FROM cedar_relationships\n WHERE \n parent_type = 'Celest::Function'\n AND parent_id = OLD.function_id;\n DELETE FROM cedar_entities\n WHERE\n entity_type = 'Celest::Function'\n AND entity_id = OLD.function_id;\nEND;"}},{"id":17,"references":[],"type":"table","data":{"name":"cloud_auth_meta","was_declared_in_moor":true,"columns":[{"name":"schema_version","getter_name":"schemaVersion","moor_type":"int","nullable":false,"customConstraints":"NOT NULL PRIMARY KEY","default_dart":null,"default_client_dart":null,"dsl_features":["primary-key"]}],"is_virtual":false,"without_rowid":false,"constraints":[]}},{"id":18,"references":[],"type":"table","data":{"name":"cloud_auth_crypto_keys","was_declared_in_moor":true,"columns":[{"name":"crypto_key_id","getter_name":"cryptoKeyId","moor_type":"blob","nullable":false,"customConstraints":"NOT NULL PRIMARY KEY","default_dart":null,"default_client_dart":null,"dsl_features":["primary-key"]},{"name":"key_purpose","getter_name":"keyPurpose","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"key_algorithm","getter_name":"keyAlgorithm","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"key_material","getter_name":"keyMaterial","moor_type":"blob","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"external_crypto_key_id","getter_name":"externalCryptoKeyId","moor_type":"string","nullable":true,"customConstraints":"UNIQUE","default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]}],"is_virtual":false,"without_rowid":false,"constraints":["CHECK(key_material IS NOT NULL OR external_crypto_key_id IS NOT NULL)"]}},{"id":19,"references":[18],"type":"index","data":{"on":18,"name":"cloud_auth_crypto_keys_external_crypto_key_id_idx","sql":"CREATE INDEX IF NOT EXISTS cloud_auth_crypto_keys_external_crypto_key_id_idx ON cloud_auth_crypto_keys(external_crypto_key_id);","unique":false,"columns":[]}},{"id":20,"references":[0,18],"type":"table","data":{"name":"cloud_auth_sessions","was_declared_in_moor":true,"columns":[{"name":"rowid","getter_name":"rowid","moor_type":"int","nullable":false,"customConstraints":"PRIMARY KEY AUTOINCREMENT","default_dart":null,"default_client_dart":null,"dsl_features":["auto-increment"]},{"name":"session_id","getter_name":"sessionId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL UNIQUE","default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"crypto_key_id","getter_name":"cryptoKeyId","moor_type":"blob","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"user_id","getter_name":"userId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"client_info","getter_name":"clientInfo","moor_type":"blob","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const SessionClientConverter()","dart_type_name":"SessionClient"}},{"name":"authentication_factor","getter_name":"authenticationFactor","moor_type":"blob","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const AuthenticationFactorConverter()","dart_type_name":"AuthenticationFactor"}},{"name":"state","getter_name":"state","moor_type":"blob","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const SessionStateConverter()","dart_type_name":"SessionState"}},{"name":"ip_address","getter_name":"ipAddress","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"external_session_id","getter_name":"externalSessionId","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"create_time","getter_name":"createTime","moor_type":"double","nullable":false,"customConstraints":"NOT NULL DEFAULT (unixepoch('now', 'subsec'))","default_dart":"const CustomExpression('unixepoch(\\'now\\', \\'subsec\\')')","default_client_dart":null,"dsl_features":[]},{"name":"update_time","getter_name":"updateTime","moor_type":"double","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"expire_time","getter_name":"expireTime","moor_type":"double","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":["CONSTRAINT cloud_auth_sessions_user_fk FOREIGN KEY(user_id)REFERENCES cloud_auth_users(user_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED","CONSTRAINT cloud_auth_sessions_key_fk FOREIGN KEY(crypto_key_id)REFERENCES cloud_auth_crypto_keys(crypto_key_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED"]}},{"id":21,"references":[20],"type":"index","data":{"on":20,"name":"cloud_auth_sessions_user_idx","sql":"CREATE INDEX IF NOT EXISTS cloud_auth_sessions_user_idx ON cloud_auth_sessions(user_id);","unique":false,"columns":[]}},{"id":22,"references":[20],"type":"index","data":{"on":20,"name":"cloud_auth_sessions_crypto_key_idx","sql":"CREATE INDEX IF NOT EXISTS cloud_auth_sessions_crypto_key_idx ON cloud_auth_sessions(crypto_key_id);","unique":false,"columns":[]}},{"id":23,"references":[20],"type":"index","data":{"on":20,"name":"cloud_auth_sessions_external_session_id_idx","sql":"CREATE INDEX IF NOT EXISTS cloud_auth_sessions_external_session_id_idx ON cloud_auth_sessions(external_session_id);","unique":false,"columns":[]}},{"id":24,"references":[20],"type":"trigger","data":{"on":20,"references_in_body":[20],"name":"cloud_auth_sessions_update_time_trg","sql":"CREATE TRIGGER IF NOT EXISTS cloud_auth_sessions_update_time_trg\nAFTER UPDATE ON cloud_auth_sessions\nBEGIN\n UPDATE cloud_auth_sessions\n SET update_time = unixepoch('now', 'subsec')\n WHERE rowid = OLD.rowid;\nEND;"}},{"id":25,"references":[20],"type":"table","data":{"name":"cloud_auth_otp_codes","was_declared_in_moor":true,"columns":[{"name":"rowid","getter_name":"rowid","moor_type":"int","nullable":false,"customConstraints":"PRIMARY KEY AUTOINCREMENT","default_dart":null,"default_client_dart":null,"dsl_features":["auto-increment"]},{"name":"session_id","getter_name":"sessionId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL UNIQUE","default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"resend_attempt","getter_name":"resendAttempt","moor_type":"int","nullable":false,"customConstraints":"NOT NULL DEFAULT 0","default_dart":"const CustomExpression('0')","default_client_dart":null,"dsl_features":[]},{"name":"verify_attempt","getter_name":"verifyAttempt","moor_type":"int","nullable":false,"customConstraints":"NOT NULL DEFAULT 0","default_dart":"const CustomExpression('0')","default_client_dart":null,"dsl_features":[]},{"name":"update_time","getter_name":"updateTime","moor_type":"double","nullable":false,"customConstraints":"NOT NULL DEFAULT (unixepoch('now', 'subsec'))","default_dart":"const CustomExpression('unixepoch(\\'now\\', \\'subsec\\')')","default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":["CONSTRAINT cloud_auth_otp_codes_session_id_fk FOREIGN KEY(session_id)REFERENCES cloud_auth_sessions(session_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED"]}},{"id":26,"references":[25],"type":"index","data":{"on":25,"name":"cloud_auth_otp_codes_session_id_idx","sql":"CREATE INDEX IF NOT EXISTS cloud_auth_otp_codes_session_id_idx ON cloud_auth_otp_codes(session_id);","unique":false,"columns":[]}},{"id":27,"references":[18,2],"type":"table","data":{"name":"cloud_auth_corks","was_declared_in_moor":true,"columns":[{"name":"cork_id","getter_name":"corkId","moor_type":"blob","nullable":false,"customConstraints":"NOT NULL PRIMARY KEY","default_dart":null,"default_client_dart":null,"dsl_features":["primary-key"]},{"name":"crypto_key_id","getter_name":"cryptoKeyId","moor_type":"blob","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"bearer_type","getter_name":"bearerType","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"bearer_id","getter_name":"bearerId","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"audience_type","getter_name":"audienceType","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"audience_id","getter_name":"audienceId","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"issuer_type","getter_name":"issuerType","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"issuer_id","getter_name":"issuerId","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"create_time","getter_name":"createTime","moor_type":"double","nullable":false,"customConstraints":"NOT NULL DEFAULT (unixepoch('now', 'subsec'))","default_dart":"const CustomExpression('unixepoch(\\'now\\', \\'subsec\\')')","default_client_dart":null,"dsl_features":[]},{"name":"expire_time","getter_name":"expireTime","moor_type":"double","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"last_use_time","getter_name":"lastUseTime","moor_type":"double","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":["CONSTRAINT cloud_auth_corks_crypto_key_fk FOREIGN KEY(crypto_key_id)REFERENCES cloud_auth_crypto_keys(crypto_key_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED","CONSTRAINT cloud_auth_corks_bearer_fk FOREIGN KEY(bearer_type, bearer_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED","CONSTRAINT cloud_auth_corks_audience_fk FOREIGN KEY(audience_type, audience_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED","CONSTRAINT cloud_auth_corks_issuer_fk FOREIGN KEY(issuer_type, issuer_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED"]}},{"id":28,"references":[27],"type":"index","data":{"on":27,"name":"cloud_auth_corks_crypto_key_idx","sql":"CREATE INDEX IF NOT EXISTS cloud_auth_corks_crypto_key_idx ON cloud_auth_corks(crypto_key_id);","unique":false,"columns":[]}},{"id":29,"references":[27],"type":"index","data":{"on":27,"name":"cloud_auth_corks_bearer_idx","sql":"CREATE INDEX IF NOT EXISTS cloud_auth_corks_bearer_idx ON cloud_auth_corks(bearer_type, bearer_id);","unique":false,"columns":[]}},{"id":30,"references":[27],"type":"index","data":{"on":27,"name":"cloud_auth_corks_audience_idx","sql":"CREATE INDEX IF NOT EXISTS cloud_auth_corks_audience_idx ON cloud_auth_corks(audience_type, audience_id);","unique":false,"columns":[]}},{"id":31,"references":[27],"type":"index","data":{"on":27,"name":"cloud_auth_corks_issuer_idx","sql":"CREATE INDEX IF NOT EXISTS cloud_auth_corks_issuer_idx ON cloud_auth_corks(issuer_type, issuer_id);","unique":false,"columns":[]}},{"id":32,"references":[4],"type":"index","data":{"on":4,"name":"cedar_relationships_fk_entity_idx","sql":"CREATE INDEX IF NOT EXISTS cedar_relationships_fk_entity_idx ON cedar_relationships(entity_type, entity_id);","unique":false,"columns":[]}},{"id":33,"references":[4],"type":"index","data":{"on":4,"name":"cedar_relationships_fk_parent_idx","sql":"CREATE INDEX IF NOT EXISTS cedar_relationships_fk_parent_idx ON cedar_relationships(parent_type, parent_id);","unique":false,"columns":[]}},{"id":34,"references":[],"type":"table","data":{"name":"cedar_policies","was_declared_in_moor":true,"columns":[{"name":"id","getter_name":"id","moor_type":"string","nullable":false,"customConstraints":"NOT NULL PRIMARY KEY","default_dart":null,"default_client_dart":null,"dsl_features":["primary-key"]},{"name":"policy_id","getter_name":"policyId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL UNIQUE","default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"policy","getter_name":"policy","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const CedarPolicyConverter()","dart_type_name":"Policy"}},{"name":"enforcement_level","getter_name":"enforcementLevel","moor_type":"int","nullable":false,"customConstraints":"NOT NULL DEFAULT 1","default_dart":"const CustomExpression('1')","default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":["CHECK(enforcement_level IN (0, 1))"]}},{"id":35,"references":[],"type":"table","data":{"name":"cedar_policy_templates","was_declared_in_moor":true,"columns":[{"name":"id","getter_name":"id","moor_type":"string","nullable":false,"customConstraints":"NOT NULL PRIMARY KEY","default_dart":null,"default_client_dart":null,"dsl_features":["primary-key"]},{"name":"template_id","getter_name":"templateId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL UNIQUE","default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"template","getter_name":"template","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const CedarPolicyConverter()","dart_type_name":"Policy"}}],"is_virtual":false,"without_rowid":false,"constraints":["CHECK(template IS NOT NULL OR template IS NOT NULL)"]}},{"id":36,"references":[35,2],"type":"table","data":{"name":"cedar_policy_template_links","was_declared_in_moor":true,"columns":[{"name":"id","getter_name":"id","moor_type":"string","nullable":false,"customConstraints":"NOT NULL PRIMARY KEY","default_dart":null,"default_client_dart":null,"dsl_features":["primary-key"]},{"name":"policy_id","getter_name":"policyId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL UNIQUE","default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"template_id","getter_name":"templateId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"principal_type","getter_name":"principalType","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"principal_id","getter_name":"principalId","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"resource_type","getter_name":"resourceType","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"resource_id","getter_name":"resourceId","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"enforcement_level","getter_name":"enforcementLevel","moor_type":"int","nullable":false,"customConstraints":"NOT NULL DEFAULT 1","default_dart":"const CustomExpression('1')","default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":["CHECK(principal_type IS NOT NULL AND principal_id IS NOT NULL OR resource_type IS NOT NULL AND resource_id IS NOT NULL)","CHECK(enforcement_level IN (0, 1))","CONSTRAINT cedar_policy_template_links_fk_template_id FOREIGN KEY(template_id)REFERENCES cedar_policy_templates(template_id)ON UPDATE CASCADE ON DELETE CASCADE","CONSTRAINT cedar_policy_template_links_fk_principal FOREIGN KEY(principal_type, principal_id)REFERENCES cedar_entities(entity_type, entity_id)ON DELETE CASCADE","CONSTRAINT cedar_policy_template_links_fk_resource FOREIGN KEY(resource_type, resource_id)REFERENCES cedar_entities(entity_type, entity_id)ON DELETE CASCADE"]}},{"id":37,"references":[36],"type":"index","data":{"on":36,"name":"cedar_policy_template_links_fk_template_id_idx","sql":"CREATE INDEX IF NOT EXISTS cedar_policy_template_links_fk_template_id_idx ON cedar_policy_template_links(template_id);","unique":false,"columns":[]}},{"id":38,"references":[36],"type":"index","data":{"on":36,"name":"cedar_policy_template_links_fk_principal_idx","sql":"CREATE INDEX IF NOT EXISTS cedar_policy_template_links_fk_principal_idx ON cedar_policy_template_links(principal_type, principal_id);","unique":false,"columns":[]}},{"id":39,"references":[36],"type":"index","data":{"on":36,"name":"cedar_policy_template_links_fk_resource_idx","sql":"CREATE INDEX IF NOT EXISTS cedar_policy_template_links_fk_resource_idx ON cedar_policy_template_links(resource_type, resource_id);","unique":false,"columns":[]}},{"id":40,"references":[],"type":"table","data":{"name":"cedar_authorization_logs","was_declared_in_moor":true,"columns":[{"name":"rowid","getter_name":"rowid","moor_type":"int","nullable":false,"customConstraints":"PRIMARY KEY AUTOINCREMENT","default_dart":null,"default_client_dart":null,"dsl_features":["auto-increment"]},{"name":"create_time","getter_name":"createTime","moor_type":"dateTime","nullable":false,"customConstraints":"NOT NULL DEFAULT (unixepoch('now', 'subsec'))","default_dart":"const CustomExpression('unixepoch(\\'now\\', \\'subsec\\')')","default_client_dart":null,"dsl_features":[]},{"name":"expire_time","getter_name":"expireTime","moor_type":"dateTime","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"principal_type","getter_name":"principalType","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"principal_id","getter_name":"principalId","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"action_type","getter_name":"actionType","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"action_id","getter_name":"actionId","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"resource_type","getter_name":"resourceType","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"resource_id","getter_name":"resourceId","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"context_json","getter_name":"contextJson","moor_type":"string","nullable":false,"customConstraints":"NOT NULL DEFAULT '{}'","default_dart":"const CustomExpression('\\'{}\\'')","default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const CedarAttributesConverter()","dart_type_name":"Map"}},{"name":"decision","getter_name":"decision","moor_type":"bool","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"reasons_json","getter_name":"reasonsJson","moor_type":"string","nullable":false,"customConstraints":"NOT NULL DEFAULT '[]'","default_dart":"const CustomExpression('\\'[]\\'')","default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const CedarAuthorizationReasonsConverter()","dart_type_name":"List"}},{"name":"errors_json","getter_name":"errorsJson","moor_type":"string","nullable":false,"customConstraints":"NOT NULL DEFAULT '[]'","default_dart":"const CustomExpression('\\'[]\\'')","default_client_dart":null,"dsl_features":[],"type_converter":{"dart_expr":"const CedarAuthorizationErrorsConverter()","dart_type_name":"AuthorizationErrors"}}],"is_virtual":false,"without_rowid":false,"constraints":[]}},{"id":41,"references":[2],"type":"table","data":{"name":"user_memberships","was_declared_in_moor":true,"columns":[{"name":"membership_id","getter_name":"membershipId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL PRIMARY KEY","default_dart":null,"default_client_dart":null,"dsl_features":["primary-key"]},{"name":"user_id","getter_name":"userId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"parent_type","getter_name":"parentType","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"parent_id","getter_name":"parentId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"role","getter_name":"role","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"create_time","getter_name":"createTime","moor_type":"dateTime","nullable":false,"customConstraints":"NOT NULL DEFAULT (unixepoch('now', 'subsec'))","default_dart":"const CustomExpression('unixepoch(\\'now\\', \\'subsec\\')')","default_client_dart":null,"dsl_features":[]},{"name":"update_time","getter_name":"updateTime","moor_type":"dateTime","nullable":false,"customConstraints":"NOT NULL DEFAULT (unixepoch('now', 'subsec'))","default_dart":"const CustomExpression('unixepoch(\\'now\\', \\'subsec\\')')","default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":["CHECK(parent_type = 'Celest::Organization' OR parent_type = 'Celest::Project' OR parent_type = 'Celest::Project::Environment')","CONSTRAINT user_memberships_parent_fk FOREIGN KEY(parent_type, parent_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED"]}},{"id":42,"references":[41],"type":"index","data":{"on":41,"name":"user_memberships_parent_idx","sql":"CREATE INDEX IF NOT EXISTS user_memberships_parent_idx ON user_memberships(parent_type, parent_id);","unique":false,"columns":[]}},{"id":43,"references":[41,2,4],"type":"trigger","data":{"on":41,"references_in_body":[41,2,4],"name":"user_memberships_create_trg","sql":"CREATE TRIGGER IF NOT EXISTS user_memberships_create_trg\nBEFORE INSERT ON user_memberships\nBEGIN\n INSERT INTO cedar_entities(entity_type, entity_id, attribute_json)\n VALUES (\n NEW.parent_type || '::Member', \n NEW.membership_id, \n json_object(\n 'role', json_object(\n 'type', 'Celest::Role',\n 'id', NEW.role\n ), \n 'parent', json_object(\n 'type', NEW.parent_type, \n 'id', NEW.parent_id\n )\n )\n );\n INSERT INTO cedar_relationships(entity_type, entity_id, parent_type, parent_id)\n VALUES ('Celest::User', NEW.user_id, NEW.parent_type || '::Member', NEW.membership_id);\nEND;"}},{"id":44,"references":[41,2,4],"type":"trigger","data":{"on":41,"references_in_body":[41,2,4],"name":"user_memberships_update_trg","sql":"CREATE TRIGGER IF NOT EXISTS user_memberships_update_trg\nAFTER UPDATE ON user_memberships\nBEGIN\n UPDATE cedar_entities\n SET attribute_json = json_object(\n 'role', json_object(\n 'type', 'Celest::Role',\n 'id', NEW.role\n ), \n 'parent', json_object(\n 'type', OLD.parent_type,\n 'id', OLD.parent_id\n )\n )\n WHERE entity_id = OLD.membership_id AND entity_type = OLD.parent_type || '::Member';\n UPDATE cedar_relationships\n SET parent_id = NEW.role\n WHERE entity_id = OLD.membership_id AND entity_type = OLD.parent_type || '::Member' AND parent_type = 'Celest::Role';\nEND;"}},{"id":45,"references":[41,4,2],"type":"trigger","data":{"on":41,"references_in_body":[41,4,2],"name":"user_memberships_delete_trg","sql":"CREATE TRIGGER IF NOT EXISTS user_memberships_delete_trg\nAFTER DELETE ON user_memberships\nBEGIN\n DELETE FROM cedar_relationships\n WHERE \n entity_id = OLD.membership_id \n AND entity_type = OLD.parent_type || '::Member';\n DELETE FROM cedar_relationships\n WHERE\n parent_id = OLD.membership_id \n AND parent_type = OLD.parent_type || '::Member';\n DELETE FROM cedar_entities\n WHERE\n entity_id = OLD.membership_id\n AND entity_type = OLD.parent_type || '::Member';\nEND;"}},{"id":46,"references":[2],"type":"table","data":{"name":"organizations","was_declared_in_moor":true,"columns":[{"name":"id","getter_name":"id","moor_type":"string","nullable":false,"customConstraints":"NOT NULL PRIMARY KEY","default_dart":null,"default_client_dart":null,"dsl_features":["primary-key"]},{"name":"parent_type","getter_name":"parentType","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"parent_id","getter_name":"parentId","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"organization_id","getter_name":"organizationId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL UNIQUE","default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"state","getter_name":"state","moor_type":"string","nullable":false,"customConstraints":"NOT NULL DEFAULT 'CREATING'","default_dart":"const CustomExpression('\\'CREATING\\'')","default_client_dart":null,"dsl_features":[]},{"name":"display_name","getter_name":"displayName","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"create_time","getter_name":"createTime","moor_type":"dateTime","nullable":false,"customConstraints":"NOT NULL DEFAULT (unixepoch('now', 'subsec'))","default_dart":"const CustomExpression('unixepoch(\\'now\\', \\'subsec\\')')","default_client_dart":null,"dsl_features":[]},{"name":"update_time","getter_name":"updateTime","moor_type":"dateTime","nullable":false,"customConstraints":"NOT NULL DEFAULT (unixepoch('now', 'subsec'))","default_dart":"const CustomExpression('unixepoch(\\'now\\', \\'subsec\\')')","default_client_dart":null,"dsl_features":[]},{"name":"delete_time","getter_name":"deleteTime","moor_type":"dateTime","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"purge_time","getter_name":"purgeTime","moor_type":"dateTime","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"annotations","getter_name":"annotations","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"primary_region","getter_name":"primaryRegion","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"reconciling","getter_name":"reconciling","moor_type":"bool","nullable":false,"customConstraints":"NOT NULL DEFAULT FALSE","default_dart":"const CustomExpression('FALSE')","default_client_dart":null,"dsl_features":[]},{"name":"etag","getter_name":"etag","moor_type":"string","nullable":false,"customConstraints":"NOT NULL GENERATED ALWAYS AS (hex(md5(json_array(id, parent_type, parent_id, organization_id, state, display_name, create_time, update_time, delete_time, purge_time, annotations, primary_region, reconciling)))) STORED","default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]}],"is_virtual":false,"without_rowid":false,"constraints":["CONSTRAINT organizations_parent_fk FOREIGN KEY(parent_type, parent_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE SET NULL"]}},{"id":47,"references":[46,41],"type":"trigger","data":{"on":46,"references_in_body":[46,41],"name":"organizations_delete_user_memberships_trg","sql":"CREATE TRIGGER IF NOT EXISTS organizations_delete_user_memberships_trg\nAFTER DELETE ON organizations\nBEGIN\n DELETE FROM user_memberships\n WHERE\n parent_type = 'Celest::Organization'\n AND parent_id = OLD.id;\nEND;"}},{"id":48,"references":[2,46],"type":"table","data":{"name":"projects","was_declared_in_moor":true,"columns":[{"name":"id","getter_name":"id","moor_type":"string","nullable":false,"customConstraints":"NOT NULL PRIMARY KEY","default_dart":null,"default_client_dart":null,"dsl_features":["primary-key"]},{"name":"parent_type","getter_name":"parentType","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"parent_id","getter_name":"parentId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"project_id","getter_name":"projectId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"state","getter_name":"state","moor_type":"string","nullable":false,"customConstraints":"NOT NULL DEFAULT 'CREATING'","default_dart":"const CustomExpression('\\'CREATING\\'')","default_client_dart":null,"dsl_features":[]},{"name":"display_name","getter_name":"displayName","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"create_time","getter_name":"createTime","moor_type":"dateTime","nullable":false,"customConstraints":"NOT NULL DEFAULT (unixepoch('now', 'subsec'))","default_dart":"const CustomExpression('unixepoch(\\'now\\', \\'subsec\\')')","default_client_dart":null,"dsl_features":[]},{"name":"update_time","getter_name":"updateTime","moor_type":"dateTime","nullable":false,"customConstraints":"NOT NULL DEFAULT (unixepoch('now', 'subsec'))","default_dart":"const CustomExpression('unixepoch(\\'now\\', \\'subsec\\')')","default_client_dart":null,"dsl_features":[]},{"name":"delete_time","getter_name":"deleteTime","moor_type":"dateTime","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"purge_time","getter_name":"purgeTime","moor_type":"dateTime","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"annotations","getter_name":"annotations","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"regions","getter_name":"regions","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"reconciling","getter_name":"reconciling","moor_type":"bool","nullable":false,"customConstraints":"NOT NULL DEFAULT FALSE","default_dart":"const CustomExpression('FALSE')","default_client_dart":null,"dsl_features":[]},{"name":"etag","getter_name":"etag","moor_type":"string","nullable":false,"customConstraints":"NOT NULL GENERATED ALWAYS AS (hex(md5(json_array(id, parent_type, parent_id, project_id, state, display_name, create_time, update_time, delete_time, purge_time, annotations, regions, reconciling)))) STORED","default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]}],"is_virtual":false,"without_rowid":false,"constraints":["CHECK(parent_type = 'Celest::Organization')","CONSTRAINT projects_fk_parent FOREIGN KEY(parent_type, parent_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE CASCADE","CONSTRAINT projects_fk_organization FOREIGN KEY(parent_id)REFERENCES organizations(id)ON UPDATE CASCADE ON DELETE CASCADE","CONSTRAINT projects_uq_project_id UNIQUE(project_id, parent_id)"],"unique_keys":[["project_id","parent_id"]]}},{"id":49,"references":[48,41],"type":"trigger","data":{"on":48,"references_in_body":[48,41],"name":"projects_delete_user_memberships_trg","sql":"CREATE TRIGGER IF NOT EXISTS projects_delete_user_memberships_trg\nAFTER DELETE ON projects\nBEGIN\n DELETE FROM user_memberships\n WHERE\n parent_type = 'Celest::Project'\n AND parent_id = OLD.id;\nEND;"}},{"id":50,"references":[2,48],"type":"table","data":{"name":"project_environments","was_declared_in_moor":true,"columns":[{"name":"id","getter_name":"id","moor_type":"string","nullable":false,"customConstraints":"NOT NULL PRIMARY KEY","default_dart":null,"default_client_dart":null,"dsl_features":["primary-key"]},{"name":"parent_type","getter_name":"parentType","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"parent_id","getter_name":"parentId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"project_environment_id","getter_name":"projectEnvironmentId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"state","getter_name":"state","moor_type":"string","nullable":false,"customConstraints":"NOT NULL DEFAULT 'CREATING'","default_dart":"const CustomExpression('\\'CREATING\\'')","default_client_dart":null,"dsl_features":[]},{"name":"display_name","getter_name":"displayName","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"create_time","getter_name":"createTime","moor_type":"dateTime","nullable":false,"customConstraints":"NOT NULL DEFAULT (unixepoch('now', 'subsec'))","default_dart":"const CustomExpression('unixepoch(\\'now\\', \\'subsec\\')')","default_client_dart":null,"dsl_features":[]},{"name":"update_time","getter_name":"updateTime","moor_type":"dateTime","nullable":false,"customConstraints":"NOT NULL DEFAULT (unixepoch('now', 'subsec'))","default_dart":"const CustomExpression('unixepoch(\\'now\\', \\'subsec\\')')","default_client_dart":null,"dsl_features":[]},{"name":"delete_time","getter_name":"deleteTime","moor_type":"dateTime","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"annotations","getter_name":"annotations","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"reconciling","getter_name":"reconciling","moor_type":"bool","nullable":false,"customConstraints":"NOT NULL GENERATED ALWAYS AS (state IN ('CREATING', 'UPDATING', 'DELETING')) VIRTUAL","default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"etag","getter_name":"etag","moor_type":"string","nullable":false,"customConstraints":"NOT NULL GENERATED ALWAYS AS (hex(md5(json_array(id, parent_type, parent_id, project_environment_id, state, display_name, create_time, update_time, delete_time, annotations, reconciling)))) STORED","default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]}],"is_virtual":false,"without_rowid":false,"constraints":["CHECK(parent_type = 'Celest::Project')","CONSTRAINT project_environments_parent_fk FOREIGN KEY(parent_type, parent_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE CASCADE","CONSTRAINT project_environments_organization_fk FOREIGN KEY(parent_id)REFERENCES projects(id)ON UPDATE CASCADE ON DELETE CASCADE","CONSTRAINT project_environments_project_environment_id_unique_idx UNIQUE(project_environment_id, parent_id)"],"unique_keys":[["project_environment_id","parent_id"]]}},{"id":51,"references":[50,41],"type":"trigger","data":{"on":50,"references_in_body":[50,41],"name":"project_environments_delete_user_memberships_trg","sql":"CREATE TRIGGER IF NOT EXISTS project_environments_delete_user_memberships_trg\nAFTER DELETE ON project_environments\nBEGIN\n DELETE FROM user_memberships\n WHERE\n parent_type = 'Celest::Project::Environment'\n AND parent_id = OLD.id;\nEND;"}},{"id":52,"references":[50],"type":"index","data":{"on":50,"name":"project_environments_parent_idx","sql":"CREATE INDEX IF NOT EXISTS project_environments_parent_idx ON project_environments(parent_type, parent_id);","unique":false,"columns":[]}},{"id":53,"references":[50],"type":"trigger","data":{"on":50,"references_in_body":[50],"name":"project_environments_update_time_trg","sql":"CREATE TRIGGER IF NOT EXISTS project_environments_update_time_trg\nAFTER UPDATE ON project_environments\nBEGIN\n UPDATE project_environments\n SET update_time = unixepoch('now', 'subsec')\n WHERE id = OLD.id;\nEND;"}},{"id":54,"references":[50,2,4],"type":"trigger","data":{"on":50,"references_in_body":[50,2,4],"name":"project_environments_create_trg","sql":"CREATE TRIGGER IF NOT EXISTS project_environments_create_trg\nBEFORE INSERT ON project_environments\nBEGIN\n INSERT INTO cedar_entities(entity_type, entity_id)\n VALUES ('Celest::Project::Environment', NEW.id);\n INSERT INTO cedar_relationships(entity_type, entity_id, parent_type, parent_id)\n VALUES ('Celest::Project::Environment', NEW.id, NEW.parent_type, NEW.parent_id);\nEND;"}},{"id":55,"references":[50,4],"type":"trigger","data":{"on":50,"references_in_body":[50,4],"name":"project_environments_set_parent_trg","sql":"CREATE TRIGGER IF NOT EXISTS project_environments_set_parent_trg\nAFTER UPDATE OF parent_type, parent_id ON project_environments\nWHEN OLD.parent_type != NEW.parent_type OR OLD.parent_id != NEW.parent_id\nBEGIN\n UPDATE cedar_relationships\n SET \n parent_type = NEW.parent_type,\n parent_id = NEW.parent_id\n WHERE \n entity_id = OLD.id \n AND entity_type = 'Celest::Project::Environment';\nEND;"}},{"id":56,"references":[50,4,2],"type":"trigger","data":{"on":50,"references_in_body":[50,4,2],"name":"project_environments_delete_trg","sql":"CREATE TRIGGER IF NOT EXISTS project_environments_delete_trg\nAFTER DELETE ON project_environments\nBEGIN\n DELETE FROM cedar_relationships\n WHERE \n entity_id = OLD.id \n AND entity_type = 'Celest::Project::Environment';\n DELETE FROM cedar_entities\n WHERE\n entity_id = OLD.id\n AND entity_type = 'Celest::Project::Environment';\nEND;"}},{"id":57,"references":[50],"type":"table","data":{"name":"project_environment_asts","was_declared_in_moor":true,"columns":[{"name":"project_environment_id","getter_name":"projectEnvironmentId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL PRIMARY KEY","default_dart":null,"default_client_dart":null,"dsl_features":["primary-key"]},{"name":"ast","getter_name":"ast","moor_type":"blob","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"version","getter_name":"version","moor_type":"int","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"digest","getter_name":"digest","moor_type":"string","nullable":false,"customConstraints":"NOT NULL GENERATED ALWAYS AS (hex(md5(ast))) STORED","default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]}],"is_virtual":false,"without_rowid":true,"constraints":["CONSTRAINT fk_environment_metadata_project_environment_id FOREIGN KEY(project_environment_id)REFERENCES project_environments(id)ON UPDATE CASCADE ON DELETE CASCADE"]}},{"id":58,"references":[50],"type":"table","data":{"name":"project_environment_assets","was_declared_in_moor":true,"columns":[{"name":"project_environment_id","getter_name":"projectEnvironmentId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"type","getter_name":"type","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"bucket","getter_name":"bucket","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"name","getter_name":"name","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"etag","getter_name":"etag","moor_type":"string","nullable":false,"customConstraints":"NOT NULL","default_dart":null,"default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":true,"constraints":["PRIMARY KEY(project_environment_id, name)","CONSTRAINT fk_environment_assets_project_environment_id FOREIGN KEY(project_environment_id)REFERENCES project_environments(id)ON UPDATE CASCADE ON DELETE CASCADE"],"explicit_pk":["project_environment_id","name"]}},{"id":59,"references":[50],"type":"table","data":{"name":"project_environment_states","was_declared_in_moor":true,"columns":[{"name":"project_environment_id","getter_name":"projectEnvironmentId","moor_type":"string","nullable":false,"customConstraints":"NOT NULL PRIMARY KEY","default_dart":null,"default_client_dart":null,"dsl_features":["primary-key"]},{"name":"domain_name","getter_name":"domainName","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"fly_app_name","getter_name":"flyAppName","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"fly_volume_name","getter_name":"flyVolumeName","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"fly_volume_id","getter_name":"flyVolumeId","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":true,"constraints":["CONSTRAINT fk_project_environment_state_project_environment_id FOREIGN KEY(project_environment_id)REFERENCES project_environments(id)ON UPDATE CASCADE ON DELETE CASCADE"]}},{"id":60,"references":[48],"type":"index","data":{"on":48,"name":"projects_fk_parent_idx","sql":"CREATE INDEX IF NOT EXISTS projects_fk_parent_idx ON projects(parent_type, parent_id);","unique":false,"columns":[]}},{"id":61,"references":[48],"type":"trigger","data":{"on":48,"references_in_body":[48],"name":"projects_update_time_trg","sql":"CREATE TRIGGER IF NOT EXISTS projects_update_time_trg\nAFTER UPDATE ON projects\nBEGIN\n UPDATE projects\n SET update_time = unixepoch('now', 'subsec')\n WHERE id = OLD.id;\nEND;"}},{"id":62,"references":[48,2,4],"type":"trigger","data":{"on":48,"references_in_body":[48,2,4],"name":"projects_create_trg","sql":"CREATE TRIGGER IF NOT EXISTS projects_create_trg\nBEFORE INSERT ON projects\nBEGIN\n INSERT INTO cedar_entities(entity_type, entity_id)\n VALUES ('Celest::Project', NEW.id);\n INSERT INTO cedar_relationships(entity_type, entity_id, parent_type, parent_id)\n VALUES ('Celest::Project', NEW.id, NEW.parent_type, NEW.parent_id);\nEND;"}},{"id":63,"references":[48,4],"type":"trigger","data":{"on":48,"references_in_body":[48,4],"name":"projects_set_parent_trg","sql":"CREATE TRIGGER IF NOT EXISTS projects_set_parent_trg\nAFTER UPDATE OF parent_type, parent_id ON projects\nWHEN OLD.parent_type != NEW.parent_type OR OLD.parent_id != NEW.parent_id\nBEGIN\n UPDATE cedar_relationships\n SET \n parent_type = NEW.parent_type,\n parent_id = NEW.parent_id\n WHERE \n entity_id = OLD.id \n AND entity_type = 'Celest::Project';\nEND;"}},{"id":64,"references":[48,4,2],"type":"trigger","data":{"on":48,"references_in_body":[48,4,2],"name":"projects_delete_trg","sql":"CREATE TRIGGER IF NOT EXISTS projects_delete_trg\nAFTER DELETE ON projects\nBEGIN\n DELETE FROM cedar_relationships\n WHERE \n entity_type = 'Celest::Project'\n AND entity_id = OLD.id;\n DELETE FROM cedar_relationships\n WHERE \n parent_type = 'Celest::Project'\n AND parent_id = OLD.id;\n DELETE FROM cedar_entities\n WHERE\n entity_id = OLD.id\n AND entity_type = 'Celest::Project';\nEND;"}},{"id":65,"references":[46],"type":"index","data":{"on":46,"name":"organizations_parent_idx","sql":"CREATE INDEX IF NOT EXISTS organizations_parent_idx ON organizations(parent_type, parent_id);","unique":false,"columns":[]}},{"id":66,"references":[46],"type":"trigger","data":{"on":46,"references_in_body":[46],"name":"organizations_update_time","sql":"CREATE TRIGGER IF NOT EXISTS organizations_update_time\nAFTER UPDATE ON organizations\nBEGIN\n UPDATE organizations\n SET update_time = unixepoch('now', 'subsec')\n WHERE id = OLD.id;\nEND;"}},{"id":67,"references":[46,2],"type":"trigger","data":{"on":46,"references_in_body":[46,2],"name":"organizations_create","sql":"CREATE TRIGGER IF NOT EXISTS organizations_create\nBEFORE INSERT ON organizations\nBEGIN\n INSERT INTO cedar_entities(entity_type, entity_id)\n VALUES ('Celest::Organization', NEW.id);\nEND;"}},{"id":68,"references":[46,4],"type":"trigger","data":{"on":46,"references_in_body":[46,4],"name":"organizations_create_parent","sql":"CREATE TRIGGER IF NOT EXISTS organizations_create_parent\nAFTER INSERT ON organizations\nWHEN NEW.parent_id IS NOT NULL\nBEGIN\n INSERT INTO cedar_relationships(entity_type, entity_id, parent_type, parent_id)\n VALUES ('Celest::Organization', NEW.id, NEW.parent_type, NEW.parent_id);\nEND;"}},{"id":69,"references":[46,4],"type":"trigger","data":{"on":46,"references_in_body":[46,4],"name":"organizations_add_parent","sql":"CREATE TRIGGER IF NOT EXISTS organizations_add_parent\nAFTER UPDATE OF parent_id ON organizations\nWHEN OLD.parent_id IS NULL AND NEW.parent_id IS NOT NULL\nBEGIN\n INSERT INTO cedar_relationships(entity_type, entity_id, parent_type, parent_id)\n VALUES ('Celest::Organization', NEW.id, NEW.parent_type, NEW.parent_id);\nEND;"}},{"id":70,"references":[46,4],"type":"trigger","data":{"on":46,"references_in_body":[46,4],"name":"organizations_set_parent","sql":"CREATE TRIGGER IF NOT EXISTS organizations_set_parent\nAFTER UPDATE OF parent_type, parent_id ON organizations\nWHEN (OLD.parent_type != NEW.parent_type OR OLD.parent_id != NEW.parent_id) AND NEW.parent_id IS NOT NULL\nBEGIN\n UPDATE cedar_relationships\n SET \n parent_type = NEW.parent_type,\n parent_id = NEW.parent_id\n WHERE \n entity_id = OLD.id \n AND entity_type = 'Celest::Organization';\nEND;"}},{"id":71,"references":[46,4],"type":"trigger","data":{"on":46,"references_in_body":[46,4],"name":"organizations_remove_parent","sql":"CREATE TRIGGER IF NOT EXISTS organizations_remove_parent\nAFTER UPDATE OF parent_id ON organizations\nWHEN OLD.parent_id IS NOT NULL AND NEW.parent_id IS NULL\nBEGIN\n DELETE FROM cedar_relationships\n WHERE \n entity_id = OLD.id \n AND entity_type = 'Celest::Organization'\n AND parent_id = OLD.parent_id\n AND parent_type = OLD.parent_type;\nEND;"}},{"id":72,"references":[46,4,2],"type":"trigger","data":{"on":46,"references_in_body":[46,4,2],"name":"organizations_delete","sql":"CREATE TRIGGER IF NOT EXISTS organizations_delete\nAFTER DELETE ON organizations\nBEGIN\n DELETE FROM cedar_relationships\n WHERE \n entity_type = 'Celest::Organization'\n AND entity_id = OLD.id;\n DELETE FROM cedar_relationships\n WHERE \n parent_type = 'Celest::Organization'\n AND parent_id = OLD.id;\n DELETE FROM cedar_entities\n WHERE\n entity_type = 'Celest::Organization'\n AND entity_id = OLD.id;\nEND;"}},{"id":73,"references":[],"type":"table","data":{"name":"operations","was_declared_in_moor":true,"columns":[{"name":"id","getter_name":"id","moor_type":"string","nullable":false,"customConstraints":"NOT NULL PRIMARY KEY","default_dart":null,"default_client_dart":null,"dsl_features":["primary-key"]},{"name":"metadata","getter_name":"metadata","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"response","getter_name":"response","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"error","getter_name":"error","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"done","getter_name":"done","moor_type":"bool","nullable":false,"customConstraints":"NOT NULL GENERATED ALWAYS AS (response IS NOT NULL OR error IS NOT NULL) VIRTUAL","default_dart":null,"default_client_dart":null,"dsl_features":["unknown"]},{"name":"create_time","getter_name":"createTime","moor_type":"dateTime","nullable":false,"customConstraints":"NOT NULL DEFAULT (unixepoch('now', 'subsec'))","default_dart":"const CustomExpression('unixepoch(\\'now\\', \\'subsec\\')')","default_client_dart":null,"dsl_features":[]},{"name":"full_resource_name","getter_name":"fullResourceName","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"owner_type","getter_name":"ownerType","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"owner_id","getter_name":"ownerId","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"resource_type","getter_name":"resourceType","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]},{"name":"resource_id","getter_name":"resourceId","moor_type":"string","nullable":true,"customConstraints":"","default_dart":null,"default_client_dart":null,"dsl_features":[]}],"is_virtual":false,"without_rowid":false,"constraints":[]}},{"id":74,"references":[73],"type":"index","data":{"on":73,"name":"operations_fk_owner_idx","sql":"CREATE INDEX IF NOT EXISTS operations_fk_owner_idx ON operations(owner_type, owner_id);","unique":false,"columns":[]}},{"id":75,"references":[73],"type":"index","data":{"on":73,"name":"operations_fk_resource_idx","sql":"CREATE INDEX IF NOT EXISTS operations_fk_resource_idx ON operations(resource_type, resource_id);","unique":false,"columns":[]}},{"id":76,"references":[73,2],"type":"trigger","data":{"on":73,"references_in_body":[73,2],"name":"operations_trigger_create","sql":"CREATE TRIGGER IF NOT EXISTS operations_trigger_create\nBEFORE INSERT ON operations\nBEGIN\n INSERT INTO cedar_entities(entity_type, entity_id)\n VALUES ('Celest::Operation', NEW.id);\nEND;"}},{"id":77,"references":[73,4],"type":"trigger","data":{"on":73,"references_in_body":[73,4],"name":"operations_trigger_create_owner","sql":"CREATE TRIGGER IF NOT EXISTS operations_trigger_create_owner\nAFTER INSERT ON operations\nWHEN NEW.owner_id IS NOT NULL\nBEGIN\n INSERT INTO cedar_relationships(entity_type, entity_id, parent_type, parent_id)\n VALUES ('Celest::Operation', NEW.id, NEW.owner_type, NEW.owner_id);\nEND;"}},{"id":78,"references":[73,4],"type":"trigger","data":{"on":73,"references_in_body":[73,4],"name":"operations_trigger_create_resource","sql":"CREATE TRIGGER IF NOT EXISTS operations_trigger_create_resource\nAFTER INSERT ON operations\nWHEN NEW.resource_id IS NOT NULL\nBEGIN\n INSERT INTO cedar_relationships(entity_type, entity_id, parent_type, parent_id)\n VALUES ('Celest::Operation', NEW.id, NEW.resource_type, NEW.resource_id);\nEND;"}},{"id":79,"references":[73,4],"type":"trigger","data":{"on":73,"references_in_body":[73,4],"name":"operations_trigger_add_owner","sql":"CREATE TRIGGER IF NOT EXISTS operations_trigger_add_owner\nAFTER UPDATE OF owner_id ON operations\nWHEN OLD.owner_id IS NULL AND NEW.owner_id IS NOT NULL\nBEGIN\n INSERT INTO cedar_relationships(entity_type, entity_id, parent_type, parent_id)\n VALUES ('Celest::Operation', NEW.id, NEW.owner_type, NEW.owner_id);\nEND;"}},{"id":80,"references":[73,4],"type":"trigger","data":{"on":73,"references_in_body":[73,4],"name":"operations_trigger_add_resource","sql":"CREATE TRIGGER IF NOT EXISTS operations_trigger_add_resource\nAFTER UPDATE OF resource_id ON operations\nWHEN OLD.resource_id IS NULL AND NEW.resource_id IS NOT NULL\nBEGIN\n INSERT INTO cedar_relationships(entity_type, entity_id, parent_type, parent_id)\n VALUES ('Celest::Operation', NEW.id, NEW.resource_type, NEW.resource_id);\nEND;"}},{"id":81,"references":[73,4],"type":"trigger","data":{"on":73,"references_in_body":[73,4],"name":"operations_trigger_set_owner","sql":"CREATE TRIGGER IF NOT EXISTS operations_trigger_set_owner\nAFTER UPDATE OF owner_type, owner_id ON operations\nWHEN (OLD.owner_type != NEW.owner_type OR OLD.owner_id != NEW.owner_id) AND OLD.owner_id IS NOT NULL AND NEW.owner_id IS NOT NULL\nBEGIN\n UPDATE cedar_relationships\n SET \n parent_type = NEW.owner_type,\n parent_id = NEW.owner_id\n WHERE \n entity_id = OLD.id\n AND entity_type = 'Celest::Operation'\n AND parent_type = OLD.owner_type\n AND parent_id = OLD.owner_id;\nEND;"}},{"id":82,"references":[73,4],"type":"trigger","data":{"on":73,"references_in_body":[73,4],"name":"operations_trigger_set_resource","sql":"CREATE TRIGGER IF NOT EXISTS operations_trigger_set_resource\nAFTER UPDATE OF resource_type, resource_id ON operations\nWHEN (OLD.resource_type != NEW.resource_type OR OLD.resource_id != NEW.resource_id) AND OLD.resource_id IS NOT NULL AND NEW.resource_id IS NOT NULL\nBEGIN\n UPDATE cedar_relationships\n SET \n parent_type = NEW.resource_type,\n parent_id = NEW.resource_id\n WHERE \n entity_id = OLD.id\n AND entity_type = 'Celest::Operation'\n AND parent_type = OLD.resource_type\n AND parent_id = OLD.resource_id;\nEND;"}},{"id":83,"references":[73,4,2],"type":"trigger","data":{"on":73,"references_in_body":[73,4,2],"name":"operations_trigger_delete","sql":"CREATE TRIGGER IF NOT EXISTS operations_trigger_delete\nAFTER DELETE ON operations\nBEGIN\n DELETE FROM cedar_relationships\n WHERE \n entity_id = OLD.id\n AND entity_type = 'Celest::Operation';\n DELETE FROM cedar_entities\n WHERE\n entity_id = OLD.id\n AND entity_type = 'Celest::Operation';\nEND;"}}]} \ No newline at end of file diff --git a/services/celest_cloud_hub/lib/src/context.dart b/services/celest_cloud_hub/lib/src/context.dart new file mode 100644 index 000000000..1661984c5 --- /dev/null +++ b/services/celest_cloud_hub/lib/src/context.dart @@ -0,0 +1,26 @@ +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'; + +export 'package:celest/src/core/context.dart' show ContextKey; + +Context get context => Context._(core.Context.current); + +extension type Context._(core.Context _ctx) implements core.Context { + static const core.ContextKey _flyContextKey = + core.ContextKey('FlyMachinesApiClient'); + + String get flyAuthToken => _ctx.expect(const env('FLY_API_TOKEN')); + String get flyOrgSlug => 'celest-809'; + + FlyMachinesApiClient get fly { + if (_ctx.get(_flyContextKey) case final flyApi?) { + return flyApi; + } + final flyApi = FlyMachinesApiClient( + authToken: flyAuthToken, + client: _ctx.httpClient, + ); + return _ctx.put(_flyContextKey, flyApi); + } +} diff --git a/services/celest_cloud_hub/lib/src/database/cloud_hub_database.dart b/services/celest_cloud_hub/lib/src/database/cloud_hub_database.dart index 8d41dc4d5..ce2f66acd 100644 --- a/services/celest_cloud_hub/lib/src/database/cloud_hub_database.dart +++ b/services/celest_cloud_hub/lib/src/database/cloud_hub_database.dart @@ -2,6 +2,7 @@ import 'dart:io'; import 'package:celest_cloud_auth/celest_cloud_auth.dart'; import 'package:celest_cloud_hub/src/auth/policy_set.g.dart'; +import 'package:celest_cloud_hub/src/database/cloud_hub_database.steps.dart'; import 'package:celest_cloud_hub/src/database/db_functions.dart'; import 'package:celest_cloud_hub/src/project.dart'; import 'package:celest_cloud_hub/src/services/service_mixin.dart'; @@ -44,7 +45,7 @@ final class CloudHubDatabase extends $CloudHubDatabase } @override - int get schemaVersion => 1; + int get schemaVersion => 2; static final Entity rootOrg = Entity( uid: const EntityUid.of('Celest::Organization', 'celest-dev'), @@ -53,44 +54,39 @@ final class CloudHubDatabase extends $CloudHubDatabase static final Logger _logger = Logger('CloudHubDatabase'); @override - MigrationStrategy get migration => MigrationStrategy( - onCreate: (m) async { - await m.createAll(); - }, - onUpgrade: (m, from, to) async { - await cloudAuth.onUpgrade(m); - }, + MigrationStrategy get migration => createMigration( + onUpgrade: stepByStep( + from1To2: (m, schema) async { + await m.addColumn( + schema.projectEnvironmentStates, + schema.projectEnvironmentStates.flyVolumeId, + ); + }, + ), beforeOpen: (details) async { final versionRow = await customSelect('SELECT sqlite_version() as version;').getSingle(); final version = versionRow.read('version'); _logger.config('Using SQLite v$version'); - - await withoutForeignKeys(() async { - if (details.wasCreated) { - await cloudAuth.seed( - additionalCedarTypes: { - 'Celest::Operation', - 'Celest::Organization', - 'Celest::Organization::Member', - 'Celest::Project', - 'Celest::Project::Member', - 'Celest::Project::Environment', - 'Celest::Project::Environment::Member', - }, - additionalCedarEntities: { - rootOrg.uid: rootOrg, - ProjectEnvironmentAction.deploy: Entity( - uid: ProjectEnvironmentAction.deploy, - parents: [CelestAction.owner], - ), - }, - additionalCedarPolicies: corePolicySet, - ); - } - await cloudAuth.upsertProject(project: project); - }); }, + project: project, + additionalCedarTypes: { + 'Celest::Operation', + 'Celest::Organization', + 'Celest::Organization::Member', + 'Celest::Project', + 'Celest::Project::Member', + 'Celest::Project::Environment', + 'Celest::Project::Environment::Member', + }, + additionalCedarEntities: { + rootOrg.uid: rootOrg, + ProjectEnvironmentAction.deploy: Entity( + uid: ProjectEnvironmentAction.deploy, + parents: [CelestAction.owner], + ), + }, + additionalCedarPolicies: corePolicySet, ); /// Runs [action] in a context without foreign keys enabled. diff --git a/services/celest_cloud_hub/lib/src/database/cloud_hub_database.steps.dart b/services/celest_cloud_hub/lib/src/database/cloud_hub_database.steps.dart new file mode 100644 index 000000000..44325d76b --- /dev/null +++ b/services/celest_cloud_hub/lib/src/database/cloud_hub_database.steps.dart @@ -0,0 +1,2227 @@ +// dart format width=80 +import 'package:drift/internal/versioned_schema.dart' as i0; +import 'package:drift/drift.dart' as i1; +import 'dart:typed_data' as i2; +import 'package:drift/drift.dart'; // ignore_for_file: type=lint,unused_import + +// GENERATED BY drift_dev, DO NOT MODIFY. +final class Schema2 extends i0.VersionedSchema { + Schema2({required super.database}) : super(version: 2); + @override + late final List entities = [ + cloudAuthUsers, + cedarTypes, + cedarEntities, + cloudAuthUsersCreateTrg, + cedarRelationships, + cloudAuthUsersDeleteTrg, + cloudAuthUserEmails, + cloudAuthUserPhoneNumbers, + cloudAuthProjects, + cloudAuthApis, + cloudAuthApisProjectIdx, + cloudAuthApisCreateTrg, + cloudAuthApisDeleteTrg, + cloudAuthFunctions, + cloudAuthFunctionsApiIdx, + cloudAuthFunctionsCreateTrg, + cloudAuthFunctionsDeleteTrg, + cloudAuthMeta, + cloudAuthCryptoKeys, + cloudAuthCryptoKeysExternalCryptoKeyIdIdx, + cloudAuthSessions, + cloudAuthSessionsUserIdx, + cloudAuthSessionsCryptoKeyIdx, + cloudAuthSessionsExternalSessionIdIdx, + cloudAuthSessionsUpdateTimeTrg, + cloudAuthOtpCodes, + cloudAuthOtpCodesSessionIdIdx, + cloudAuthCorks, + cloudAuthCorksCryptoKeyIdx, + cloudAuthCorksBearerIdx, + cloudAuthCorksAudienceIdx, + cloudAuthCorksIssuerIdx, + cedarRelationshipsFkEntityIdx, + cedarRelationshipsFkParentIdx, + cedarPolicies, + cedarPolicyTemplates, + cedarPolicyTemplateLinks, + cedarPolicyTemplateLinksFkTemplateIdIdx, + cedarPolicyTemplateLinksFkPrincipalIdx, + cedarPolicyTemplateLinksFkResourceIdx, + cedarAuthorizationLogs, + userMemberships, + userMembershipsParentIdx, + userMembershipsCreateTrg, + userMembershipsUpdateTrg, + userMembershipsDeleteTrg, + organizations, + organizationsDeleteUserMembershipsTrg, + projects, + projectsDeleteUserMembershipsTrg, + projectEnvironments, + projectEnvironmentsDeleteUserMembershipsTrg, + projectEnvironmentsParentIdx, + projectEnvironmentsUpdateTimeTrg, + projectEnvironmentsCreateTrg, + projectEnvironmentsSetParentTrg, + projectEnvironmentsDeleteTrg, + projectEnvironmentAsts, + projectEnvironmentAssets, + projectEnvironmentStates, + projectsFkParentIdx, + projectsUpdateTimeTrg, + projectsCreateTrg, + projectsSetParentTrg, + projectsDeleteTrg, + organizationsParentIdx, + organizationsUpdateTime, + organizationsCreate, + organizationsCreateParent, + organizationsAddParent, + organizationsSetParent, + organizationsRemoveParent, + organizationsDelete, + operations, + operationsFkOwnerIdx, + operationsFkResourceIdx, + operationsTriggerCreate, + operationsTriggerCreateOwner, + operationsTriggerCreateResource, + operationsTriggerAddOwner, + operationsTriggerAddResource, + operationsTriggerSetOwner, + operationsTriggerSetResource, + operationsTriggerDelete, + ]; + late final Shape0 cloudAuthUsers = Shape0( + source: i0.VersionedTable( + entityName: 'cloud_auth_users', + withoutRowId: false, + isStrict: false, + tableConstraints: [], + columns: [ + _column_0, + _column_1, + _column_2, + _column_3, + _column_4, + _column_5, + _column_6, + ], + attachedDatabase: database, + ), + alias: null, + ); + late final Shape1 cedarTypes = Shape1( + source: i0.VersionedTable( + entityName: 'cedar_types', + withoutRowId: false, + isStrict: false, + tableConstraints: [], + columns: [_column_7], + attachedDatabase: database, + ), + alias: null, + ); + late final Shape2 cedarEntities = Shape2( + source: i0.VersionedTable( + entityName: 'cedar_entities', + withoutRowId: true, + isStrict: false, + tableConstraints: [ + 'CONSTRAINT cedar_entities_pk PRIMARY KEY(entity_type, entity_id)ON CONFLICT IGNORE', + ], + columns: [_column_8, _column_9, _column_10, _column_11], + attachedDatabase: database, + ), + alias: null, + ); + final i1.Trigger cloudAuthUsersCreateTrg = i1.Trigger( + 'CREATE TRIGGER IF NOT EXISTS cloud_auth_users_create_trg BEFORE INSERT ON cloud_auth_users BEGIN INSERT INTO cedar_entities (entity_type, entity_id) VALUES (\'Celest::User\', NEW.user_id);END', + 'cloud_auth_users_create_trg', + ); + late final Shape3 cedarRelationships = Shape3( + source: i0.VersionedTable( + entityName: 'cedar_relationships', + withoutRowId: true, + isStrict: false, + tableConstraints: [ + 'CONSTRAINT cedar_relationships_pk PRIMARY KEY(entity_type, entity_id, parent_type, parent_id)ON CONFLICT IGNORE', + 'CONSTRAINT cedar_relationships_fk_entity FOREIGN KEY(entity_type, entity_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE CASCADE', + 'CONSTRAINT cedar_relationships_fk_parent FOREIGN KEY(parent_type, parent_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE CASCADE', + ], + columns: [ + _column_12, + _column_9, + _column_11, + _column_13, + _column_14, + _column_15, + ], + attachedDatabase: database, + ), + alias: null, + ); + final i1.Trigger cloudAuthUsersDeleteTrg = i1.Trigger( + 'CREATE TRIGGER IF NOT EXISTS cloud_auth_users_delete_trg AFTER DELETE ON cloud_auth_users BEGIN DELETE FROM cedar_relationships WHERE(entity_type = \'Celest::User\' AND entity_id = OLD.user_id)OR(parent_type = \'Celest::User\' AND parent_id = OLD.user_id);DELETE FROM cedar_entities WHERE entity_id = OLD.user_id AND entity_type = \'Celest::User\';END', + 'cloud_auth_users_delete_trg', + ); + late final Shape4 cloudAuthUserEmails = Shape4( + source: i0.VersionedTable( + entityName: 'cloud_auth_user_emails', + withoutRowId: true, + isStrict: false, + tableConstraints: [ + 'CONSTRAINT cloud_auth_user_emails_pk PRIMARY KEY(user_id, email)', + 'CONSTRAINT cloud_auth_user_emails_user_fk FOREIGN KEY(user_id)REFERENCES cloud_auth_users(user_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED', + ], + columns: [_column_16, _column_17, _column_18, _column_19], + attachedDatabase: database, + ), + alias: null, + ); + late final Shape5 cloudAuthUserPhoneNumbers = Shape5( + source: i0.VersionedTable( + entityName: 'cloud_auth_user_phone_numbers', + withoutRowId: true, + isStrict: false, + tableConstraints: [ + 'CONSTRAINT cloud_auth_user_phone_numbers_pk PRIMARY KEY(user_id, phone_number)', + 'CONSTRAINT cloud_auth_user_phone_numbers_user_fk FOREIGN KEY(user_id)REFERENCES cloud_auth_users(user_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED', + ], + columns: [_column_16, _column_20, _column_18, _column_19], + attachedDatabase: database, + ), + alias: null, + ); + late final Shape6 cloudAuthProjects = Shape6( + source: i0.VersionedTable( + entityName: 'cloud_auth_projects', + withoutRowId: false, + isStrict: false, + tableConstraints: [], + columns: [_column_21, _column_22, _column_23, _column_24], + attachedDatabase: database, + ), + alias: null, + ); + late final Shape7 cloudAuthApis = Shape7( + source: i0.VersionedTable( + entityName: 'cloud_auth_apis', + withoutRowId: false, + isStrict: false, + tableConstraints: [ + 'CONSTRAINT cloud_auth_apis_project_fk FOREIGN KEY(project_id)REFERENCES cloud_auth_projects(project_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED', + ], + columns: [_column_25, _column_26, _column_23, _column_24], + attachedDatabase: database, + ), + alias: null, + ); + final i1.Index cloudAuthApisProjectIdx = i1.Index( + 'cloud_auth_apis_project_idx', + 'CREATE INDEX IF NOT EXISTS cloud_auth_apis_project_idx ON cloud_auth_apis (project_id)', + ); + final i1.Trigger cloudAuthApisCreateTrg = i1.Trigger( + 'CREATE TRIGGER IF NOT EXISTS cloud_auth_apis_create_trg BEFORE INSERT ON cloud_auth_apis BEGIN INSERT INTO cedar_entities (entity_type, entity_id) VALUES (\'Celest::Api\', NEW.api_id);END', + 'cloud_auth_apis_create_trg', + ); + final i1.Trigger cloudAuthApisDeleteTrg = i1.Trigger( + 'CREATE TRIGGER IF NOT EXISTS cloud_auth_apis_delete_trg AFTER DELETE ON cloud_auth_apis BEGIN DELETE FROM cedar_relationships WHERE entity_type = \'Celest::Api\' AND entity_id = OLD.api_id;DELETE FROM cedar_relationships WHERE parent_type = \'Celest::Api\' AND parent_id = OLD.api_id;DELETE FROM cedar_entities WHERE entity_type = \'Celest::Api\' AND entity_id = OLD.api_id;END', + 'cloud_auth_apis_delete_trg', + ); + late final Shape8 cloudAuthFunctions = Shape8( + source: i0.VersionedTable( + entityName: 'cloud_auth_functions', + withoutRowId: false, + isStrict: false, + tableConstraints: [ + 'CONSTRAINT cloud_auth_functions_api_fk FOREIGN KEY(api_id)REFERENCES cloud_auth_apis(api_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED', + ], + columns: [_column_27, _column_28, _column_23, _column_24], + attachedDatabase: database, + ), + alias: null, + ); + final i1.Index cloudAuthFunctionsApiIdx = i1.Index( + 'cloud_auth_functions_api_idx', + 'CREATE INDEX IF NOT EXISTS cloud_auth_functions_api_idx ON cloud_auth_functions (api_id)', + ); + final i1.Trigger cloudAuthFunctionsCreateTrg = i1.Trigger( + 'CREATE TRIGGER IF NOT EXISTS cloud_auth_functions_create_trg BEFORE INSERT ON cloud_auth_functions BEGIN INSERT INTO cedar_entities (entity_type, entity_id) VALUES (\'Celest::Function\', NEW.function_id);INSERT INTO cedar_relationships (entity_type, entity_id, parent_type, parent_id) VALUES (\'Celest::Function\', NEW.function_id, \'Celest::Api\', NEW.api_id);END', + 'cloud_auth_functions_create_trg', + ); + final i1.Trigger cloudAuthFunctionsDeleteTrg = i1.Trigger( + 'CREATE TRIGGER IF NOT EXISTS cloud_auth_functions_delete_trg AFTER DELETE ON cloud_auth_functions BEGIN DELETE FROM cedar_relationships WHERE entity_type = \'Celest::Function\' AND entity_id = OLD.function_id;DELETE FROM cedar_relationships WHERE parent_type = \'Celest::Function\' AND parent_id = OLD.function_id;DELETE FROM cedar_entities WHERE entity_type = \'Celest::Function\' AND entity_id = OLD.function_id;END', + 'cloud_auth_functions_delete_trg', + ); + late final Shape9 cloudAuthMeta = Shape9( + source: i0.VersionedTable( + entityName: 'cloud_auth_meta', + withoutRowId: false, + isStrict: false, + tableConstraints: [], + columns: [_column_29], + attachedDatabase: database, + ), + alias: null, + ); + late final Shape10 cloudAuthCryptoKeys = Shape10( + source: i0.VersionedTable( + entityName: 'cloud_auth_crypto_keys', + withoutRowId: false, + isStrict: false, + tableConstraints: [ + 'CHECK(key_material IS NOT NULL OR external_crypto_key_id IS NOT NULL)', + ], + columns: [_column_30, _column_31, _column_32, _column_33, _column_34], + attachedDatabase: database, + ), + alias: null, + ); + final i1.Index cloudAuthCryptoKeysExternalCryptoKeyIdIdx = i1.Index( + 'cloud_auth_crypto_keys_external_crypto_key_id_idx', + 'CREATE INDEX IF NOT EXISTS cloud_auth_crypto_keys_external_crypto_key_id_idx ON cloud_auth_crypto_keys (external_crypto_key_id)', + ); + late final Shape11 cloudAuthSessions = Shape11( + source: i0.VersionedTable( + entityName: 'cloud_auth_sessions', + withoutRowId: false, + isStrict: false, + tableConstraints: [ + 'CONSTRAINT cloud_auth_sessions_user_fk FOREIGN KEY(user_id)REFERENCES cloud_auth_users(user_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED', + 'CONSTRAINT cloud_auth_sessions_key_fk FOREIGN KEY(crypto_key_id)REFERENCES cloud_auth_crypto_keys(crypto_key_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED', + ], + columns: [ + _column_35, + _column_36, + _column_37, + _column_16, + _column_38, + _column_39, + _column_40, + _column_41, + _column_42, + _column_5, + _column_6, + _column_43, + ], + attachedDatabase: database, + ), + alias: null, + ); + final i1.Index cloudAuthSessionsUserIdx = i1.Index( + 'cloud_auth_sessions_user_idx', + 'CREATE INDEX IF NOT EXISTS cloud_auth_sessions_user_idx ON cloud_auth_sessions (user_id)', + ); + final i1.Index cloudAuthSessionsCryptoKeyIdx = i1.Index( + 'cloud_auth_sessions_crypto_key_idx', + 'CREATE INDEX IF NOT EXISTS cloud_auth_sessions_crypto_key_idx ON cloud_auth_sessions (crypto_key_id)', + ); + final i1.Index cloudAuthSessionsExternalSessionIdIdx = i1.Index( + 'cloud_auth_sessions_external_session_id_idx', + 'CREATE INDEX IF NOT EXISTS cloud_auth_sessions_external_session_id_idx ON cloud_auth_sessions (external_session_id)', + ); + final i1.Trigger cloudAuthSessionsUpdateTimeTrg = i1.Trigger( + 'CREATE TRIGGER IF NOT EXISTS cloud_auth_sessions_update_time_trg AFTER UPDATE ON cloud_auth_sessions BEGIN UPDATE cloud_auth_sessions SET update_time = unixepoch(\'now\', \'subsec\') WHERE "rowid" = OLD."rowid";END', + 'cloud_auth_sessions_update_time_trg', + ); + late final Shape12 cloudAuthOtpCodes = Shape12( + source: i0.VersionedTable( + entityName: 'cloud_auth_otp_codes', + withoutRowId: false, + isStrict: false, + tableConstraints: [ + 'CONSTRAINT cloud_auth_otp_codes_session_id_fk FOREIGN KEY(session_id)REFERENCES cloud_auth_sessions(session_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED', + ], + columns: [_column_35, _column_36, _column_44, _column_45, _column_46], + attachedDatabase: database, + ), + alias: null, + ); + final i1.Index cloudAuthOtpCodesSessionIdIdx = i1.Index( + 'cloud_auth_otp_codes_session_id_idx', + 'CREATE INDEX IF NOT EXISTS cloud_auth_otp_codes_session_id_idx ON cloud_auth_otp_codes (session_id)', + ); + late final Shape13 cloudAuthCorks = Shape13( + source: i0.VersionedTable( + entityName: 'cloud_auth_corks', + withoutRowId: false, + isStrict: false, + tableConstraints: [ + 'CONSTRAINT cloud_auth_corks_crypto_key_fk FOREIGN KEY(crypto_key_id)REFERENCES cloud_auth_crypto_keys(crypto_key_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED', + 'CONSTRAINT cloud_auth_corks_bearer_fk FOREIGN KEY(bearer_type, bearer_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED', + 'CONSTRAINT cloud_auth_corks_audience_fk FOREIGN KEY(audience_type, audience_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED', + 'CONSTRAINT cloud_auth_corks_issuer_fk FOREIGN KEY(issuer_type, issuer_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED', + ], + columns: [ + _column_47, + _column_37, + _column_48, + _column_49, + _column_50, + _column_51, + _column_52, + _column_53, + _column_5, + _column_54, + _column_55, + ], + attachedDatabase: database, + ), + alias: null, + ); + final i1.Index cloudAuthCorksCryptoKeyIdx = i1.Index( + 'cloud_auth_corks_crypto_key_idx', + 'CREATE INDEX IF NOT EXISTS cloud_auth_corks_crypto_key_idx ON cloud_auth_corks (crypto_key_id)', + ); + final i1.Index cloudAuthCorksBearerIdx = i1.Index( + 'cloud_auth_corks_bearer_idx', + 'CREATE INDEX IF NOT EXISTS cloud_auth_corks_bearer_idx ON cloud_auth_corks (bearer_type, bearer_id)', + ); + final i1.Index cloudAuthCorksAudienceIdx = i1.Index( + 'cloud_auth_corks_audience_idx', + 'CREATE INDEX IF NOT EXISTS cloud_auth_corks_audience_idx ON cloud_auth_corks (audience_type, audience_id)', + ); + final i1.Index cloudAuthCorksIssuerIdx = i1.Index( + 'cloud_auth_corks_issuer_idx', + 'CREATE INDEX IF NOT EXISTS cloud_auth_corks_issuer_idx ON cloud_auth_corks (issuer_type, issuer_id)', + ); + final i1.Index cedarRelationshipsFkEntityIdx = i1.Index( + 'cedar_relationships_fk_entity_idx', + 'CREATE INDEX IF NOT EXISTS cedar_relationships_fk_entity_idx ON cedar_relationships (entity_type, entity_id)', + ); + final i1.Index cedarRelationshipsFkParentIdx = i1.Index( + 'cedar_relationships_fk_parent_idx', + 'CREATE INDEX IF NOT EXISTS cedar_relationships_fk_parent_idx ON cedar_relationships (parent_type, parent_id)', + ); + late final Shape14 cedarPolicies = Shape14( + source: i0.VersionedTable( + entityName: 'cedar_policies', + withoutRowId: false, + isStrict: false, + tableConstraints: ['CHECK(enforcement_level IN (0, 1))'], + columns: [_column_56, _column_57, _column_58, _column_59], + attachedDatabase: database, + ), + alias: null, + ); + late final Shape15 cedarPolicyTemplates = Shape15( + source: i0.VersionedTable( + entityName: 'cedar_policy_templates', + withoutRowId: false, + isStrict: false, + tableConstraints: ['CHECK(template IS NOT NULL OR template IS NOT NULL)'], + columns: [_column_56, _column_60, _column_61], + attachedDatabase: database, + ), + alias: null, + ); + late final Shape16 cedarPolicyTemplateLinks = Shape16( + source: i0.VersionedTable( + entityName: 'cedar_policy_template_links', + withoutRowId: false, + isStrict: false, + tableConstraints: [ + 'CHECK(principal_type IS NOT NULL AND principal_id IS NOT NULL OR resource_type IS NOT NULL AND resource_id IS NOT NULL)', + 'CHECK(enforcement_level IN (0, 1))', + 'CONSTRAINT cedar_policy_template_links_fk_template_id FOREIGN KEY(template_id)REFERENCES cedar_policy_templates(template_id)ON UPDATE CASCADE ON DELETE CASCADE', + 'CONSTRAINT cedar_policy_template_links_fk_principal FOREIGN KEY(principal_type, principal_id)REFERENCES cedar_entities(entity_type, entity_id)ON DELETE CASCADE', + 'CONSTRAINT cedar_policy_template_links_fk_resource FOREIGN KEY(resource_type, resource_id)REFERENCES cedar_entities(entity_type, entity_id)ON DELETE CASCADE', + ], + columns: [ + _column_56, + _column_57, + _column_62, + _column_63, + _column_64, + _column_65, + _column_66, + _column_59, + ], + attachedDatabase: database, + ), + alias: null, + ); + final i1.Index cedarPolicyTemplateLinksFkTemplateIdIdx = i1.Index( + 'cedar_policy_template_links_fk_template_id_idx', + 'CREATE INDEX IF NOT EXISTS cedar_policy_template_links_fk_template_id_idx ON cedar_policy_template_links (template_id)', + ); + final i1.Index cedarPolicyTemplateLinksFkPrincipalIdx = i1.Index( + 'cedar_policy_template_links_fk_principal_idx', + 'CREATE INDEX IF NOT EXISTS cedar_policy_template_links_fk_principal_idx ON cedar_policy_template_links (principal_type, principal_id)', + ); + final i1.Index cedarPolicyTemplateLinksFkResourceIdx = i1.Index( + 'cedar_policy_template_links_fk_resource_idx', + 'CREATE INDEX IF NOT EXISTS cedar_policy_template_links_fk_resource_idx ON cedar_policy_template_links (resource_type, resource_id)', + ); + late final Shape17 cedarAuthorizationLogs = Shape17( + source: i0.VersionedTable( + entityName: 'cedar_authorization_logs', + withoutRowId: false, + isStrict: false, + tableConstraints: [], + columns: [ + _column_35, + _column_67, + _column_68, + _column_63, + _column_64, + _column_69, + _column_70, + _column_65, + _column_66, + _column_71, + _column_72, + _column_73, + _column_74, + ], + attachedDatabase: database, + ), + alias: null, + ); + late final Shape18 userMemberships = Shape18( + source: i0.VersionedTable( + entityName: 'user_memberships', + withoutRowId: false, + isStrict: false, + tableConstraints: [ + 'CHECK(parent_type = \'Celest::Organization\' OR parent_type = \'Celest::Project\' OR parent_type = \'Celest::Project::Environment\')', + 'CONSTRAINT user_memberships_parent_fk FOREIGN KEY(parent_type, parent_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED', + ], + columns: [ + _column_75, + _column_16, + _column_13, + _column_14, + _column_76, + _column_67, + _column_77, + ], + attachedDatabase: database, + ), + alias: null, + ); + final i1.Index userMembershipsParentIdx = i1.Index( + 'user_memberships_parent_idx', + 'CREATE INDEX IF NOT EXISTS user_memberships_parent_idx ON user_memberships (parent_type, parent_id)', + ); + final i1.Trigger userMembershipsCreateTrg = i1.Trigger( + 'CREATE TRIGGER IF NOT EXISTS user_memberships_create_trg BEFORE INSERT ON user_memberships BEGIN INSERT INTO cedar_entities (entity_type, entity_id, attribute_json) VALUES (NEW.parent_type || \'::Member\', NEW.membership_id, json_object(\'role\', json_object(\'type\', \'Celest::Role\', \'id\', NEW.role), \'parent\', json_object(\'type\', NEW.parent_type, \'id\', NEW.parent_id)));INSERT INTO cedar_relationships (entity_type, entity_id, parent_type, parent_id) VALUES (\'Celest::User\', NEW.user_id, NEW.parent_type || \'::Member\', NEW.membership_id);END', + 'user_memberships_create_trg', + ); + final i1.Trigger userMembershipsUpdateTrg = i1.Trigger( + 'CREATE TRIGGER IF NOT EXISTS user_memberships_update_trg AFTER UPDATE ON user_memberships BEGIN UPDATE cedar_entities SET attribute_json = json_object(\'role\', json_object(\'type\', \'Celest::Role\', \'id\', NEW.role), \'parent\', json_object(\'type\', OLD.parent_type, \'id\', OLD.parent_id)) WHERE entity_id = OLD.membership_id AND entity_type = OLD.parent_type || \'::Member\';UPDATE cedar_relationships SET parent_id = NEW.role WHERE entity_id = OLD.membership_id AND entity_type = OLD.parent_type || \'::Member\' AND parent_type = \'Celest::Role\';END', + 'user_memberships_update_trg', + ); + final i1.Trigger userMembershipsDeleteTrg = i1.Trigger( + 'CREATE TRIGGER IF NOT EXISTS user_memberships_delete_trg AFTER DELETE ON user_memberships BEGIN DELETE FROM cedar_relationships WHERE entity_id = OLD.membership_id AND entity_type = OLD.parent_type || \'::Member\';DELETE FROM cedar_relationships WHERE parent_id = OLD.membership_id AND parent_type = OLD.parent_type || \'::Member\';DELETE FROM cedar_entities WHERE entity_id = OLD.membership_id AND entity_type = OLD.parent_type || \'::Member\';END', + 'user_memberships_delete_trg', + ); + late final Shape19 organizations = Shape19( + source: i0.VersionedTable( + entityName: 'organizations', + withoutRowId: false, + isStrict: false, + tableConstraints: [ + 'CONSTRAINT organizations_parent_fk FOREIGN KEY(parent_type, parent_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE SET NULL', + ], + columns: [ + _column_56, + _column_78, + _column_79, + _column_80, + _column_81, + _column_82, + _column_67, + _column_77, + _column_83, + _column_84, + _column_85, + _column_86, + _column_87, + _column_88, + ], + attachedDatabase: database, + ), + alias: null, + ); + final i1.Trigger organizationsDeleteUserMembershipsTrg = i1.Trigger( + 'CREATE TRIGGER IF NOT EXISTS organizations_delete_user_memberships_trg AFTER DELETE ON organizations BEGIN DELETE FROM user_memberships WHERE parent_type = \'Celest::Organization\' AND parent_id = OLD.id;END', + 'organizations_delete_user_memberships_trg', + ); + late final Shape20 projects = Shape20( + source: i0.VersionedTable( + entityName: 'projects', + withoutRowId: false, + isStrict: false, + tableConstraints: [ + 'CHECK(parent_type = \'Celest::Organization\')', + 'CONSTRAINT projects_fk_parent FOREIGN KEY(parent_type, parent_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE CASCADE', + 'CONSTRAINT projects_fk_organization FOREIGN KEY(parent_id)REFERENCES organizations(id)ON UPDATE CASCADE ON DELETE CASCADE', + 'CONSTRAINT projects_uq_project_id UNIQUE(project_id, parent_id)', + ], + columns: [ + _column_56, + _column_13, + _column_14, + _column_26, + _column_81, + _column_89, + _column_67, + _column_77, + _column_83, + _column_84, + _column_85, + _column_90, + _column_87, + _column_91, + ], + attachedDatabase: database, + ), + alias: null, + ); + final i1.Trigger projectsDeleteUserMembershipsTrg = i1.Trigger( + 'CREATE TRIGGER IF NOT EXISTS projects_delete_user_memberships_trg AFTER DELETE ON projects BEGIN DELETE FROM user_memberships WHERE parent_type = \'Celest::Project\' AND parent_id = OLD.id;END', + 'projects_delete_user_memberships_trg', + ); + late final Shape21 projectEnvironments = Shape21( + source: i0.VersionedTable( + entityName: 'project_environments', + withoutRowId: false, + isStrict: false, + tableConstraints: [ + 'CHECK(parent_type = \'Celest::Project\')', + 'CONSTRAINT project_environments_parent_fk FOREIGN KEY(parent_type, parent_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE CASCADE', + 'CONSTRAINT project_environments_organization_fk FOREIGN KEY(parent_id)REFERENCES projects(id)ON UPDATE CASCADE ON DELETE CASCADE', + 'CONSTRAINT project_environments_project_environment_id_unique_idx UNIQUE(project_environment_id, parent_id)', + ], + columns: [ + _column_56, + _column_13, + _column_14, + _column_92, + _column_81, + _column_89, + _column_67, + _column_77, + _column_83, + _column_85, + _column_93, + _column_94, + ], + attachedDatabase: database, + ), + alias: null, + ); + final i1.Trigger projectEnvironmentsDeleteUserMembershipsTrg = i1.Trigger( + 'CREATE TRIGGER IF NOT EXISTS project_environments_delete_user_memberships_trg AFTER DELETE ON project_environments BEGIN DELETE FROM user_memberships WHERE parent_type = \'Celest::Project::Environment\' AND parent_id = OLD.id;END', + 'project_environments_delete_user_memberships_trg', + ); + final i1.Index projectEnvironmentsParentIdx = i1.Index( + 'project_environments_parent_idx', + 'CREATE INDEX IF NOT EXISTS project_environments_parent_idx ON project_environments (parent_type, parent_id)', + ); + final i1.Trigger projectEnvironmentsUpdateTimeTrg = i1.Trigger( + 'CREATE TRIGGER IF NOT EXISTS project_environments_update_time_trg AFTER UPDATE ON project_environments BEGIN UPDATE project_environments SET update_time = unixepoch(\'now\', \'subsec\') WHERE id = OLD.id;END', + 'project_environments_update_time_trg', + ); + final i1.Trigger projectEnvironmentsCreateTrg = i1.Trigger( + 'CREATE TRIGGER IF NOT EXISTS project_environments_create_trg BEFORE INSERT ON project_environments BEGIN INSERT INTO cedar_entities (entity_type, entity_id) VALUES (\'Celest::Project::Environment\', NEW.id);INSERT INTO cedar_relationships (entity_type, entity_id, parent_type, parent_id) VALUES (\'Celest::Project::Environment\', NEW.id, NEW.parent_type, NEW.parent_id);END', + 'project_environments_create_trg', + ); + final i1.Trigger projectEnvironmentsSetParentTrg = i1.Trigger( + 'CREATE TRIGGER IF NOT EXISTS project_environments_set_parent_trg AFTER UPDATE OF parent_type, parent_id ON project_environments WHEN OLD.parent_type != NEW.parent_type OR OLD.parent_id != NEW.parent_id BEGIN UPDATE cedar_relationships SET parent_type = NEW.parent_type, parent_id = NEW.parent_id WHERE entity_id = OLD.id AND entity_type = \'Celest::Project::Environment\';END', + 'project_environments_set_parent_trg', + ); + final i1.Trigger projectEnvironmentsDeleteTrg = i1.Trigger( + 'CREATE TRIGGER IF NOT EXISTS project_environments_delete_trg AFTER DELETE ON project_environments BEGIN DELETE FROM cedar_relationships WHERE entity_id = OLD.id AND entity_type = \'Celest::Project::Environment\';DELETE FROM cedar_entities WHERE entity_id = OLD.id AND entity_type = \'Celest::Project::Environment\';END', + 'project_environments_delete_trg', + ); + late final Shape22 projectEnvironmentAsts = Shape22( + source: i0.VersionedTable( + entityName: 'project_environment_asts', + withoutRowId: true, + isStrict: false, + tableConstraints: [ + 'CONSTRAINT fk_environment_metadata_project_environment_id FOREIGN KEY(project_environment_id)REFERENCES project_environments(id)ON UPDATE CASCADE ON DELETE CASCADE', + ], + columns: [_column_95, _column_96, _column_97, _column_98], + attachedDatabase: database, + ), + alias: null, + ); + late final Shape23 projectEnvironmentAssets = Shape23( + source: i0.VersionedTable( + entityName: 'project_environment_assets', + withoutRowId: true, + isStrict: false, + tableConstraints: [ + 'PRIMARY KEY(project_environment_id, name)', + 'CONSTRAINT fk_environment_assets_project_environment_id FOREIGN KEY(project_environment_id)REFERENCES project_environments(id)ON UPDATE CASCADE ON DELETE CASCADE', + ], + columns: [_column_92, _column_99, _column_100, _column_101, _column_24], + attachedDatabase: database, + ), + alias: null, + ); + late final Shape24 projectEnvironmentStates = Shape24( + source: i0.VersionedTable( + entityName: 'project_environment_states', + withoutRowId: true, + isStrict: false, + tableConstraints: [ + 'CONSTRAINT fk_project_environment_state_project_environment_id FOREIGN KEY(project_environment_id)REFERENCES project_environments(id)ON UPDATE CASCADE ON DELETE CASCADE', + ], + columns: [_column_95, _column_102, _column_103, _column_104, _column_105], + attachedDatabase: database, + ), + alias: null, + ); + final i1.Index projectsFkParentIdx = i1.Index( + 'projects_fk_parent_idx', + 'CREATE INDEX IF NOT EXISTS projects_fk_parent_idx ON projects (parent_type, parent_id)', + ); + final i1.Trigger projectsUpdateTimeTrg = i1.Trigger( + 'CREATE TRIGGER IF NOT EXISTS projects_update_time_trg AFTER UPDATE ON projects BEGIN UPDATE projects SET update_time = unixepoch(\'now\', \'subsec\') WHERE id = OLD.id;END', + 'projects_update_time_trg', + ); + final i1.Trigger projectsCreateTrg = i1.Trigger( + 'CREATE TRIGGER IF NOT EXISTS projects_create_trg BEFORE INSERT ON projects BEGIN INSERT INTO cedar_entities (entity_type, entity_id) VALUES (\'Celest::Project\', NEW.id);INSERT INTO cedar_relationships (entity_type, entity_id, parent_type, parent_id) VALUES (\'Celest::Project\', NEW.id, NEW.parent_type, NEW.parent_id);END', + 'projects_create_trg', + ); + final i1.Trigger projectsSetParentTrg = i1.Trigger( + 'CREATE TRIGGER IF NOT EXISTS projects_set_parent_trg AFTER UPDATE OF parent_type, parent_id ON projects WHEN OLD.parent_type != NEW.parent_type OR OLD.parent_id != NEW.parent_id BEGIN UPDATE cedar_relationships SET parent_type = NEW.parent_type, parent_id = NEW.parent_id WHERE entity_id = OLD.id AND entity_type = \'Celest::Project\';END', + 'projects_set_parent_trg', + ); + final i1.Trigger projectsDeleteTrg = i1.Trigger( + 'CREATE TRIGGER IF NOT EXISTS projects_delete_trg AFTER DELETE ON projects BEGIN DELETE FROM cedar_relationships WHERE entity_type = \'Celest::Project\' AND entity_id = OLD.id;DELETE FROM cedar_relationships WHERE parent_type = \'Celest::Project\' AND parent_id = OLD.id;DELETE FROM cedar_entities WHERE entity_id = OLD.id AND entity_type = \'Celest::Project\';END', + 'projects_delete_trg', + ); + final i1.Index organizationsParentIdx = i1.Index( + 'organizations_parent_idx', + 'CREATE INDEX IF NOT EXISTS organizations_parent_idx ON organizations (parent_type, parent_id)', + ); + final i1.Trigger organizationsUpdateTime = i1.Trigger( + 'CREATE TRIGGER IF NOT EXISTS organizations_update_time AFTER UPDATE ON organizations BEGIN UPDATE organizations SET update_time = unixepoch(\'now\', \'subsec\') WHERE id = OLD.id;END', + 'organizations_update_time', + ); + final i1.Trigger organizationsCreate = i1.Trigger( + 'CREATE TRIGGER IF NOT EXISTS organizations_create BEFORE INSERT ON organizations BEGIN INSERT INTO cedar_entities (entity_type, entity_id) VALUES (\'Celest::Organization\', NEW.id);END', + 'organizations_create', + ); + final i1.Trigger organizationsCreateParent = i1.Trigger( + 'CREATE TRIGGER IF NOT EXISTS organizations_create_parent AFTER INSERT ON organizations WHEN NEW.parent_id IS NOT NULL BEGIN INSERT INTO cedar_relationships (entity_type, entity_id, parent_type, parent_id) VALUES (\'Celest::Organization\', NEW.id, NEW.parent_type, NEW.parent_id);END', + 'organizations_create_parent', + ); + final i1.Trigger organizationsAddParent = i1.Trigger( + 'CREATE TRIGGER IF NOT EXISTS organizations_add_parent AFTER UPDATE OF parent_id ON organizations WHEN OLD.parent_id IS NULL AND NEW.parent_id IS NOT NULL BEGIN INSERT INTO cedar_relationships (entity_type, entity_id, parent_type, parent_id) VALUES (\'Celest::Organization\', NEW.id, NEW.parent_type, NEW.parent_id);END', + 'organizations_add_parent', + ); + final i1.Trigger organizationsSetParent = i1.Trigger( + 'CREATE TRIGGER IF NOT EXISTS organizations_set_parent AFTER UPDATE OF parent_type, parent_id ON organizations WHEN(OLD.parent_type != NEW.parent_type OR OLD.parent_id != NEW.parent_id)AND NEW.parent_id IS NOT NULL BEGIN UPDATE cedar_relationships SET parent_type = NEW.parent_type, parent_id = NEW.parent_id WHERE entity_id = OLD.id AND entity_type = \'Celest::Organization\';END', + 'organizations_set_parent', + ); + final i1.Trigger organizationsRemoveParent = i1.Trigger( + 'CREATE TRIGGER IF NOT EXISTS organizations_remove_parent AFTER UPDATE OF parent_id ON organizations WHEN OLD.parent_id IS NOT NULL AND NEW.parent_id IS NULL BEGIN DELETE FROM cedar_relationships WHERE entity_id = OLD.id AND entity_type = \'Celest::Organization\' AND parent_id = OLD.parent_id AND parent_type = OLD.parent_type;END', + 'organizations_remove_parent', + ); + final i1.Trigger organizationsDelete = i1.Trigger( + 'CREATE TRIGGER IF NOT EXISTS organizations_delete AFTER DELETE ON organizations BEGIN DELETE FROM cedar_relationships WHERE entity_type = \'Celest::Organization\' AND entity_id = OLD.id;DELETE FROM cedar_relationships WHERE parent_type = \'Celest::Organization\' AND parent_id = OLD.id;DELETE FROM cedar_entities WHERE entity_type = \'Celest::Organization\' AND entity_id = OLD.id;END', + 'organizations_delete', + ); + late final Shape25 operations = Shape25( + source: i0.VersionedTable( + entityName: 'operations', + withoutRowId: false, + isStrict: false, + tableConstraints: [], + columns: [ + _column_56, + _column_106, + _column_107, + _column_108, + _column_109, + _column_67, + _column_110, + _column_111, + _column_112, + _column_65, + _column_66, + ], + attachedDatabase: database, + ), + alias: null, + ); + final i1.Index operationsFkOwnerIdx = i1.Index( + 'operations_fk_owner_idx', + 'CREATE INDEX IF NOT EXISTS operations_fk_owner_idx ON operations (owner_type, owner_id)', + ); + final i1.Index operationsFkResourceIdx = i1.Index( + 'operations_fk_resource_idx', + 'CREATE INDEX IF NOT EXISTS operations_fk_resource_idx ON operations (resource_type, resource_id)', + ); + final i1.Trigger operationsTriggerCreate = i1.Trigger( + 'CREATE TRIGGER IF NOT EXISTS operations_trigger_create BEFORE INSERT ON operations BEGIN INSERT INTO cedar_entities (entity_type, entity_id) VALUES (\'Celest::Operation\', NEW.id);END', + 'operations_trigger_create', + ); + final i1.Trigger operationsTriggerCreateOwner = i1.Trigger( + 'CREATE TRIGGER IF NOT EXISTS operations_trigger_create_owner AFTER INSERT ON operations WHEN NEW.owner_id IS NOT NULL BEGIN INSERT INTO cedar_relationships (entity_type, entity_id, parent_type, parent_id) VALUES (\'Celest::Operation\', NEW.id, NEW.owner_type, NEW.owner_id);END', + 'operations_trigger_create_owner', + ); + final i1.Trigger operationsTriggerCreateResource = i1.Trigger( + 'CREATE TRIGGER IF NOT EXISTS operations_trigger_create_resource AFTER INSERT ON operations WHEN NEW.resource_id IS NOT NULL BEGIN INSERT INTO cedar_relationships (entity_type, entity_id, parent_type, parent_id) VALUES (\'Celest::Operation\', NEW.id, NEW.resource_type, NEW.resource_id);END', + 'operations_trigger_create_resource', + ); + final i1.Trigger operationsTriggerAddOwner = i1.Trigger( + 'CREATE TRIGGER IF NOT EXISTS operations_trigger_add_owner AFTER UPDATE OF owner_id ON operations WHEN OLD.owner_id IS NULL AND NEW.owner_id IS NOT NULL BEGIN INSERT INTO cedar_relationships (entity_type, entity_id, parent_type, parent_id) VALUES (\'Celest::Operation\', NEW.id, NEW.owner_type, NEW.owner_id);END', + 'operations_trigger_add_owner', + ); + final i1.Trigger operationsTriggerAddResource = i1.Trigger( + 'CREATE TRIGGER IF NOT EXISTS operations_trigger_add_resource AFTER UPDATE OF resource_id ON operations WHEN OLD.resource_id IS NULL AND NEW.resource_id IS NOT NULL BEGIN INSERT INTO cedar_relationships (entity_type, entity_id, parent_type, parent_id) VALUES (\'Celest::Operation\', NEW.id, NEW.resource_type, NEW.resource_id);END', + 'operations_trigger_add_resource', + ); + final i1.Trigger operationsTriggerSetOwner = i1.Trigger( + 'CREATE TRIGGER IF NOT EXISTS operations_trigger_set_owner AFTER UPDATE OF owner_type, owner_id ON operations WHEN(OLD.owner_type != NEW.owner_type OR OLD.owner_id != NEW.owner_id)AND OLD.owner_id IS NOT NULL AND NEW.owner_id IS NOT NULL BEGIN UPDATE cedar_relationships SET parent_type = NEW.owner_type, parent_id = NEW.owner_id WHERE entity_id = OLD.id AND entity_type = \'Celest::Operation\' AND parent_type = OLD.owner_type AND parent_id = OLD.owner_id;END', + 'operations_trigger_set_owner', + ); + final i1.Trigger operationsTriggerSetResource = i1.Trigger( + 'CREATE TRIGGER IF NOT EXISTS operations_trigger_set_resource AFTER UPDATE OF resource_type, resource_id ON operations WHEN(OLD.resource_type != NEW.resource_type OR OLD.resource_id != NEW.resource_id)AND OLD.resource_id IS NOT NULL AND NEW.resource_id IS NOT NULL BEGIN UPDATE cedar_relationships SET parent_type = NEW.resource_type, parent_id = NEW.resource_id WHERE entity_id = OLD.id AND entity_type = \'Celest::Operation\' AND parent_type = OLD.resource_type AND parent_id = OLD.resource_id;END', + 'operations_trigger_set_resource', + ); + final i1.Trigger operationsTriggerDelete = i1.Trigger( + 'CREATE TRIGGER IF NOT EXISTS operations_trigger_delete AFTER DELETE ON operations BEGIN DELETE FROM cedar_relationships WHERE entity_id = OLD.id AND entity_type = \'Celest::Operation\';DELETE FROM cedar_entities WHERE entity_id = OLD.id AND entity_type = \'Celest::Operation\';END', + 'operations_trigger_delete', + ); +} + +class Shape0 extends i0.VersionedTable { + Shape0({required super.source, required super.alias}) : super.aliased(); + i1.GeneratedColumn get userId => + columnsByName['user_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get givenName => + columnsByName['given_name']! as i1.GeneratedColumn; + i1.GeneratedColumn get familyName => + columnsByName['family_name']! as i1.GeneratedColumn; + i1.GeneratedColumn get timeZone => + columnsByName['time_zone']! as i1.GeneratedColumn; + i1.GeneratedColumn get languageCode => + columnsByName['language_code']! as i1.GeneratedColumn; + i1.GeneratedColumn get createTime => + columnsByName['create_time']! as i1.GeneratedColumn; + i1.GeneratedColumn get updateTime => + columnsByName['update_time']! as i1.GeneratedColumn; +} + +i1.GeneratedColumn _column_0(String aliasedName) => + i1.GeneratedColumn( + 'user_id', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); +i1.GeneratedColumn _column_1(String aliasedName) => + i1.GeneratedColumn( + 'given_name', + aliasedName, + true, + type: i1.DriftSqlType.string, + $customConstraints: '', + ); +i1.GeneratedColumn _column_2(String aliasedName) => + i1.GeneratedColumn( + 'family_name', + aliasedName, + true, + type: i1.DriftSqlType.string, + $customConstraints: '', + ); +i1.GeneratedColumn _column_3(String aliasedName) => + i1.GeneratedColumn( + 'time_zone', + aliasedName, + true, + type: i1.DriftSqlType.string, + $customConstraints: '', + ); +i1.GeneratedColumn _column_4(String aliasedName) => + i1.GeneratedColumn( + 'language_code', + aliasedName, + true, + type: i1.DriftSqlType.string, + $customConstraints: '', + ); +i1.GeneratedColumn _column_5(String aliasedName) => + i1.GeneratedColumn( + 'create_time', + aliasedName, + false, + type: i1.DriftSqlType.double, + $customConstraints: 'NOT NULL DEFAULT (unixepoch(\'now\', \'subsec\'))', + defaultValue: const CustomExpression('unixepoch(\'now\', \'subsec\')'), + ); +i1.GeneratedColumn _column_6(String aliasedName) => + i1.GeneratedColumn( + 'update_time', + aliasedName, + true, + type: i1.DriftSqlType.double, + $customConstraints: '', + ); + +class Shape1 extends i0.VersionedTable { + Shape1({required super.source, required super.alias}) : super.aliased(); + i1.GeneratedColumn get fqn => + columnsByName['fqn']! as i1.GeneratedColumn; +} + +i1.GeneratedColumn _column_7(String aliasedName) => + i1.GeneratedColumn( + 'fqn', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); + +class Shape2 extends i0.VersionedTable { + Shape2({required super.source, required super.alias}) : super.aliased(); + i1.GeneratedColumn get entityType => + columnsByName['entity_type']! as i1.GeneratedColumn; + i1.GeneratedColumn get entityId => + columnsByName['entity_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get attributeJson => + columnsByName['attribute_json']! as i1.GeneratedColumn; + i1.GeneratedColumn get entityJson => + columnsByName['entity_json']! as i1.GeneratedColumn; +} + +i1.GeneratedColumn _column_8(String aliasedName) => + i1.GeneratedColumn( + 'entity_type', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: 'NOT NULL REFERENCES cedar_types(fqn)', + ); +i1.GeneratedColumn _column_9(String aliasedName) => + i1.GeneratedColumn( + 'entity_id', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: 'NOT NULL', + ); +i1.GeneratedColumn _column_10(String aliasedName) => + i1.GeneratedColumn( + 'attribute_json', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: 'NOT NULL DEFAULT \'{}\'', + defaultValue: const CustomExpression('\'{}\''), + ); +i1.GeneratedColumn _column_11( + String aliasedName, +) => i1.GeneratedColumn( + 'entity_json', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: + 'NOT NULL GENERATED ALWAYS AS (json_object(\'type\', entity_type, \'id\', entity_id)) VIRTUAL', +); + +class Shape3 extends i0.VersionedTable { + Shape3({required super.source, required super.alias}) : super.aliased(); + i1.GeneratedColumn get entityType => + columnsByName['entity_type']! as i1.GeneratedColumn; + i1.GeneratedColumn get entityId => + columnsByName['entity_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get entityJson => + columnsByName['entity_json']! as i1.GeneratedColumn; + i1.GeneratedColumn get parentType => + columnsByName['parent_type']! as i1.GeneratedColumn; + i1.GeneratedColumn get parentId => + columnsByName['parent_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get parentJson => + columnsByName['parent_json']! as i1.GeneratedColumn; +} + +i1.GeneratedColumn _column_12(String aliasedName) => + i1.GeneratedColumn( + 'entity_type', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: 'NOT NULL', + ); +i1.GeneratedColumn _column_13(String aliasedName) => + i1.GeneratedColumn( + 'parent_type', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: 'NOT NULL', + ); +i1.GeneratedColumn _column_14(String aliasedName) => + i1.GeneratedColumn( + 'parent_id', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: 'NOT NULL', + ); +i1.GeneratedColumn _column_15( + String aliasedName, +) => i1.GeneratedColumn( + 'parent_json', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: + 'NOT NULL GENERATED ALWAYS AS (json_object(\'type\', parent_type, \'id\', parent_id)) VIRTUAL', +); + +class Shape4 extends i0.VersionedTable { + Shape4({required super.source, required super.alias}) : super.aliased(); + i1.GeneratedColumn get userId => + columnsByName['user_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get email => + columnsByName['email']! as i1.GeneratedColumn; + i1.GeneratedColumn get isVerified => + columnsByName['is_verified']! as i1.GeneratedColumn; + i1.GeneratedColumn get isPrimary => + columnsByName['is_primary']! as i1.GeneratedColumn; +} + +i1.GeneratedColumn _column_16(String aliasedName) => + i1.GeneratedColumn( + 'user_id', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: 'NOT NULL', + ); +i1.GeneratedColumn _column_17(String aliasedName) => + i1.GeneratedColumn( + 'email', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: 'NOT NULL', + ); +i1.GeneratedColumn _column_18(String aliasedName) => + i1.GeneratedColumn( + 'is_verified', + aliasedName, + false, + type: i1.DriftSqlType.bool, + $customConstraints: 'NOT NULL DEFAULT FALSE', + defaultValue: const CustomExpression('FALSE'), + ); +i1.GeneratedColumn _column_19(String aliasedName) => + i1.GeneratedColumn( + 'is_primary', + aliasedName, + false, + type: i1.DriftSqlType.bool, + $customConstraints: 'NOT NULL DEFAULT FALSE', + defaultValue: const CustomExpression('FALSE'), + ); + +class Shape5 extends i0.VersionedTable { + Shape5({required super.source, required super.alias}) : super.aliased(); + i1.GeneratedColumn get userId => + columnsByName['user_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get phoneNumber => + columnsByName['phone_number']! as i1.GeneratedColumn; + i1.GeneratedColumn get isVerified => + columnsByName['is_verified']! as i1.GeneratedColumn; + i1.GeneratedColumn get isPrimary => + columnsByName['is_primary']! as i1.GeneratedColumn; +} + +i1.GeneratedColumn _column_20(String aliasedName) => + i1.GeneratedColumn( + 'phone_number', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: 'NOT NULL', + ); + +class Shape6 extends i0.VersionedTable { + Shape6({required super.source, required super.alias}) : super.aliased(); + i1.GeneratedColumn get projectId => + columnsByName['project_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get version => + columnsByName['version']! as i1.GeneratedColumn; + i1.GeneratedColumn get resolvedAst => + columnsByName['resolved_ast']! as i1.GeneratedColumn; + i1.GeneratedColumn get etag => + columnsByName['etag']! as i1.GeneratedColumn; +} + +i1.GeneratedColumn _column_21(String aliasedName) => + i1.GeneratedColumn( + 'project_id', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); +i1.GeneratedColumn _column_22(String aliasedName) => + i1.GeneratedColumn( + 'version', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: 'NOT NULL', + ); +i1.GeneratedColumn _column_23(String aliasedName) => + i1.GeneratedColumn( + 'resolved_ast', + aliasedName, + false, + type: i1.DriftSqlType.blob, + $customConstraints: 'NOT NULL', + ); +i1.GeneratedColumn _column_24(String aliasedName) => + i1.GeneratedColumn( + 'etag', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: 'NOT NULL', + ); + +class Shape7 extends i0.VersionedTable { + Shape7({required super.source, required super.alias}) : super.aliased(); + i1.GeneratedColumn get apiId => + columnsByName['api_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get projectId => + columnsByName['project_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get resolvedAst => + columnsByName['resolved_ast']! as i1.GeneratedColumn; + i1.GeneratedColumn get etag => + columnsByName['etag']! as i1.GeneratedColumn; +} + +i1.GeneratedColumn _column_25(String aliasedName) => + i1.GeneratedColumn( + 'api_id', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); +i1.GeneratedColumn _column_26(String aliasedName) => + i1.GeneratedColumn( + 'project_id', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: 'NOT NULL', + ); + +class Shape8 extends i0.VersionedTable { + Shape8({required super.source, required super.alias}) : super.aliased(); + i1.GeneratedColumn get functionId => + columnsByName['function_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get apiId => + columnsByName['api_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get resolvedAst => + columnsByName['resolved_ast']! as i1.GeneratedColumn; + i1.GeneratedColumn get etag => + columnsByName['etag']! as i1.GeneratedColumn; +} + +i1.GeneratedColumn _column_27(String aliasedName) => + i1.GeneratedColumn( + 'function_id', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); +i1.GeneratedColumn _column_28(String aliasedName) => + i1.GeneratedColumn( + 'api_id', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: 'NOT NULL', + ); + +class Shape9 extends i0.VersionedTable { + Shape9({required super.source, required super.alias}) : super.aliased(); + i1.GeneratedColumn get schemaVersion => + columnsByName['schema_version']! as i1.GeneratedColumn; +} + +i1.GeneratedColumn _column_29(String aliasedName) => + i1.GeneratedColumn( + 'schema_version', + aliasedName, + false, + type: i1.DriftSqlType.int, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); + +class Shape10 extends i0.VersionedTable { + Shape10({required super.source, required super.alias}) : super.aliased(); + i1.GeneratedColumn get cryptoKeyId => + columnsByName['crypto_key_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get keyPurpose => + columnsByName['key_purpose']! as i1.GeneratedColumn; + i1.GeneratedColumn get keyAlgorithm => + columnsByName['key_algorithm']! as i1.GeneratedColumn; + i1.GeneratedColumn get keyMaterial => + columnsByName['key_material']! as i1.GeneratedColumn; + i1.GeneratedColumn get externalCryptoKeyId => + columnsByName['external_crypto_key_id']! as i1.GeneratedColumn; +} + +i1.GeneratedColumn _column_30(String aliasedName) => + i1.GeneratedColumn( + 'crypto_key_id', + aliasedName, + false, + type: i1.DriftSqlType.blob, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); +i1.GeneratedColumn _column_31(String aliasedName) => + i1.GeneratedColumn( + 'key_purpose', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: 'NOT NULL', + ); +i1.GeneratedColumn _column_32(String aliasedName) => + i1.GeneratedColumn( + 'key_algorithm', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: 'NOT NULL', + ); +i1.GeneratedColumn _column_33(String aliasedName) => + i1.GeneratedColumn( + 'key_material', + aliasedName, + true, + type: i1.DriftSqlType.blob, + $customConstraints: '', + ); +i1.GeneratedColumn _column_34(String aliasedName) => + i1.GeneratedColumn( + 'external_crypto_key_id', + aliasedName, + true, + type: i1.DriftSqlType.string, + $customConstraints: 'UNIQUE', + ); + +class Shape11 extends i0.VersionedTable { + Shape11({required super.source, required super.alias}) : super.aliased(); + i1.GeneratedColumn get rowid => + columnsByName['rowid']! as i1.GeneratedColumn; + i1.GeneratedColumn get sessionId => + columnsByName['session_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get cryptoKeyId => + columnsByName['crypto_key_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get userId => + columnsByName['user_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get clientInfo => + columnsByName['client_info']! as i1.GeneratedColumn; + i1.GeneratedColumn get authenticationFactor => + columnsByName['authentication_factor']! + as i1.GeneratedColumn; + i1.GeneratedColumn get state => + columnsByName['state']! as i1.GeneratedColumn; + i1.GeneratedColumn get ipAddress => + columnsByName['ip_address']! as i1.GeneratedColumn; + i1.GeneratedColumn get externalSessionId => + columnsByName['external_session_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get createTime => + columnsByName['create_time']! as i1.GeneratedColumn; + i1.GeneratedColumn get updateTime => + columnsByName['update_time']! as i1.GeneratedColumn; + i1.GeneratedColumn get expireTime => + columnsByName['expire_time']! as i1.GeneratedColumn; +} + +i1.GeneratedColumn _column_35(String aliasedName) => + i1.GeneratedColumn( + 'rowid', + aliasedName, + false, + hasAutoIncrement: true, + type: i1.DriftSqlType.int, + $customConstraints: 'PRIMARY KEY AUTOINCREMENT', + ); +i1.GeneratedColumn _column_36(String aliasedName) => + i1.GeneratedColumn( + 'session_id', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: 'NOT NULL UNIQUE', + ); +i1.GeneratedColumn _column_37(String aliasedName) => + i1.GeneratedColumn( + 'crypto_key_id', + aliasedName, + false, + type: i1.DriftSqlType.blob, + $customConstraints: 'NOT NULL', + ); +i1.GeneratedColumn _column_38(String aliasedName) => + i1.GeneratedColumn( + 'client_info', + aliasedName, + true, + type: i1.DriftSqlType.blob, + $customConstraints: '', + ); +i1.GeneratedColumn _column_39(String aliasedName) => + i1.GeneratedColumn( + 'authentication_factor', + aliasedName, + false, + type: i1.DriftSqlType.blob, + $customConstraints: 'NOT NULL', + ); +i1.GeneratedColumn _column_40(String aliasedName) => + i1.GeneratedColumn( + 'state', + aliasedName, + true, + type: i1.DriftSqlType.blob, + $customConstraints: '', + ); +i1.GeneratedColumn _column_41(String aliasedName) => + i1.GeneratedColumn( + 'ip_address', + aliasedName, + true, + type: i1.DriftSqlType.string, + $customConstraints: '', + ); +i1.GeneratedColumn _column_42(String aliasedName) => + i1.GeneratedColumn( + 'external_session_id', + aliasedName, + true, + type: i1.DriftSqlType.string, + $customConstraints: '', + ); +i1.GeneratedColumn _column_43(String aliasedName) => + i1.GeneratedColumn( + 'expire_time', + aliasedName, + false, + type: i1.DriftSqlType.double, + $customConstraints: 'NOT NULL', + ); + +class Shape12 extends i0.VersionedTable { + Shape12({required super.source, required super.alias}) : super.aliased(); + i1.GeneratedColumn get rowid => + columnsByName['rowid']! as i1.GeneratedColumn; + i1.GeneratedColumn get sessionId => + columnsByName['session_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get resendAttempt => + columnsByName['resend_attempt']! as i1.GeneratedColumn; + i1.GeneratedColumn get verifyAttempt => + columnsByName['verify_attempt']! as i1.GeneratedColumn; + i1.GeneratedColumn get updateTime => + columnsByName['update_time']! as i1.GeneratedColumn; +} + +i1.GeneratedColumn _column_44(String aliasedName) => + i1.GeneratedColumn( + 'resend_attempt', + aliasedName, + false, + type: i1.DriftSqlType.int, + $customConstraints: 'NOT NULL DEFAULT 0', + defaultValue: const CustomExpression('0'), + ); +i1.GeneratedColumn _column_45(String aliasedName) => + i1.GeneratedColumn( + 'verify_attempt', + aliasedName, + false, + type: i1.DriftSqlType.int, + $customConstraints: 'NOT NULL DEFAULT 0', + defaultValue: const CustomExpression('0'), + ); +i1.GeneratedColumn _column_46(String aliasedName) => + i1.GeneratedColumn( + 'update_time', + aliasedName, + false, + type: i1.DriftSqlType.double, + $customConstraints: 'NOT NULL DEFAULT (unixepoch(\'now\', \'subsec\'))', + defaultValue: const CustomExpression('unixepoch(\'now\', \'subsec\')'), + ); + +class Shape13 extends i0.VersionedTable { + Shape13({required super.source, required super.alias}) : super.aliased(); + i1.GeneratedColumn get corkId => + columnsByName['cork_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get cryptoKeyId => + columnsByName['crypto_key_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get bearerType => + columnsByName['bearer_type']! as i1.GeneratedColumn; + i1.GeneratedColumn get bearerId => + columnsByName['bearer_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get audienceType => + columnsByName['audience_type']! as i1.GeneratedColumn; + i1.GeneratedColumn get audienceId => + columnsByName['audience_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get issuerType => + columnsByName['issuer_type']! as i1.GeneratedColumn; + i1.GeneratedColumn get issuerId => + columnsByName['issuer_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get createTime => + columnsByName['create_time']! as i1.GeneratedColumn; + i1.GeneratedColumn get expireTime => + columnsByName['expire_time']! as i1.GeneratedColumn; + i1.GeneratedColumn get lastUseTime => + columnsByName['last_use_time']! as i1.GeneratedColumn; +} + +i1.GeneratedColumn _column_47(String aliasedName) => + i1.GeneratedColumn( + 'cork_id', + aliasedName, + false, + type: i1.DriftSqlType.blob, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); +i1.GeneratedColumn _column_48(String aliasedName) => + i1.GeneratedColumn( + 'bearer_type', + aliasedName, + true, + type: i1.DriftSqlType.string, + $customConstraints: '', + ); +i1.GeneratedColumn _column_49(String aliasedName) => + i1.GeneratedColumn( + 'bearer_id', + aliasedName, + true, + type: i1.DriftSqlType.string, + $customConstraints: '', + ); +i1.GeneratedColumn _column_50(String aliasedName) => + i1.GeneratedColumn( + 'audience_type', + aliasedName, + true, + type: i1.DriftSqlType.string, + $customConstraints: '', + ); +i1.GeneratedColumn _column_51(String aliasedName) => + i1.GeneratedColumn( + 'audience_id', + aliasedName, + true, + type: i1.DriftSqlType.string, + $customConstraints: '', + ); +i1.GeneratedColumn _column_52(String aliasedName) => + i1.GeneratedColumn( + 'issuer_type', + aliasedName, + true, + type: i1.DriftSqlType.string, + $customConstraints: '', + ); +i1.GeneratedColumn _column_53(String aliasedName) => + i1.GeneratedColumn( + 'issuer_id', + aliasedName, + true, + type: i1.DriftSqlType.string, + $customConstraints: '', + ); +i1.GeneratedColumn _column_54(String aliasedName) => + i1.GeneratedColumn( + 'expire_time', + aliasedName, + true, + type: i1.DriftSqlType.double, + $customConstraints: '', + ); +i1.GeneratedColumn _column_55(String aliasedName) => + i1.GeneratedColumn( + 'last_use_time', + aliasedName, + true, + type: i1.DriftSqlType.double, + $customConstraints: '', + ); + +class Shape14 extends i0.VersionedTable { + Shape14({required super.source, required super.alias}) : super.aliased(); + i1.GeneratedColumn get id => + columnsByName['id']! as i1.GeneratedColumn; + i1.GeneratedColumn get policyId => + columnsByName['policy_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get policy => + columnsByName['policy']! as i1.GeneratedColumn; + i1.GeneratedColumn get enforcementLevel => + columnsByName['enforcement_level']! as i1.GeneratedColumn; +} + +i1.GeneratedColumn _column_56(String aliasedName) => + i1.GeneratedColumn( + 'id', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); +i1.GeneratedColumn _column_57(String aliasedName) => + i1.GeneratedColumn( + 'policy_id', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: 'NOT NULL UNIQUE', + ); +i1.GeneratedColumn _column_58(String aliasedName) => + i1.GeneratedColumn( + 'policy', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: 'NOT NULL', + ); +i1.GeneratedColumn _column_59(String aliasedName) => + i1.GeneratedColumn( + 'enforcement_level', + aliasedName, + false, + type: i1.DriftSqlType.int, + $customConstraints: 'NOT NULL DEFAULT 1', + defaultValue: const CustomExpression('1'), + ); + +class Shape15 extends i0.VersionedTable { + Shape15({required super.source, required super.alias}) : super.aliased(); + i1.GeneratedColumn get id => + columnsByName['id']! as i1.GeneratedColumn; + i1.GeneratedColumn get templateId => + columnsByName['template_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get template => + columnsByName['template']! as i1.GeneratedColumn; +} + +i1.GeneratedColumn _column_60(String aliasedName) => + i1.GeneratedColumn( + 'template_id', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: 'NOT NULL UNIQUE', + ); +i1.GeneratedColumn _column_61(String aliasedName) => + i1.GeneratedColumn( + 'template', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: 'NOT NULL', + ); + +class Shape16 extends i0.VersionedTable { + Shape16({required super.source, required super.alias}) : super.aliased(); + i1.GeneratedColumn get id => + columnsByName['id']! as i1.GeneratedColumn; + i1.GeneratedColumn get policyId => + columnsByName['policy_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get templateId => + columnsByName['template_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get principalType => + columnsByName['principal_type']! as i1.GeneratedColumn; + i1.GeneratedColumn get principalId => + columnsByName['principal_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get resourceType => + columnsByName['resource_type']! as i1.GeneratedColumn; + i1.GeneratedColumn get resourceId => + columnsByName['resource_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get enforcementLevel => + columnsByName['enforcement_level']! as i1.GeneratedColumn; +} + +i1.GeneratedColumn _column_62(String aliasedName) => + i1.GeneratedColumn( + 'template_id', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: 'NOT NULL', + ); +i1.GeneratedColumn _column_63(String aliasedName) => + i1.GeneratedColumn( + 'principal_type', + aliasedName, + true, + type: i1.DriftSqlType.string, + $customConstraints: '', + ); +i1.GeneratedColumn _column_64(String aliasedName) => + i1.GeneratedColumn( + 'principal_id', + aliasedName, + true, + type: i1.DriftSqlType.string, + $customConstraints: '', + ); +i1.GeneratedColumn _column_65(String aliasedName) => + i1.GeneratedColumn( + 'resource_type', + aliasedName, + true, + type: i1.DriftSqlType.string, + $customConstraints: '', + ); +i1.GeneratedColumn _column_66(String aliasedName) => + i1.GeneratedColumn( + 'resource_id', + aliasedName, + true, + type: i1.DriftSqlType.string, + $customConstraints: '', + ); + +class Shape17 extends i0.VersionedTable { + Shape17({required super.source, required super.alias}) : super.aliased(); + i1.GeneratedColumn get rowid => + columnsByName['rowid']! as i1.GeneratedColumn; + i1.GeneratedColumn get createTime => + columnsByName['create_time']! as i1.GeneratedColumn; + i1.GeneratedColumn get expireTime => + columnsByName['expire_time']! as i1.GeneratedColumn; + i1.GeneratedColumn get principalType => + columnsByName['principal_type']! as i1.GeneratedColumn; + i1.GeneratedColumn get principalId => + columnsByName['principal_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get actionType => + columnsByName['action_type']! as i1.GeneratedColumn; + i1.GeneratedColumn get actionId => + columnsByName['action_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get resourceType => + columnsByName['resource_type']! as i1.GeneratedColumn; + i1.GeneratedColumn get resourceId => + columnsByName['resource_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get contextJson => + columnsByName['context_json']! as i1.GeneratedColumn; + i1.GeneratedColumn get decision => + columnsByName['decision']! as i1.GeneratedColumn; + i1.GeneratedColumn get reasonsJson => + columnsByName['reasons_json']! as i1.GeneratedColumn; + i1.GeneratedColumn get errorsJson => + columnsByName['errors_json']! as i1.GeneratedColumn; +} + +i1.GeneratedColumn _column_67(String aliasedName) => + i1.GeneratedColumn( + 'create_time', + aliasedName, + false, + type: i1.DriftSqlType.dateTime, + $customConstraints: 'NOT NULL DEFAULT (unixepoch(\'now\', \'subsec\'))', + defaultValue: const CustomExpression('unixepoch(\'now\', \'subsec\')'), + ); +i1.GeneratedColumn _column_68(String aliasedName) => + i1.GeneratedColumn( + 'expire_time', + aliasedName, + true, + type: i1.DriftSqlType.dateTime, + $customConstraints: '', + ); +i1.GeneratedColumn _column_69(String aliasedName) => + i1.GeneratedColumn( + 'action_type', + aliasedName, + true, + type: i1.DriftSqlType.string, + $customConstraints: '', + ); +i1.GeneratedColumn _column_70(String aliasedName) => + i1.GeneratedColumn( + 'action_id', + aliasedName, + true, + type: i1.DriftSqlType.string, + $customConstraints: '', + ); +i1.GeneratedColumn _column_71(String aliasedName) => + i1.GeneratedColumn( + 'context_json', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: 'NOT NULL DEFAULT \'{}\'', + defaultValue: const CustomExpression('\'{}\''), + ); +i1.GeneratedColumn _column_72(String aliasedName) => + i1.GeneratedColumn( + 'decision', + aliasedName, + false, + type: i1.DriftSqlType.bool, + $customConstraints: 'NOT NULL', + ); +i1.GeneratedColumn _column_73(String aliasedName) => + i1.GeneratedColumn( + 'reasons_json', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: 'NOT NULL DEFAULT \'[]\'', + defaultValue: const CustomExpression('\'[]\''), + ); +i1.GeneratedColumn _column_74(String aliasedName) => + i1.GeneratedColumn( + 'errors_json', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: 'NOT NULL DEFAULT \'[]\'', + defaultValue: const CustomExpression('\'[]\''), + ); + +class Shape18 extends i0.VersionedTable { + Shape18({required super.source, required super.alias}) : super.aliased(); + i1.GeneratedColumn get membershipId => + columnsByName['membership_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get userId => + columnsByName['user_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get parentType => + columnsByName['parent_type']! as i1.GeneratedColumn; + i1.GeneratedColumn get parentId => + columnsByName['parent_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get role => + columnsByName['role']! as i1.GeneratedColumn; + i1.GeneratedColumn get createTime => + columnsByName['create_time']! as i1.GeneratedColumn; + i1.GeneratedColumn get updateTime => + columnsByName['update_time']! as i1.GeneratedColumn; +} + +i1.GeneratedColumn _column_75(String aliasedName) => + i1.GeneratedColumn( + 'membership_id', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); +i1.GeneratedColumn _column_76(String aliasedName) => + i1.GeneratedColumn( + 'role', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: 'NOT NULL', + ); +i1.GeneratedColumn _column_77(String aliasedName) => + i1.GeneratedColumn( + 'update_time', + aliasedName, + false, + type: i1.DriftSqlType.dateTime, + $customConstraints: 'NOT NULL DEFAULT (unixepoch(\'now\', \'subsec\'))', + defaultValue: const CustomExpression('unixepoch(\'now\', \'subsec\')'), + ); + +class Shape19 extends i0.VersionedTable { + Shape19({required super.source, required super.alias}) : super.aliased(); + i1.GeneratedColumn get id => + columnsByName['id']! as i1.GeneratedColumn; + i1.GeneratedColumn get parentType => + columnsByName['parent_type']! as i1.GeneratedColumn; + i1.GeneratedColumn get parentId => + columnsByName['parent_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get organizationId => + columnsByName['organization_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get state => + columnsByName['state']! as i1.GeneratedColumn; + i1.GeneratedColumn get displayName => + columnsByName['display_name']! as i1.GeneratedColumn; + i1.GeneratedColumn get createTime => + columnsByName['create_time']! as i1.GeneratedColumn; + i1.GeneratedColumn get updateTime => + columnsByName['update_time']! as i1.GeneratedColumn; + i1.GeneratedColumn get deleteTime => + columnsByName['delete_time']! as i1.GeneratedColumn; + i1.GeneratedColumn get purgeTime => + columnsByName['purge_time']! as i1.GeneratedColumn; + i1.GeneratedColumn get annotations => + columnsByName['annotations']! as i1.GeneratedColumn; + i1.GeneratedColumn get primaryRegion => + columnsByName['primary_region']! as i1.GeneratedColumn; + i1.GeneratedColumn get reconciling => + columnsByName['reconciling']! as i1.GeneratedColumn; + i1.GeneratedColumn get etag => + columnsByName['etag']! as i1.GeneratedColumn; +} + +i1.GeneratedColumn _column_78(String aliasedName) => + i1.GeneratedColumn( + 'parent_type', + aliasedName, + true, + type: i1.DriftSqlType.string, + $customConstraints: '', + ); +i1.GeneratedColumn _column_79(String aliasedName) => + i1.GeneratedColumn( + 'parent_id', + aliasedName, + true, + type: i1.DriftSqlType.string, + $customConstraints: '', + ); +i1.GeneratedColumn _column_80(String aliasedName) => + i1.GeneratedColumn( + 'organization_id', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: 'NOT NULL UNIQUE', + ); +i1.GeneratedColumn _column_81(String aliasedName) => + i1.GeneratedColumn( + 'state', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: 'NOT NULL DEFAULT \'CREATING\'', + defaultValue: const CustomExpression('\'CREATING\''), + ); +i1.GeneratedColumn _column_82(String aliasedName) => + i1.GeneratedColumn( + 'display_name', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: 'NOT NULL', + ); +i1.GeneratedColumn _column_83(String aliasedName) => + i1.GeneratedColumn( + 'delete_time', + aliasedName, + true, + type: i1.DriftSqlType.dateTime, + $customConstraints: '', + ); +i1.GeneratedColumn _column_84(String aliasedName) => + i1.GeneratedColumn( + 'purge_time', + aliasedName, + true, + type: i1.DriftSqlType.dateTime, + $customConstraints: '', + ); +i1.GeneratedColumn _column_85(String aliasedName) => + i1.GeneratedColumn( + 'annotations', + aliasedName, + true, + type: i1.DriftSqlType.string, + $customConstraints: '', + ); +i1.GeneratedColumn _column_86(String aliasedName) => + i1.GeneratedColumn( + 'primary_region', + aliasedName, + true, + type: i1.DriftSqlType.string, + $customConstraints: '', + ); +i1.GeneratedColumn _column_87(String aliasedName) => + i1.GeneratedColumn( + 'reconciling', + aliasedName, + false, + type: i1.DriftSqlType.bool, + $customConstraints: 'NOT NULL DEFAULT FALSE', + defaultValue: const CustomExpression('FALSE'), + ); +i1.GeneratedColumn _column_88( + String aliasedName, +) => i1.GeneratedColumn( + 'etag', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: + 'NOT NULL GENERATED ALWAYS AS (hex(md5(json_array(id, parent_type, parent_id, organization_id, state, display_name, create_time, update_time, delete_time, purge_time, annotations, primary_region, reconciling)))) STORED', +); + +class Shape20 extends i0.VersionedTable { + Shape20({required super.source, required super.alias}) : super.aliased(); + i1.GeneratedColumn get id => + columnsByName['id']! as i1.GeneratedColumn; + i1.GeneratedColumn get parentType => + columnsByName['parent_type']! as i1.GeneratedColumn; + i1.GeneratedColumn get parentId => + columnsByName['parent_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get projectId => + columnsByName['project_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get state => + columnsByName['state']! as i1.GeneratedColumn; + i1.GeneratedColumn get displayName => + columnsByName['display_name']! as i1.GeneratedColumn; + i1.GeneratedColumn get createTime => + columnsByName['create_time']! as i1.GeneratedColumn; + i1.GeneratedColumn get updateTime => + columnsByName['update_time']! as i1.GeneratedColumn; + i1.GeneratedColumn get deleteTime => + columnsByName['delete_time']! as i1.GeneratedColumn; + i1.GeneratedColumn get purgeTime => + columnsByName['purge_time']! as i1.GeneratedColumn; + i1.GeneratedColumn get annotations => + columnsByName['annotations']! as i1.GeneratedColumn; + i1.GeneratedColumn get regions => + columnsByName['regions']! as i1.GeneratedColumn; + i1.GeneratedColumn get reconciling => + columnsByName['reconciling']! as i1.GeneratedColumn; + i1.GeneratedColumn get etag => + columnsByName['etag']! as i1.GeneratedColumn; +} + +i1.GeneratedColumn _column_89(String aliasedName) => + i1.GeneratedColumn( + 'display_name', + aliasedName, + true, + type: i1.DriftSqlType.string, + $customConstraints: '', + ); +i1.GeneratedColumn _column_90(String aliasedName) => + i1.GeneratedColumn( + 'regions', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: 'NOT NULL', + ); +i1.GeneratedColumn _column_91( + String aliasedName, +) => i1.GeneratedColumn( + 'etag', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: + 'NOT NULL GENERATED ALWAYS AS (hex(md5(json_array(id, parent_type, parent_id, project_id, state, display_name, create_time, update_time, delete_time, purge_time, annotations, regions, reconciling)))) STORED', +); + +class Shape21 extends i0.VersionedTable { + Shape21({required super.source, required super.alias}) : super.aliased(); + i1.GeneratedColumn get id => + columnsByName['id']! as i1.GeneratedColumn; + i1.GeneratedColumn get parentType => + columnsByName['parent_type']! as i1.GeneratedColumn; + i1.GeneratedColumn get parentId => + columnsByName['parent_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get projectEnvironmentId => + columnsByName['project_environment_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get state => + columnsByName['state']! as i1.GeneratedColumn; + i1.GeneratedColumn get displayName => + columnsByName['display_name']! as i1.GeneratedColumn; + i1.GeneratedColumn get createTime => + columnsByName['create_time']! as i1.GeneratedColumn; + i1.GeneratedColumn get updateTime => + columnsByName['update_time']! as i1.GeneratedColumn; + i1.GeneratedColumn get deleteTime => + columnsByName['delete_time']! as i1.GeneratedColumn; + i1.GeneratedColumn get annotations => + columnsByName['annotations']! as i1.GeneratedColumn; + i1.GeneratedColumn get reconciling => + columnsByName['reconciling']! as i1.GeneratedColumn; + i1.GeneratedColumn get etag => + columnsByName['etag']! as i1.GeneratedColumn; +} + +i1.GeneratedColumn _column_92(String aliasedName) => + i1.GeneratedColumn( + 'project_environment_id', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: 'NOT NULL', + ); +i1.GeneratedColumn _column_93( + String aliasedName, +) => i1.GeneratedColumn( + 'reconciling', + aliasedName, + false, + type: i1.DriftSqlType.bool, + $customConstraints: + 'NOT NULL GENERATED ALWAYS AS (state IN (\'CREATING\', \'UPDATING\', \'DELETING\')) VIRTUAL', +); +i1.GeneratedColumn _column_94( + String aliasedName, +) => i1.GeneratedColumn( + 'etag', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: + 'NOT NULL GENERATED ALWAYS AS (hex(md5(json_array(id, parent_type, parent_id, project_environment_id, state, display_name, create_time, update_time, delete_time, annotations, reconciling)))) STORED', +); + +class Shape22 extends i0.VersionedTable { + Shape22({required super.source, required super.alias}) : super.aliased(); + i1.GeneratedColumn get projectEnvironmentId => + columnsByName['project_environment_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get ast => + columnsByName['ast']! as i1.GeneratedColumn; + i1.GeneratedColumn get version => + columnsByName['version']! as i1.GeneratedColumn; + i1.GeneratedColumn get digest => + columnsByName['digest']! as i1.GeneratedColumn; +} + +i1.GeneratedColumn _column_95(String aliasedName) => + i1.GeneratedColumn( + 'project_environment_id', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); +i1.GeneratedColumn _column_96(String aliasedName) => + i1.GeneratedColumn( + 'ast', + aliasedName, + false, + type: i1.DriftSqlType.blob, + $customConstraints: 'NOT NULL', + ); +i1.GeneratedColumn _column_97(String aliasedName) => + i1.GeneratedColumn( + 'version', + aliasedName, + false, + type: i1.DriftSqlType.int, + $customConstraints: 'NOT NULL', + ); +i1.GeneratedColumn _column_98(String aliasedName) => + i1.GeneratedColumn( + 'digest', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: 'NOT NULL GENERATED ALWAYS AS (hex(md5(ast))) STORED', + ); + +class Shape23 extends i0.VersionedTable { + Shape23({required super.source, required super.alias}) : super.aliased(); + i1.GeneratedColumn get projectEnvironmentId => + columnsByName['project_environment_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get type => + columnsByName['type']! as i1.GeneratedColumn; + i1.GeneratedColumn get bucket => + columnsByName['bucket']! as i1.GeneratedColumn; + i1.GeneratedColumn get name => + columnsByName['name']! as i1.GeneratedColumn; + i1.GeneratedColumn get etag => + columnsByName['etag']! as i1.GeneratedColumn; +} + +i1.GeneratedColumn _column_99(String aliasedName) => + i1.GeneratedColumn( + 'type', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: 'NOT NULL', + ); +i1.GeneratedColumn _column_100(String aliasedName) => + i1.GeneratedColumn( + 'bucket', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: 'NOT NULL', + ); +i1.GeneratedColumn _column_101(String aliasedName) => + i1.GeneratedColumn( + 'name', + aliasedName, + false, + type: i1.DriftSqlType.string, + $customConstraints: 'NOT NULL', + ); + +class Shape24 extends i0.VersionedTable { + Shape24({required super.source, required super.alias}) : super.aliased(); + i1.GeneratedColumn get projectEnvironmentId => + columnsByName['project_environment_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get domainName => + columnsByName['domain_name']! as i1.GeneratedColumn; + i1.GeneratedColumn get flyAppName => + columnsByName['fly_app_name']! as i1.GeneratedColumn; + i1.GeneratedColumn get flyVolumeName => + columnsByName['fly_volume_name']! as i1.GeneratedColumn; + i1.GeneratedColumn get flyVolumeId => + columnsByName['fly_volume_id']! as i1.GeneratedColumn; +} + +i1.GeneratedColumn _column_102(String aliasedName) => + i1.GeneratedColumn( + 'domain_name', + aliasedName, + true, + type: i1.DriftSqlType.string, + $customConstraints: '', + ); +i1.GeneratedColumn _column_103(String aliasedName) => + i1.GeneratedColumn( + 'fly_app_name', + aliasedName, + true, + type: i1.DriftSqlType.string, + $customConstraints: '', + ); +i1.GeneratedColumn _column_104(String aliasedName) => + i1.GeneratedColumn( + 'fly_volume_name', + aliasedName, + true, + type: i1.DriftSqlType.string, + $customConstraints: '', + ); +i1.GeneratedColumn _column_105(String aliasedName) => + i1.GeneratedColumn( + 'fly_volume_id', + aliasedName, + true, + type: i1.DriftSqlType.string, + $customConstraints: '', + ); + +class Shape25 extends i0.VersionedTable { + Shape25({required super.source, required super.alias}) : super.aliased(); + i1.GeneratedColumn get id => + columnsByName['id']! as i1.GeneratedColumn; + i1.GeneratedColumn get metadata => + columnsByName['metadata']! as i1.GeneratedColumn; + i1.GeneratedColumn get response => + columnsByName['response']! as i1.GeneratedColumn; + i1.GeneratedColumn get error => + columnsByName['error']! as i1.GeneratedColumn; + i1.GeneratedColumn get done => + columnsByName['done']! as i1.GeneratedColumn; + i1.GeneratedColumn get createTime => + columnsByName['create_time']! as i1.GeneratedColumn; + i1.GeneratedColumn get fullResourceName => + columnsByName['full_resource_name']! as i1.GeneratedColumn; + i1.GeneratedColumn get ownerType => + columnsByName['owner_type']! as i1.GeneratedColumn; + i1.GeneratedColumn get ownerId => + columnsByName['owner_id']! as i1.GeneratedColumn; + i1.GeneratedColumn get resourceType => + columnsByName['resource_type']! as i1.GeneratedColumn; + i1.GeneratedColumn get resourceId => + columnsByName['resource_id']! as i1.GeneratedColumn; +} + +i1.GeneratedColumn _column_106(String aliasedName) => + i1.GeneratedColumn( + 'metadata', + aliasedName, + true, + type: i1.DriftSqlType.string, + $customConstraints: '', + ); +i1.GeneratedColumn _column_107(String aliasedName) => + i1.GeneratedColumn( + 'response', + aliasedName, + true, + type: i1.DriftSqlType.string, + $customConstraints: '', + ); +i1.GeneratedColumn _column_108(String aliasedName) => + i1.GeneratedColumn( + 'error', + aliasedName, + true, + type: i1.DriftSqlType.string, + $customConstraints: '', + ); +i1.GeneratedColumn _column_109( + String aliasedName, +) => i1.GeneratedColumn( + 'done', + aliasedName, + false, + type: i1.DriftSqlType.bool, + $customConstraints: + 'NOT NULL GENERATED ALWAYS AS (response IS NOT NULL OR error IS NOT NULL) VIRTUAL', +); +i1.GeneratedColumn _column_110(String aliasedName) => + i1.GeneratedColumn( + 'full_resource_name', + aliasedName, + true, + type: i1.DriftSqlType.string, + $customConstraints: '', + ); +i1.GeneratedColumn _column_111(String aliasedName) => + i1.GeneratedColumn( + 'owner_type', + aliasedName, + true, + type: i1.DriftSqlType.string, + $customConstraints: '', + ); +i1.GeneratedColumn _column_112(String aliasedName) => + i1.GeneratedColumn( + 'owner_id', + aliasedName, + true, + type: i1.DriftSqlType.string, + $customConstraints: '', + ); +i0.MigrationStepWithVersion migrationSteps({ + required Future Function(i1.Migrator m, Schema2 schema) from1To2, +}) { + return (currentVersion, database) async { + switch (currentVersion) { + case 1: + final schema = Schema2(database: database); + final migrator = i1.Migrator(database, schema); + await from1To2(migrator, schema); + return 2; + default: + throw ArgumentError.value('Unknown migration from $currentVersion'); + } + }; +} + +i1.OnUpgrade stepByStep({ + required Future Function(i1.Migrator m, Schema2 schema) from1To2, +}) => i0.VersionedSchema.stepByStepHelper( + step: migrationSteps(from1To2: from1To2), +); diff --git a/services/celest_cloud_hub/lib/src/database/schema/project_environments.drift b/services/celest_cloud_hub/lib/src/database/schema/project_environments.drift index f9047ab06..68edd99de 100644 --- a/services/celest_cloud_hub/lib/src/database/schema/project_environments.drift +++ b/services/celest_cloud_hub/lib/src/database/schema/project_environments.drift @@ -177,14 +177,23 @@ 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 domain name of the project environment. - domain_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, CONSTRAINT fk_project_environment_state_project_environment_id FOREIGN KEY (project_environment_id) REFERENCES project_environments(id) ON UPDATE CASCADE ON DELETE CASCADE @@ -294,24 +303,28 @@ getProjectEnvironmentState: upsertProjectEnvironmentState( :projectEnvironmentId AS TEXT, + :domainName AS TEXT OR NULL, :flyAppName AS TEXT OR NULL, :flyVolumeName AS TEXT OR NULL, - :domainName AS TEXT OR NULL + :flyVolumeId AS TEXT OR NULL ): INSERT INTO project_environment_states ( project_environment_id, + domain_name, fly_app_name, fly_volume_name, - domain_name + fly_volume_id ) VALUES ( :projectEnvironmentId, + :domainName, :flyAppName, :flyVolumeName, - :domainName + :flyVolumeId ) 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), - domain_name = coalesce(:domainName, domain_name) + fly_volume_id = coalesce(:flyVolumeId, fly_volume_id) RETURNING *; diff --git a/services/celest_cloud_hub/lib/src/database/schema/project_environments.drift.dart b/services/celest_cloud_hub/lib/src/database/schema/project_environments.drift.dart index a7ade8e2d..407223f49 100644 --- a/services/celest_cloud_hub/lib/src/database/schema/project_environments.drift.dart +++ b/services/celest_cloud_hub/lib/src/database/schema/project_environments.drift.dart @@ -793,16 +793,18 @@ typedef $ProjectEnvironmentAssetsProcessedTableManager = typedef $ProjectEnvironmentStatesCreateCompanionBuilder = i1.ProjectEnvironmentStatesCompanion Function({ required String projectEnvironmentId, + i0.Value domainName, i0.Value flyAppName, i0.Value flyVolumeName, - i0.Value domainName, + i0.Value flyVolumeId, }); typedef $ProjectEnvironmentStatesUpdateCompanionBuilder = i1.ProjectEnvironmentStatesCompanion Function({ i0.Value projectEnvironmentId, + i0.Value domainName, i0.Value flyAppName, i0.Value flyVolumeName, - i0.Value domainName, + i0.Value flyVolumeId, }); class $ProjectEnvironmentStatesFilterComposer @@ -819,6 +821,11 @@ class $ProjectEnvironmentStatesFilterComposer builder: (column) => i0.ColumnFilters(column), ); + i0.ColumnFilters get domainName => $composableBuilder( + column: $table.domainName, + builder: (column) => i0.ColumnFilters(column), + ); + i0.ColumnFilters get flyAppName => $composableBuilder( column: $table.flyAppName, builder: (column) => i0.ColumnFilters(column), @@ -829,8 +836,8 @@ class $ProjectEnvironmentStatesFilterComposer builder: (column) => i0.ColumnFilters(column), ); - i0.ColumnFilters get domainName => $composableBuilder( - column: $table.domainName, + i0.ColumnFilters get flyVolumeId => $composableBuilder( + column: $table.flyVolumeId, builder: (column) => i0.ColumnFilters(column), ); } @@ -849,6 +856,11 @@ class $ProjectEnvironmentStatesOrderingComposer builder: (column) => i0.ColumnOrderings(column), ); + i0.ColumnOrderings get domainName => $composableBuilder( + column: $table.domainName, + builder: (column) => i0.ColumnOrderings(column), + ); + i0.ColumnOrderings get flyAppName => $composableBuilder( column: $table.flyAppName, builder: (column) => i0.ColumnOrderings(column), @@ -859,8 +871,8 @@ class $ProjectEnvironmentStatesOrderingComposer builder: (column) => i0.ColumnOrderings(column), ); - i0.ColumnOrderings get domainName => $composableBuilder( - column: $table.domainName, + i0.ColumnOrderings get flyVolumeId => $composableBuilder( + column: $table.flyVolumeId, builder: (column) => i0.ColumnOrderings(column), ); } @@ -879,6 +891,11 @@ class $ProjectEnvironmentStatesAnnotationComposer builder: (column) => column, ); + i0.GeneratedColumn get domainName => $composableBuilder( + column: $table.domainName, + builder: (column) => column, + ); + i0.GeneratedColumn get flyAppName => $composableBuilder( column: $table.flyAppName, builder: (column) => column, @@ -889,8 +906,8 @@ class $ProjectEnvironmentStatesAnnotationComposer builder: (column) => column, ); - i0.GeneratedColumn get domainName => $composableBuilder( - column: $table.domainName, + i0.GeneratedColumn get flyVolumeId => $composableBuilder( + column: $table.flyVolumeId, builder: (column) => column, ); } @@ -942,26 +959,30 @@ class $ProjectEnvironmentStatesTableManager updateCompanionCallback: ({ i0.Value projectEnvironmentId = const i0.Value.absent(), + i0.Value domainName = const i0.Value.absent(), i0.Value flyAppName = const i0.Value.absent(), i0.Value flyVolumeName = const i0.Value.absent(), - i0.Value domainName = const i0.Value.absent(), + i0.Value flyVolumeId = const i0.Value.absent(), }) => i1.ProjectEnvironmentStatesCompanion( projectEnvironmentId: projectEnvironmentId, + domainName: domainName, flyAppName: flyAppName, flyVolumeName: flyVolumeName, - domainName: domainName, + flyVolumeId: flyVolumeId, ), createCompanionCallback: ({ required String projectEnvironmentId, + i0.Value domainName = const i0.Value.absent(), i0.Value flyAppName = const i0.Value.absent(), i0.Value flyVolumeName = const i0.Value.absent(), - i0.Value domainName = const i0.Value.absent(), + i0.Value flyVolumeId = const i0.Value.absent(), }) => i1.ProjectEnvironmentStatesCompanion.insert( projectEnvironmentId: projectEnvironmentId, + domainName: domainName, flyAppName: flyAppName, flyVolumeName: flyVolumeName, - domainName: domainName, + flyVolumeId: flyVolumeId, ), withReferenceMapper: (p0) => @@ -2511,6 +2532,17 @@ class ProjectEnvironmentStates extends i0.Table requiredDuringInsert: true, $customConstraints: 'NOT NULL PRIMARY KEY', ); + static const i0.VerificationMeta _domainNameMeta = const i0.VerificationMeta( + 'domainName', + ); + late final i0.GeneratedColumn domainName = i0.GeneratedColumn( + 'domain_name', + aliasedName, + true, + type: i0.DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); static const i0.VerificationMeta _flyAppNameMeta = const i0.VerificationMeta( 'flyAppName', ); @@ -2533,23 +2565,25 @@ class ProjectEnvironmentStates extends i0.Table requiredDuringInsert: false, $customConstraints: '', ); - static const i0.VerificationMeta _domainNameMeta = const i0.VerificationMeta( - 'domainName', - ); - late final i0.GeneratedColumn domainName = i0.GeneratedColumn( - 'domain_name', - aliasedName, - true, - type: i0.DriftSqlType.string, - requiredDuringInsert: false, - $customConstraints: '', + static const i0.VerificationMeta _flyVolumeIdMeta = const i0.VerificationMeta( + 'flyVolumeId', ); + late final i0.GeneratedColumn flyVolumeId = + i0.GeneratedColumn( + 'fly_volume_id', + aliasedName, + true, + type: i0.DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); @override List get $columns => [ projectEnvironmentId, + domainName, flyAppName, flyVolumeName, - domainName, + flyVolumeId, ]; @override String get aliasedName => _alias ?? actualTableName; @@ -2574,6 +2608,12 @@ class ProjectEnvironmentStates extends i0.Table } else if (isInserting) { context.missing(_projectEnvironmentIdMeta); } + if (data.containsKey('domain_name')) { + context.handle( + _domainNameMeta, + domainName.isAcceptableOrUnknown(data['domain_name']!, _domainNameMeta), + ); + } if (data.containsKey('fly_app_name')) { context.handle( _flyAppNameMeta, @@ -2592,10 +2632,13 @@ class ProjectEnvironmentStates extends i0.Table ), ); } - if (data.containsKey('domain_name')) { + if (data.containsKey('fly_volume_id')) { context.handle( - _domainNameMeta, - domainName.isAcceptableOrUnknown(data['domain_name']!, _domainNameMeta), + _flyVolumeIdMeta, + flyVolumeId.isAcceptableOrUnknown( + data['fly_volume_id']!, + _flyVolumeIdMeta, + ), ); } return context; @@ -2615,6 +2658,10 @@ class ProjectEnvironmentStates extends i0.Table i0.DriftSqlType.string, data['${effectivePrefix}project_environment_id'], )!, + domainName: attachedDatabase.typeMapping.read( + i0.DriftSqlType.string, + data['${effectivePrefix}domain_name'], + ), flyAppName: attachedDatabase.typeMapping.read( i0.DriftSqlType.string, data['${effectivePrefix}fly_app_name'], @@ -2623,9 +2670,9 @@ class ProjectEnvironmentStates extends i0.Table i0.DriftSqlType.string, data['${effectivePrefix}fly_volume_name'], ), - domainName: attachedDatabase.typeMapping.read( + flyVolumeId: attachedDatabase.typeMapping.read( i0.DriftSqlType.string, - data['${effectivePrefix}domain_name'], + data['${effectivePrefix}fly_volume_id'], ), ); } @@ -2650,32 +2697,45 @@ class ProjectEnvironmentState extends i0.DataClass /// The ID of the linked project environment. final String projectEnvironmentId; + /// The domain name of the project environment. + final String? domainName; + /// The name of the project environment's Fly app. final String? flyAppName; /// 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. final String? flyVolumeName; - /// The domain name of the project environment. - final String? domainName; + /// 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. + final String? flyVolumeId; const ProjectEnvironmentState({ required this.projectEnvironmentId, + this.domainName, this.flyAppName, this.flyVolumeName, - this.domainName, + this.flyVolumeId, }); @override Map toColumns(bool nullToAbsent) { final map = {}; map['project_environment_id'] = i0.Variable(projectEnvironmentId); + if (!nullToAbsent || domainName != null) { + map['domain_name'] = i0.Variable(domainName); + } if (!nullToAbsent || flyAppName != null) { map['fly_app_name'] = i0.Variable(flyAppName); } if (!nullToAbsent || flyVolumeName != null) { map['fly_volume_name'] = i0.Variable(flyVolumeName); } - if (!nullToAbsent || domainName != null) { - map['domain_name'] = i0.Variable(domainName); + if (!nullToAbsent || flyVolumeId != null) { + map['fly_volume_id'] = i0.Variable(flyVolumeId); } return map; } @@ -2683,6 +2743,10 @@ class ProjectEnvironmentState extends i0.DataClass i1.ProjectEnvironmentStatesCompanion toCompanion(bool nullToAbsent) { return i1.ProjectEnvironmentStatesCompanion( projectEnvironmentId: i0.Value(projectEnvironmentId), + domainName: + domainName == null && nullToAbsent + ? const i0.Value.absent() + : i0.Value(domainName), flyAppName: flyAppName == null && nullToAbsent ? const i0.Value.absent() @@ -2691,10 +2755,10 @@ class ProjectEnvironmentState extends i0.DataClass flyVolumeName == null && nullToAbsent ? const i0.Value.absent() : i0.Value(flyVolumeName), - domainName: - domainName == null && nullToAbsent + flyVolumeId: + flyVolumeId == null && nullToAbsent ? const i0.Value.absent() - : i0.Value(domainName), + : i0.Value(flyVolumeId), ); } @@ -2707,9 +2771,10 @@ class ProjectEnvironmentState extends i0.DataClass projectEnvironmentId: serializer.fromJson( json['project_environment_id'], ), + domainName: serializer.fromJson(json['domain_name']), flyAppName: serializer.fromJson(json['fly_app_name']), flyVolumeName: serializer.fromJson(json['fly_volume_name']), - domainName: serializer.fromJson(json['domain_name']), + flyVolumeId: serializer.fromJson(json['fly_volume_id']), ); } @override @@ -2717,23 +2782,26 @@ class ProjectEnvironmentState extends i0.DataClass serializer ??= i0.driftRuntimeOptions.defaultSerializer; return { 'project_environment_id': serializer.toJson(projectEnvironmentId), + 'domain_name': serializer.toJson(domainName), 'fly_app_name': serializer.toJson(flyAppName), 'fly_volume_name': serializer.toJson(flyVolumeName), - 'domain_name': serializer.toJson(domainName), + 'fly_volume_id': serializer.toJson(flyVolumeId), }; } i1.ProjectEnvironmentState copyWith({ String? projectEnvironmentId, + i0.Value domainName = const i0.Value.absent(), i0.Value flyAppName = const i0.Value.absent(), i0.Value flyVolumeName = const i0.Value.absent(), - i0.Value domainName = const i0.Value.absent(), + i0.Value flyVolumeId = const i0.Value.absent(), }) => i1.ProjectEnvironmentState( projectEnvironmentId: projectEnvironmentId ?? this.projectEnvironmentId, + domainName: domainName.present ? domainName.value : this.domainName, flyAppName: flyAppName.present ? flyAppName.value : this.flyAppName, flyVolumeName: flyVolumeName.present ? flyVolumeName.value : this.flyVolumeName, - domainName: domainName.present ? domainName.value : this.domainName, + flyVolumeId: flyVolumeId.present ? flyVolumeId.value : this.flyVolumeId, ); ProjectEnvironmentState copyWithCompanion( i1.ProjectEnvironmentStatesCompanion data, @@ -2743,14 +2811,16 @@ class ProjectEnvironmentState extends i0.DataClass data.projectEnvironmentId.present ? data.projectEnvironmentId.value : this.projectEnvironmentId, + domainName: + data.domainName.present ? data.domainName.value : this.domainName, flyAppName: data.flyAppName.present ? data.flyAppName.value : this.flyAppName, flyVolumeName: data.flyVolumeName.present ? data.flyVolumeName.value : this.flyVolumeName, - domainName: - data.domainName.present ? data.domainName.value : this.domainName, + flyVolumeId: + data.flyVolumeId.present ? data.flyVolumeId.value : this.flyVolumeId, ); } @@ -2758,70 +2828,84 @@ class ProjectEnvironmentState extends i0.DataClass String toString() { return (StringBuffer('ProjectEnvironmentState(') ..write('projectEnvironmentId: $projectEnvironmentId, ') + ..write('domainName: $domainName, ') ..write('flyAppName: $flyAppName, ') ..write('flyVolumeName: $flyVolumeName, ') - ..write('domainName: $domainName') + ..write('flyVolumeId: $flyVolumeId') ..write(')')) .toString(); } @override - int get hashCode => - Object.hash(projectEnvironmentId, flyAppName, flyVolumeName, domainName); + int get hashCode => Object.hash( + projectEnvironmentId, + domainName, + flyAppName, + flyVolumeName, + flyVolumeId, + ); @override bool operator ==(Object other) => identical(this, other) || (other is i1.ProjectEnvironmentState && other.projectEnvironmentId == this.projectEnvironmentId && + other.domainName == this.domainName && other.flyAppName == this.flyAppName && other.flyVolumeName == this.flyVolumeName && - other.domainName == this.domainName); + other.flyVolumeId == this.flyVolumeId); } class ProjectEnvironmentStatesCompanion extends i0.UpdateCompanion { final i0.Value projectEnvironmentId; + final i0.Value domainName; final i0.Value flyAppName; final i0.Value flyVolumeName; - final i0.Value domainName; + final i0.Value flyVolumeId; const ProjectEnvironmentStatesCompanion({ this.projectEnvironmentId = const i0.Value.absent(), + this.domainName = const i0.Value.absent(), this.flyAppName = const i0.Value.absent(), this.flyVolumeName = const i0.Value.absent(), - this.domainName = const i0.Value.absent(), + this.flyVolumeId = const i0.Value.absent(), }); ProjectEnvironmentStatesCompanion.insert({ required String projectEnvironmentId, + this.domainName = const i0.Value.absent(), this.flyAppName = const i0.Value.absent(), this.flyVolumeName = const i0.Value.absent(), - this.domainName = const i0.Value.absent(), + this.flyVolumeId = const i0.Value.absent(), }) : projectEnvironmentId = i0.Value(projectEnvironmentId); static i0.Insertable custom({ i0.Expression? projectEnvironmentId, + i0.Expression? domainName, i0.Expression? flyAppName, i0.Expression? flyVolumeName, - i0.Expression? domainName, + i0.Expression? flyVolumeId, }) { return i0.RawValuesInsertable({ if (projectEnvironmentId != null) 'project_environment_id': projectEnvironmentId, + if (domainName != null) 'domain_name': domainName, if (flyAppName != null) 'fly_app_name': flyAppName, if (flyVolumeName != null) 'fly_volume_name': flyVolumeName, - if (domainName != null) 'domain_name': domainName, + if (flyVolumeId != null) 'fly_volume_id': flyVolumeId, }); } i1.ProjectEnvironmentStatesCompanion copyWith({ i0.Value? projectEnvironmentId, + i0.Value? domainName, i0.Value? flyAppName, i0.Value? flyVolumeName, - i0.Value? domainName, + i0.Value? flyVolumeId, }) { return i1.ProjectEnvironmentStatesCompanion( projectEnvironmentId: projectEnvironmentId ?? this.projectEnvironmentId, + domainName: domainName ?? this.domainName, flyAppName: flyAppName ?? this.flyAppName, flyVolumeName: flyVolumeName ?? this.flyVolumeName, - domainName: domainName ?? this.domainName, + flyVolumeId: flyVolumeId ?? this.flyVolumeId, ); } @@ -2833,14 +2917,17 @@ class ProjectEnvironmentStatesCompanion projectEnvironmentId.value, ); } + if (domainName.present) { + map['domain_name'] = i0.Variable(domainName.value); + } if (flyAppName.present) { map['fly_app_name'] = i0.Variable(flyAppName.value); } if (flyVolumeName.present) { map['fly_volume_name'] = i0.Variable(flyVolumeName.value); } - if (domainName.present) { - map['domain_name'] = i0.Variable(domainName.value); + if (flyVolumeId.present) { + map['fly_volume_id'] = i0.Variable(flyVolumeId.value); } return map; } @@ -2849,9 +2936,10 @@ class ProjectEnvironmentStatesCompanion String toString() { return (StringBuffer('ProjectEnvironmentStatesCompanion(') ..write('projectEnvironmentId: $projectEnvironmentId, ') + ..write('domainName: $domainName, ') ..write('flyAppName: $flyAppName, ') ..write('flyVolumeName: $flyVolumeName, ') - ..write('domainName: $domainName') + ..write('flyVolumeId: $flyVolumeId') ..write(')')) .toString(); } @@ -3004,17 +3092,19 @@ class ProjectEnvironmentsDrift extends i3.ModularAccessor { i4.Future> upsertProjectEnvironmentState({ required String projectEnvironmentId, + String? domainName, String? flyAppName, String? flyVolumeName, - String? domainName, + String? flyVolumeId, }) { return customWriteReturning( - 'INSERT INTO project_environment_states (project_environment_id, fly_app_name, fly_volume_name, domain_name) VALUES (?1, ?2, ?3, ?4) ON CONFLICT (project_environment_id) DO UPDATE SET fly_app_name = coalesce(?2, fly_app_name), fly_volume_name = coalesce(?3, fly_volume_name), domain_name = coalesce(?4, domain_name) RETURNING *', + 'INSERT INTO project_environment_states (project_environment_id, domain_name, fly_app_name, fly_volume_name, fly_volume_id) VALUES (?1, ?2, ?3, ?4, ?5) ON CONFLICT (project_environment_id) DO UPDATE SET domain_name = coalesce(?2, domain_name), fly_app_name = coalesce(?3, fly_app_name), fly_volume_name = coalesce(?4, fly_volume_name), fly_volume_id = coalesce(?5, fly_volume_id) RETURNING *', variables: [ i0.Variable(projectEnvironmentId), + i0.Variable(domainName), i0.Variable(flyAppName), i0.Variable(flyVolumeName), - i0.Variable(domainName), + i0.Variable(flyVolumeId), ], updates: {projectEnvironmentStates}, ).then( diff --git a/services/celest_cloud_hub/lib/src/deploy/fly/fly_api.dart b/services/celest_cloud_hub/lib/src/deploy/fly/fly_api.dart index 4e50422f0..012e0eefd 100644 --- a/services/celest_cloud_hub/lib/src/deploy/fly/fly_api.dart +++ b/services/celest_cloud_hub/lib/src/deploy/fly/fly_api.dart @@ -10,8 +10,11 @@ import 'dart:convert'; import 'package:collection/collection.dart'; import 'package:http/http.dart' as http; +import 'package:logging/logging.dart'; import 'package:meta/meta.dart'; +final Logger _logger = Logger('FlyApi'); + /// Base class for exceptions specific to the Fly Machines API client. class FlyMachinesApiException implements Exception { // Can hold the parsed ErrorResponse or raw body @@ -122,7 +125,7 @@ class FlyMachinesApiClient { // Expecting no content (e.g., 204) if (responseBody.isNotEmpty) { // Unexpected content - print( + _logger.finest( 'Warning: Received unexpected response body for status $statusCode: $responseBody', ); } @@ -3843,7 +3846,7 @@ class FlyDuration { return FlyDuration(seconds: durationValue); } // If neither matches, return with null. Consider logging a warning. - print('Warning: Could not parse FlyDuration from JSON: $json'); + _logger.severe('Warning: Could not parse FlyDuration from JSON: $json'); return const FlyDuration(); } const FlyDuration({this.seconds}); diff --git a/services/celest_cloud_hub/lib/src/deploy/fly/fly_deployment_engine.dart b/services/celest_cloud_hub/lib/src/deploy/fly/fly_deployment_engine.dart index c9361ed43..68ae09a71 100644 --- a/services/celest_cloud_hub/lib/src/deploy/fly/fly_deployment_engine.dart +++ b/services/celest_cloud_hub/lib/src/deploy/fly/fly_deployment_engine.dart @@ -14,6 +14,7 @@ import 'package:celest_cloud/celest_cloud.dart' as pb show DeployProjectEnvironmentResponse, LifecycleState, ProjectAsset_Type; import 'package:celest_cloud/src/proto/google/rpc/status.pb.dart' as pb; +import 'package:celest_cloud_hub/src/context.dart'; import 'package:celest_cloud_hub/src/database/cloud_hub_database.dart'; import 'package:celest_cloud_hub/src/database/schema/project_environments.drift.dart'; import 'package:celest_cloud_hub/src/deploy/fly/fly_api.dart'; @@ -40,17 +41,13 @@ typedef ProjectAsset = final class FlyDeploymentEngine { FlyDeploymentEngine({ required this.db, - required String flyApiToken, required this.projectAst, required this.kernelAsset, required this.flutterAssetsBundle, required this.environment, - }) : flyApi = FlyMachinesApiClient(authToken: flyApiToken), - _flyApiToken = flyApiToken; + }); final CloudHubDatabase db; - final String _flyApiToken; - final FlyMachinesApiClient flyApi; final ProjectEnvironment environment; final ResolvedProject projectAst; @@ -60,7 +57,6 @@ final class FlyDeploymentEngine { static Future deployIsolated({ required String operationId, required DriftIsolate dbConnection, - required String flyApiToken, required ResolvedProject projectAst, required ProjectEnvironment environment, required ProjectAsset kernelAsset, @@ -89,7 +85,6 @@ final class FlyDeploymentEngine { final db = CloudHubDatabase(connection); final engine = FlyDeploymentEngine( db: db, - flyApiToken: flyApiToken, projectAst: projectAst, kernelAsset: kernelAsset, flutterAssetsBundle: flutterAssetsBundle, @@ -121,21 +116,16 @@ final class FlyDeploymentEngine { error: jsonEncode(error.toProto3Json(typeRegistry: typeRegistry)), ); } finally { - engine.close(); + context.httpClient.close(); await db.close(); } }); } - static const String _flyOrgSlug = 'celest-809'; static const FileSystem _fileSystem = LocalFileSystem(); static const ProcessManager _processManager = LocalProcessManager(); late final Logger _logger = Logger('FlyDeploymentEngine.${environment.id}'); - void close() { - flyApi.close(); - } - Future deploy() async { final pb.LifecycleState next, onFailure; final current = pb.LifecycleState.values.firstWhere( @@ -201,8 +191,8 @@ final class FlyDeploymentEngine { } } - String _generateFlyAppName() { - var projectId = projectAst.projectId.toLowerCase(); + static String generateFlyAppName(String projectId) { + projectId = projectId.toLowerCase(); // Only lowercase letters, numbers, and dashes are allowed. projectId = projectId.replaceAll(RegExp(r'[^a-z0-9]'), '-'); @@ -228,22 +218,28 @@ final class FlyDeploymentEngine { _logger.fine('Using Fly app: $flyAppName'); } else { // Create a new Fly app - flyAppName = _generateFlyAppName(); + flyAppName = generateFlyAppName(projectAst.projectId); _logger.fine('Creating Fly app: $flyAppName'); - await flyApi.apps.create( - request: CreateAppRequest(appName: flyAppName, orgSlug: _flyOrgSlug), + await context.fly.apps.create( + request: CreateAppRequest( + appName: flyAppName, + orgSlug: context.flyOrgSlug, + ), ); _logger.fine('Fly app created'); } final String flyVolumeName; + final String flyVolumeId; if (currentState?.flyVolumeName case final volumeName?) { flyVolumeName = volumeName; - _logger.fine('Using Fly volume: $flyVolumeName'); + final flyVolumes = await context.fly.volumes.list(appName: flyAppName); + _logger.fine('Using Fly volume: $flyVolumes'); + flyVolumeId = flyVolumes.single.id!; } else { _logger.fine('Creating Fly volume'); flyVolumeName = environment.id; - final volume = await flyApi.volumes.create( + final volume = await context.fly.volumes.create( appName: flyAppName, request: CreateVolumeRequest( name: flyVolumeName, @@ -252,12 +248,14 @@ final class FlyDeploymentEngine { ), ); _logger.fine('Created Fly volume: ${volume.toJson()}'); + flyVolumeId = volume.id!; } currentState = (await db.projectEnvironmentsDrift.upsertProjectEnvironmentState( projectEnvironmentId: environment.id, flyAppName: flyAppName, flyVolumeName: flyVolumeName, + flyVolumeId: flyVolumeId, domainName: '$flyAppName.fly.dev', )).first; @@ -351,7 +349,7 @@ final class FlyDeploymentEngine { ], workingDirectory: dir.path); }); - final app = await flyApi.apps.show(appName: flyAppName); + final app = await context.fly.apps.show(appName: flyAppName); _logger.fine('App successfully deployed: ${app.toJson()}'); return currentState; @@ -362,9 +360,9 @@ final class FlyDeploymentEngine { String? workingDirectory, }) async { final process = await _processManager.start( - ['flyctl', ...args, '--access-token', _flyApiToken], + ['flyctl', ...args], workingDirectory: workingDirectory, - environment: {'NO_COLOR': '1'}, + environment: {'NO_COLOR': '1', 'FLY_API_TOKEN': context.flyAuthToken}, ); final stdout = StringBuffer(); final stderr = StringBuffer(); diff --git a/services/celest_cloud_hub/lib/src/services/organizations_service.dart b/services/celest_cloud_hub/lib/src/services/organizations_service.dart index cd7087d31..d43e1d69c 100644 --- a/services/celest_cloud_hub/lib/src/services/organizations_service.dart +++ b/services/celest_cloud_hub/lib/src/services/organizations_service.dart @@ -25,9 +25,10 @@ import 'package:shelf/src/request.dart'; final class OrganizationsService extends OrganizationsServiceBase with ServiceMixin { - OrganizationsService(this._db, this.authorizer); + OrganizationsService(this.db, this.authorizer); - final CloudHubDatabase _db; + @override + final CloudHubDatabase db; @override final Authorizer authorizer; @@ -140,7 +141,7 @@ final class OrganizationsService extends OrganizationsServiceBase ) async { final principal = call.expectPrincipal(); final organization = - await _db.organizationsDrift + await db.organizationsDrift .getOrganization(id: request.organizationId) .getSingleOrNull(); if (organization != null) { @@ -160,10 +161,10 @@ final class OrganizationsService extends OrganizationsServiceBase resource: resource, ); - return _db.withoutForeignKeys(() async { + return db.withoutForeignKeys(() async { final organizationId = TypeId('org'); final organization = - (await _db.organizationsDrift.createOrganization( + (await db.organizationsDrift.createOrganization( id: organizationId.encoded, organizationId: request.organizationId, parentType: parent.uid.type, @@ -178,7 +179,7 @@ final class OrganizationsService extends OrganizationsServiceBase )).first; // Add the user as the owner of the organization - await _db.userMembershipsDrift.createUserMembership( + await db.userMembershipsDrift.createUserMembership( membershipId: typeId('mbr'), userId: principal.uid.id, parentType: 'Celest::Organization', @@ -189,7 +190,7 @@ final class OrganizationsService extends OrganizationsServiceBase final operationId = TypeId('op'); final operationResponse = organization.toProto().packIntoAny(); final operation = - (await _db.operationsDrift.createOperation( + (await db.operationsDrift.createOperation( id: operationId.encoded, ownerType: principal.uid.type, ownerId: principal.uid.id, @@ -214,7 +215,7 @@ final class OrganizationsService extends OrganizationsServiceBase _ => throw GrpcError.invalidArgument('Invalid name: "${request.name}"'), }; final organization = - await _db.organizationsDrift + await db.organizationsDrift .getOrganization(id: organizationId) .getSingleOrNull(); if (organization == null) { @@ -224,7 +225,7 @@ final class OrganizationsService extends OrganizationsServiceBase // Get membership of user in org final principal = call.expectPrincipal(); final membership = - await _db.userMembershipsDrift + await db.userMembershipsDrift .findUserMembership( userId: principal.uid.id, parentType: 'Celest::Organization', @@ -289,7 +290,7 @@ final class OrganizationsService extends OrganizationsServiceBase } final rows = - await _db.organizationsDrift + await db.organizationsDrift .listOrganizations( userId: principal.uid.id, showDeleted: showDeleted, @@ -336,7 +337,7 @@ final class OrganizationsService extends OrganizationsServiceBase _ => throw GrpcError.invalidArgument('Invalid name'), }; var organization = - await _db.organizationsDrift + await db.organizationsDrift .getOrganization(id: organizationId) .getSingleOrNull(); if (organization == null) { @@ -346,7 +347,7 @@ final class OrganizationsService extends OrganizationsServiceBase // Get membership of user in org final principal = call.expectPrincipal(); final membership = - await _db.userMembershipsDrift + await db.userMembershipsDrift .findUserMembership( userId: principal.uid.id, parentType: 'Celest::Organization', @@ -376,7 +377,7 @@ final class OrganizationsService extends OrganizationsServiceBase } organization = - (await _db.organizationsDrift.updateOrganization( + (await db.organizationsDrift.updateOrganization( id: organization.id, primaryRegion: mask( 'primary_region', @@ -395,7 +396,7 @@ final class OrganizationsService extends OrganizationsServiceBase final operationId = TypeId('op'); final operationResponse = organization.toProto().packIntoAny(); final operation = - (await _db.operationsDrift.createOperation( + (await db.operationsDrift.createOperation( id: operationId.encoded, ownerType: principal.uid.type, ownerId: principal.uid.id, diff --git a/services/celest_cloud_hub/lib/src/services/project_environments_service.dart b/services/celest_cloud_hub/lib/src/services/project_environments_service.dart index 81a834e58..f63c2a586 100644 --- a/services/celest_cloud_hub/lib/src/services/project_environments_service.dart +++ b/services/celest_cloud_hub/lib/src/services/project_environments_service.dart @@ -1,6 +1,5 @@ import 'dart:async'; import 'dart:convert'; -import 'dart:io'; import 'package:cedar/cedar.dart'; import 'package:celest/http.dart'; @@ -10,6 +9,7 @@ import 'package:celest_cloud/src/grpc.dart'; import 'package:celest_cloud_auth/src/authorization/authorizer.dart'; import 'package:celest_cloud_core/celest_cloud_core.dart'; import 'package:celest_cloud_hub/src/auth/auth_interceptor.dart'; +import 'package:celest_cloud_hub/src/context.dart'; import 'package:celest_cloud_hub/src/database/cloud_hub_database.dart'; import 'package:celest_cloud_hub/src/database/schema/project_environments.drift.dart' as dto; @@ -29,7 +29,7 @@ import 'package:shelf/src/request.dart'; final class ProjectEnvironmentsService extends ProjectEnvironmentsServiceBase with ServiceMixin { - ProjectEnvironmentsService(this._db, this.authorizer); + ProjectEnvironmentsService(this.db, this.authorizer); static const String apiId = 'celest.cloud.v1alpha1.ProjectEnvironments'; static const EntityUid apiUid = EntityUid.of('Celest::Api', apiId); @@ -122,7 +122,8 @@ final class ProjectEnvironmentsService extends ProjectEnvironmentsServiceBase @override final Logger logger = Logger(apiId); - final CloudHubDatabase _db; + @override + final CloudHubDatabase db; @override final Authorizer authorizer; @@ -139,14 +140,14 @@ final class ProjectEnvironmentsService extends ProjectEnvironmentsServiceBase ), }; final project = - await _db.projectsDrift.getProject(id: projectId).getSingleOrNull(); + await db.projectsDrift.getProject(id: projectId).getSingleOrNull(); if (project == null) { throw GrpcError.notFound('Project with ID $projectId not found.'); } logger.info('Checking for existing environment'); final existingEnvironment = - await _db.projectEnvironmentsDrift + await db.projectEnvironmentsDrift .lookupProjectEnvironment( projectId: project.id, projectEnvironmentId: request.projectEnvironmentId, @@ -158,11 +159,10 @@ final class ProjectEnvironmentsService extends ProjectEnvironmentsServiceBase ); } - final environmentId = TypeId('env'); final principal = call.expectPrincipal(); final membership = - await _db.userMembershipsDrift + await db.userMembershipsDrift .findUserMembership( userId: principal.uid.id, parentType: 'Celest::Project', @@ -171,7 +171,7 @@ final class ProjectEnvironmentsService extends ProjectEnvironmentsServiceBase .getSingleOrNull(); final resource = Entity( - uid: EntityUid.of('Celest::Project::Environment', environmentId.encoded), + uid: EntityUid.of('Celest::Project::Environment', 'new'), parents: [EntityUid.of('Celest::Project', project.id)], ); @@ -188,9 +188,10 @@ final class ProjectEnvironmentsService extends ProjectEnvironmentsServiceBase ); logger.info('Creating project environment'); - return _db.withoutForeignKeys(() async { + return db.withoutForeignKeys(() async { + final environmentId = TypeId('env'); final environment = - (await _db.projectEnvironmentsDrift.createProjectEnvironment( + (await db.projectEnvironmentsDrift.createProjectEnvironment( id: environmentId.encoded, parentType: 'Celest::Project', parentId: project.id, @@ -204,7 +205,7 @@ final class ProjectEnvironmentsService extends ProjectEnvironmentsServiceBase )).first; // Add the user as the owner of the project - await _db.userMembershipsDrift.createUserMembership( + await db.userMembershipsDrift.createUserMembership( membershipId: typeId('mbr'), userId: principal.uid.id, parentType: 'Celest::Project::Environment', @@ -212,9 +213,36 @@ final class ProjectEnvironmentsService extends ProjectEnvironmentsServiceBase role: 'owner', ); - final operationResponse = environment.toProto().packIntoAny(); + // Reserve the project name in Fly. + // + // This allows us to know the URL of the deployed app ahead of time so + // that apps can be concurrently built and deployed to Celest by the end + // user. + final flyAppName = FlyDeploymentEngine.generateFlyAppName( + project.projectId, + ); + try { + await context.fly.apps.create( + request: CreateAppRequest( + appName: flyAppName, + orgSlug: context.flyOrgSlug, + ), + ); + } on Object catch (e, st) { + logger.severe('Failed to create Fly app', e, st); + throw GrpcError.internal('Failed to create project'); + } + + final state = + (await db.projectEnvironmentsDrift.upsertProjectEnvironmentState( + projectEnvironmentId: environment.id, + flyAppName: flyAppName, + domainName: '$flyAppName.fly.dev', + )).first; + + final operationResponse = environment.toProto(state: state).packIntoAny(); final createOperation = - (await _db.operationsDrift.createOperation( + (await db.operationsDrift.createOperation( id: typeId('op'), ownerType: principal.uid.type, ownerId: principal.uid.id, @@ -246,13 +274,13 @@ final class ProjectEnvironmentsService extends ProjectEnvironmentsServiceBase }; final project = - await _db.projectsDrift.getProject(id: projectId).getSingleOrNull(); + await db.projectsDrift.getProject(id: projectId).getSingleOrNull(); if (project == null) { throw GrpcError.notFound('Project with ID $projectId not found.'); } final environment = - await _db.projectEnvironmentsDrift + await db.projectEnvironmentsDrift .lookupProjectEnvironment( projectId: project.id, projectEnvironmentId: environmentId, @@ -270,7 +298,7 @@ final class ProjectEnvironmentsService extends ProjectEnvironmentsServiceBase final principal = call.expectPrincipal(); final membership = - await _db.userMembershipsDrift + await db.userMembershipsDrift .findUserMembership( userId: principal.uid.id, parentType: 'Celest::Project::Environment', @@ -291,7 +319,7 @@ final class ProjectEnvironmentsService extends ProjectEnvironmentsServiceBase ); final projectEnvironmentState = - await _db.projectEnvironmentsDrift + await db.projectEnvironmentsDrift .getProjectEnvironmentState(projectEnvironmentId: environment.id) .getSingleOrNull(); @@ -318,7 +346,7 @@ final class ProjectEnvironmentsService extends ProjectEnvironmentsServiceBase // // Should be the last operation for this environment since no operations // are performed on deleted resources. - final query = _db.operationsDrift.findOperationsByResource( + final query = db.operationsDrift.findOperationsByResource( resourceType: 'Celest::Project::Environment', resourceId: environment.id, orderBy: (op) => OrderBy([OrderingTerm.desc(op.createTime)]), @@ -348,7 +376,7 @@ final class ProjectEnvironmentsService extends ProjectEnvironmentsServiceBase } final deletedEnvironment = - (await _db.projectEnvironmentsDrift.deleteProjectEnvironment( + (await db.projectEnvironmentsDrift.deleteProjectEnvironment( id: environment.id, )).first; @@ -357,7 +385,7 @@ final class ProjectEnvironmentsService extends ProjectEnvironmentsServiceBase .toProto(state: projectEnvironmentState) .packIntoAny(); final operation = - (await _db.operationsDrift.createOperation( + (await db.operationsDrift.createOperation( id: typeId('op'), ownerType: principal.uid.type, ownerId: principal.uid.id, @@ -379,11 +407,8 @@ final class ProjectEnvironmentsService extends ProjectEnvironmentsServiceBase ); return; } - final api = FlyMachinesApiClient( - authToken: Platform.environment['FLY_API_TOKEN']!, - ); try { - await api.apps.delete(appName: appName); + await context.fly.apps.delete(appName: appName); } on Object catch (e, st) { logger.severe('Failed to delete Fly environment', e, st); throw GrpcError.internal('Failed to delete project environment'); @@ -407,13 +432,13 @@ final class ProjectEnvironmentsService extends ProjectEnvironmentsServiceBase }; final project = - await _db.projectsDrift.getProject(id: projectId).getSingleOrNull(); + await db.projectsDrift.getProject(id: projectId).getSingleOrNull(); if (project == null) { throw GrpcError.notFound('Project with ID $projectId not found.'); } final environment = - await _db.projectEnvironmentsDrift + await db.projectEnvironmentsDrift .lookupProjectEnvironment( projectId: project.id, projectEnvironmentId: environmentId, @@ -427,7 +452,7 @@ final class ProjectEnvironmentsService extends ProjectEnvironmentsServiceBase final principal = call.expectPrincipal(); final membership = - await _db.userMembershipsDrift + await db.userMembershipsDrift .findUserMembership( userId: principal.uid.id, parentType: 'Celest::Project::Environment', @@ -458,7 +483,7 @@ final class ProjectEnvironmentsService extends ProjectEnvironmentsServiceBase final operationId = typeId('op'); final operation = - (await _db.operationsDrift.createOperation( + (await db.operationsDrift.createOperation( id: operationId, ownerType: principal.uid.type, ownerId: principal.uid.id, @@ -467,8 +492,7 @@ final class ProjectEnvironmentsService extends ProjectEnvironmentsServiceBase )).first; final deployment = FlyDeploymentEngine.deployIsolated( operationId: operationId, - dbConnection: await _db.serializableConnection(), - flyApiToken: Platform.environment['FLY_API_TOKEN']!, + dbConnection: await db.serializableConnection(), projectAst: ResolvedProject.fromProto( pb.ResolvedProject().unpackAny(request.resolvedProjectAst), ), @@ -519,13 +543,13 @@ final class ProjectEnvironmentsService extends ProjectEnvironmentsServiceBase }; final project = - await _db.projectsDrift.getProject(id: projectId).getSingleOrNull(); + await db.projectsDrift.getProject(id: projectId).getSingleOrNull(); if (project == null) { throw GrpcError.notFound('No project found with ID $projectId'); } final environment = - await _db.projectEnvironmentsDrift + await db.projectEnvironmentsDrift .lookupProjectEnvironment( projectId: project.id, projectEnvironmentId: environmentId, @@ -539,7 +563,7 @@ final class ProjectEnvironmentsService extends ProjectEnvironmentsServiceBase final principal = call.expectPrincipal(); final membership = - await _db.userMembershipsDrift + await db.userMembershipsDrift .findUserMembership( userId: principal.uid.id, parentType: 'Celest::Project::Environment', @@ -566,7 +590,7 @@ final class ProjectEnvironmentsService extends ProjectEnvironmentsServiceBase } final environmentState = - await _db.projectEnvironmentsDrift + await db.projectEnvironmentsDrift .getProjectEnvironmentState(projectEnvironmentId: environment.id) .getSingleOrNull(); @@ -587,14 +611,14 @@ final class ProjectEnvironmentsService extends ProjectEnvironmentsServiceBase }; final project = - await _db.projectsDrift.getProject(id: projectId).getSingleOrNull(); + await db.projectsDrift.getProject(id: projectId).getSingleOrNull(); if (project == null) { throw GrpcError.notFound('No project found with ID $projectId'); } final principal = call.expectPrincipal(); final membership = - await _db.userMembershipsDrift + await db.userMembershipsDrift .findUserMembership( userId: principal.uid.id, parentType: 'Celest::Project', @@ -645,7 +669,7 @@ final class ProjectEnvironmentsService extends ProjectEnvironmentsServiceBase } final rows = - await _db.projectEnvironmentsDrift + await db.projectEnvironmentsDrift .listProjectEnvironments( userId: principal.uid.id, parentId: project.id, @@ -699,13 +723,13 @@ final class ProjectEnvironmentsService extends ProjectEnvironmentsServiceBase }; final project = - await _db.projectsDrift.getProject(id: projectId).getSingleOrNull(); + await db.projectsDrift.getProject(id: projectId).getSingleOrNull(); if (project == null) { throw GrpcError.notFound('Project with ID $projectId not found.'); } var environment = - await _db.projectEnvironmentsDrift + await db.projectEnvironmentsDrift .lookupProjectEnvironment( projectId: project.id, projectEnvironmentId: environmentId, @@ -717,7 +741,7 @@ final class ProjectEnvironmentsService extends ProjectEnvironmentsServiceBase final principal = call.expectPrincipal(); final membership = - await _db.userMembershipsDrift + await db.userMembershipsDrift .findUserMembership( userId: principal.uid.id, parentType: 'Celest::Project::Environment', @@ -747,7 +771,7 @@ final class ProjectEnvironmentsService extends ProjectEnvironmentsServiceBase } environment = - (await _db.projectEnvironmentsDrift.updateProjectEnvironment( + (await db.projectEnvironmentsDrift.updateProjectEnvironment( id: environment.id, displayName: mask( 'display_name', @@ -765,7 +789,7 @@ final class ProjectEnvironmentsService extends ProjectEnvironmentsServiceBase final operationResponse = environment.toProto().packIntoAny(); final operation = - (await _db.operationsDrift.createOperation( + (await db.operationsDrift.createOperation( id: typeId('op'), ownerType: principal.uid.type, ownerId: principal.uid.id, diff --git a/services/celest_cloud_hub/lib/src/services/projects_service.dart b/services/celest_cloud_hub/lib/src/services/projects_service.dart index 56095edf4..ddde9b38a 100644 --- a/services/celest_cloud_hub/lib/src/services/projects_service.dart +++ b/services/celest_cloud_hub/lib/src/services/projects_service.dart @@ -24,9 +24,10 @@ import 'package:protobuf/protobuf.dart' as pb; import 'package:shelf/src/request.dart'; final class ProjectsService extends ProjectsServiceBase with ServiceMixin { - ProjectsService(this._db, this.authorizer); + ProjectsService(this.db, this.authorizer); - final CloudHubDatabase _db; + @override + final CloudHubDatabase db; @override final Authorizer authorizer; @@ -138,13 +139,14 @@ final class ProjectsService extends ProjectsServiceBase with ServiceMixin { CreateProjectRequest request, ) async { final principal = call.expectPrincipal(); - final organizationId = switch (request.parent.split('/')) { - ['organizations', final organizationId] => organizationId, - _ => throw GrpcError.invalidArgument('Invalid parent'), - }; + final parent = ResourceName.tryParse(request.parent); + if (parent == null || parent.type != ResourceType.organization) { + throw GrpcError.invalidArgument('Invalid parent'); + } + final organizationId = parent.id; final organization = - await _db.organizationsDrift + await db.organizationsDrift .getOrganization(id: organizationId) .getSingleOrNull(); if (organization == null) { @@ -152,7 +154,7 @@ final class ProjectsService extends ProjectsServiceBase with ServiceMixin { } final project = - await _db.projectsDrift + await db.projectsDrift .getProject(id: request.projectId) .getSingleOrNull(); if (project != null) { @@ -162,7 +164,7 @@ final class ProjectsService extends ProjectsServiceBase with ServiceMixin { } final membership = - await _db.userMembershipsDrift + await db.userMembershipsDrift .findUserMembership( userId: principal.uid.id, parentType: 'Celest::Organization', @@ -186,10 +188,10 @@ final class ProjectsService extends ProjectsServiceBase with ServiceMixin { resource: resource, ); - return _db.withoutForeignKeys(() async { + return db.withoutForeignKeys(() async { final projectId = TypeId('prj'); final project = - (await _db.projectsDrift.createProject( + (await db.projectsDrift.createProject( id: projectId.encoded, parentType: 'Celest::Organization', parentId: organization.id, @@ -206,7 +208,7 @@ final class ProjectsService extends ProjectsServiceBase with ServiceMixin { )).first; // Add the user as the owner of the project - await _db.userMembershipsDrift.createUserMembership( + await db.userMembershipsDrift.createUserMembership( membershipId: typeId('mbr'), userId: principal.uid.id, parentType: 'Celest::Project', @@ -217,7 +219,7 @@ final class ProjectsService extends ProjectsServiceBase with ServiceMixin { final operationId = TypeId('op'); final operationResponse = project.toProto().packIntoAny(); final operation = - (await _db.operationsDrift.createOperation( + (await db.operationsDrift.createOperation( id: operationId.encoded, ownerType: principal.uid.type, ownerId: principal.uid.id, @@ -243,14 +245,14 @@ final class ProjectsService extends ProjectsServiceBase with ServiceMixin { }; final project = - await _db.projectsDrift.getProject(id: projectId).getSingleOrNull(); + await db.projectsDrift.getProject(id: projectId).getSingleOrNull(); if (project == null) { throw GrpcError.notFound('No project found with ID $projectId'); } final principal = call.expectPrincipal(); final membership = - await _db.userMembershipsDrift + await db.userMembershipsDrift .findUserMembership( userId: principal.uid.id, parentType: 'Celest::Project', @@ -294,7 +296,7 @@ final class ProjectsService extends ProjectsServiceBase with ServiceMixin { }; final organization = - await _db.organizationsDrift + await db.organizationsDrift .getOrganization(id: organizationId) .getSingleOrNull(); if (organization == null) { @@ -302,7 +304,7 @@ final class ProjectsService extends ProjectsServiceBase with ServiceMixin { } final membership = - await _db.userMembershipsDrift + await db.userMembershipsDrift .findUserMembership( userId: principal.uid.id, parentType: 'Celest::Organization', @@ -349,7 +351,7 @@ final class ProjectsService extends ProjectsServiceBase with ServiceMixin { } final rows = - await _db.projectsDrift + await db.projectsDrift .listProjects( userId: principal.uid.id, parentId: organization.id, @@ -397,14 +399,14 @@ final class ProjectsService extends ProjectsServiceBase with ServiceMixin { }; var project = - await _db.projectsDrift.getProject(id: projectId).getSingleOrNull(); + await db.projectsDrift.getProject(id: projectId).getSingleOrNull(); if (project == null) { throw GrpcError.notFound('No project found with ID $projectId'); } final principal = call.expectPrincipal(); final membership = - await _db.userMembershipsDrift + await db.userMembershipsDrift .findUserMembership( userId: principal.uid.id, parentType: 'Celest::Project', @@ -434,7 +436,7 @@ final class ProjectsService extends ProjectsServiceBase with ServiceMixin { } project = - (await _db.projectsDrift.updateProject( + (await db.projectsDrift.updateProject( id: project.id, displayName: mask( 'display_name', @@ -453,7 +455,7 @@ final class ProjectsService extends ProjectsServiceBase with ServiceMixin { final operationId = TypeId('op'); final operationResponse = project.toProto().packIntoAny(); final operation = - (await _db.operationsDrift.createOperation( + (await db.operationsDrift.createOperation( id: operationId.encoded, ownerType: principal.uid.type, ownerId: principal.uid.id, @@ -478,7 +480,7 @@ final class ProjectsService extends ProjectsServiceBase with ServiceMixin { }; final project = - await _db.projectsDrift.getProject(id: projectId).getSingleOrNull(); + await db.projectsDrift.getProject(id: projectId).getSingleOrNull(); if (project == null) { if (request.allowMissing) { return Operation(); @@ -488,7 +490,7 @@ final class ProjectsService extends ProjectsServiceBase with ServiceMixin { final principal = call.expectPrincipal(); final membership = - await _db.userMembershipsDrift + await db.userMembershipsDrift .findUserMembership( userId: principal.uid.id, parentType: 'Celest::Project', @@ -513,7 +515,7 @@ final class ProjectsService extends ProjectsServiceBase with ServiceMixin { } final deletedProject = - (await _db.projectsDrift.deleteProject( + (await db.projectsDrift.deleteProject( id: project.id, state: 'DELETED', deleteTime: DateTime.timestamp(), @@ -523,7 +525,7 @@ final class ProjectsService extends ProjectsServiceBase with ServiceMixin { final operationId = TypeId('op'); final operationResponse = deletedProject.toProto().packIntoAny(); final operation = - (await _db.operationsDrift.createOperation( + (await db.operationsDrift.createOperation( id: operationId.encoded, ownerType: principal.uid.type, ownerId: principal.uid.id, @@ -548,14 +550,14 @@ final class ProjectsService extends ProjectsServiceBase with ServiceMixin { }; final project = - await _db.projectsDrift.getProject(id: projectId).getSingleOrNull(); + await db.projectsDrift.getProject(id: projectId).getSingleOrNull(); if (project == null) { throw GrpcError.notFound('No project found with ID $projectId'); } final principal = call.expectPrincipal(); final membership = - await _db.userMembershipsDrift + await db.userMembershipsDrift .findUserMembership( userId: principal.uid.id, parentType: 'Celest::Project', @@ -580,7 +582,7 @@ final class ProjectsService extends ProjectsServiceBase with ServiceMixin { } final undeletedProject = - (await _db.projectsDrift.undeleteProject( + (await db.projectsDrift.undeleteProject( id: project.id, state: 'ACTIVE', )).first; @@ -588,7 +590,7 @@ final class ProjectsService extends ProjectsServiceBase with ServiceMixin { final operationId = TypeId('op'); final operationResponse = undeletedProject.toProto().packIntoAny(); final operation = - (await _db.operationsDrift.createOperation( + (await db.operationsDrift.createOperation( id: operationId.encoded, ownerType: principal.uid.type, ownerId: principal.uid.id, diff --git a/services/celest_cloud_hub/lib/src/services/service_mixin.dart b/services/celest_cloud_hub/lib/src/services/service_mixin.dart index d75ee4293..88e2817ef 100644 --- a/services/celest_cloud_hub/lib/src/services/service_mixin.dart +++ b/services/celest_cloud_hub/lib/src/services/service_mixin.dart @@ -1,6 +1,7 @@ import 'package:cedar/cedar.dart'; import 'package:celest_cloud_auth/src/authorization/authorizer.dart'; import 'package:celest_cloud_auth/src/authorization/celest_action.dart' as auth; +import 'package:celest_cloud_hub/src/database/cloud_hub_database.dart'; import 'package:celest_core/celest_core.dart'; import 'package:logging/logging.dart'; @@ -17,6 +18,7 @@ extension type const ProjectEnvironmentAction._(EntityUid uid) } mixin ServiceMixin { + CloudHubDatabase get db; Authorizer get authorizer; Logger get logger; diff --git a/services/celest_cloud_hub/test/database/cloud_hub_database/generated/schema.dart b/services/celest_cloud_hub/test/database/cloud_hub_database/generated/schema.dart new file mode 100644 index 000000000..b2b7404b5 --- /dev/null +++ b/services/celest_cloud_hub/test/database/cloud_hub_database/generated/schema.dart @@ -0,0 +1,23 @@ +// dart format width=80 +// GENERATED CODE, DO NOT EDIT BY HAND. +// ignore_for_file: type=lint +import 'package:drift/drift.dart'; +import 'package:drift/internal/migrations.dart'; +import 'schema_v1.dart' as v1; +import 'schema_v2.dart' as v2; + +class GeneratedHelper implements SchemaInstantiationHelper { + @override + GeneratedDatabase databaseForVersion(QueryExecutor db, int version) { + switch (version) { + case 1: + return v1.DatabaseAtV1(db); + case 2: + return v2.DatabaseAtV2(db); + default: + throw MissingSchemaException(version, versions); + } + } + + static const versions = const [1, 2]; +} diff --git a/services/celest_cloud_hub/test/database/cloud_hub_database/generated/schema_v1.dart b/services/celest_cloud_hub/test/database/cloud_hub_database/generated/schema_v1.dart new file mode 100644 index 000000000..056ac2666 --- /dev/null +++ b/services/celest_cloud_hub/test/database/cloud_hub_database/generated/schema_v1.dart @@ -0,0 +1,10765 @@ +// dart format width=80 +// GENERATED CODE, DO NOT EDIT BY HAND. +// ignore_for_file: type=lint +import 'package:drift/drift.dart'; + +class CloudAuthUsers extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + CloudAuthUsers(this.attachedDatabase, [this._alias]); + late final GeneratedColumn userId = GeneratedColumn( + 'user_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); + late final GeneratedColumn givenName = GeneratedColumn( + 'given_name', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn familyName = GeneratedColumn( + 'family_name', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn timeZone = GeneratedColumn( + 'time_zone', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn languageCode = GeneratedColumn( + 'language_code', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn createTime = GeneratedColumn( + 'create_time', + aliasedName, + false, + type: DriftSqlType.double, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT (unixepoch(\'now\', \'subsec\'))', + defaultValue: const CustomExpression('unixepoch(\'now\', \'subsec\')'), + ); + late final GeneratedColumn updateTime = GeneratedColumn( + 'update_time', + aliasedName, + true, + type: DriftSqlType.double, + requiredDuringInsert: false, + $customConstraints: '', + ); + @override + List get $columns => [ + userId, + givenName, + familyName, + timeZone, + languageCode, + createTime, + updateTime, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'cloud_auth_users'; + @override + Set get $primaryKey => {userId}; + @override + CloudAuthUsersData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return CloudAuthUsersData( + userId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}user_id'], + )!, + givenName: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}given_name'], + ), + familyName: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}family_name'], + ), + timeZone: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}time_zone'], + ), + languageCode: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}language_code'], + ), + createTime: + attachedDatabase.typeMapping.read( + DriftSqlType.double, + data['${effectivePrefix}create_time'], + )!, + updateTime: attachedDatabase.typeMapping.read( + DriftSqlType.double, + data['${effectivePrefix}update_time'], + ), + ); + } + + @override + CloudAuthUsers createAlias(String alias) { + return CloudAuthUsers(attachedDatabase, alias); + } + + @override + bool get dontWriteConstraints => true; +} + +class CloudAuthUsersData extends DataClass + implements Insertable { + final String userId; + final String? givenName; + final String? familyName; + final String? timeZone; + final String? languageCode; + final double createTime; + final double? updateTime; + const CloudAuthUsersData({ + required this.userId, + this.givenName, + this.familyName, + this.timeZone, + this.languageCode, + required this.createTime, + this.updateTime, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['user_id'] = Variable(userId); + if (!nullToAbsent || givenName != null) { + map['given_name'] = Variable(givenName); + } + if (!nullToAbsent || familyName != null) { + map['family_name'] = Variable(familyName); + } + if (!nullToAbsent || timeZone != null) { + map['time_zone'] = Variable(timeZone); + } + if (!nullToAbsent || languageCode != null) { + map['language_code'] = Variable(languageCode); + } + map['create_time'] = Variable(createTime); + if (!nullToAbsent || updateTime != null) { + map['update_time'] = Variable(updateTime); + } + return map; + } + + CloudAuthUsersCompanion toCompanion(bool nullToAbsent) { + return CloudAuthUsersCompanion( + userId: Value(userId), + givenName: + givenName == null && nullToAbsent + ? const Value.absent() + : Value(givenName), + familyName: + familyName == null && nullToAbsent + ? const Value.absent() + : Value(familyName), + timeZone: + timeZone == null && nullToAbsent + ? const Value.absent() + : Value(timeZone), + languageCode: + languageCode == null && nullToAbsent + ? const Value.absent() + : Value(languageCode), + createTime: Value(createTime), + updateTime: + updateTime == null && nullToAbsent + ? const Value.absent() + : Value(updateTime), + ); + } + + factory CloudAuthUsersData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return CloudAuthUsersData( + userId: serializer.fromJson(json['userId']), + givenName: serializer.fromJson(json['givenName']), + familyName: serializer.fromJson(json['familyName']), + timeZone: serializer.fromJson(json['timeZone']), + languageCode: serializer.fromJson(json['languageCode']), + createTime: serializer.fromJson(json['createTime']), + updateTime: serializer.fromJson(json['updateTime']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'userId': serializer.toJson(userId), + 'givenName': serializer.toJson(givenName), + 'familyName': serializer.toJson(familyName), + 'timeZone': serializer.toJson(timeZone), + 'languageCode': serializer.toJson(languageCode), + 'createTime': serializer.toJson(createTime), + 'updateTime': serializer.toJson(updateTime), + }; + } + + CloudAuthUsersData copyWith({ + String? userId, + Value givenName = const Value.absent(), + Value familyName = const Value.absent(), + Value timeZone = const Value.absent(), + Value languageCode = const Value.absent(), + double? createTime, + Value updateTime = const Value.absent(), + }) => CloudAuthUsersData( + userId: userId ?? this.userId, + givenName: givenName.present ? givenName.value : this.givenName, + familyName: familyName.present ? familyName.value : this.familyName, + timeZone: timeZone.present ? timeZone.value : this.timeZone, + languageCode: languageCode.present ? languageCode.value : this.languageCode, + createTime: createTime ?? this.createTime, + updateTime: updateTime.present ? updateTime.value : this.updateTime, + ); + CloudAuthUsersData copyWithCompanion(CloudAuthUsersCompanion data) { + return CloudAuthUsersData( + userId: data.userId.present ? data.userId.value : this.userId, + givenName: data.givenName.present ? data.givenName.value : this.givenName, + familyName: + data.familyName.present ? data.familyName.value : this.familyName, + timeZone: data.timeZone.present ? data.timeZone.value : this.timeZone, + languageCode: + data.languageCode.present + ? data.languageCode.value + : this.languageCode, + createTime: + data.createTime.present ? data.createTime.value : this.createTime, + updateTime: + data.updateTime.present ? data.updateTime.value : this.updateTime, + ); + } + + @override + String toString() { + return (StringBuffer('CloudAuthUsersData(') + ..write('userId: $userId, ') + ..write('givenName: $givenName, ') + ..write('familyName: $familyName, ') + ..write('timeZone: $timeZone, ') + ..write('languageCode: $languageCode, ') + ..write('createTime: $createTime, ') + ..write('updateTime: $updateTime') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + userId, + givenName, + familyName, + timeZone, + languageCode, + createTime, + updateTime, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is CloudAuthUsersData && + other.userId == this.userId && + other.givenName == this.givenName && + other.familyName == this.familyName && + other.timeZone == this.timeZone && + other.languageCode == this.languageCode && + other.createTime == this.createTime && + other.updateTime == this.updateTime); +} + +class CloudAuthUsersCompanion extends UpdateCompanion { + final Value userId; + final Value givenName; + final Value familyName; + final Value timeZone; + final Value languageCode; + final Value createTime; + final Value updateTime; + final Value rowid; + const CloudAuthUsersCompanion({ + this.userId = const Value.absent(), + this.givenName = const Value.absent(), + this.familyName = const Value.absent(), + this.timeZone = const Value.absent(), + this.languageCode = const Value.absent(), + this.createTime = const Value.absent(), + this.updateTime = const Value.absent(), + this.rowid = const Value.absent(), + }); + CloudAuthUsersCompanion.insert({ + required String userId, + this.givenName = const Value.absent(), + this.familyName = const Value.absent(), + this.timeZone = const Value.absent(), + this.languageCode = const Value.absent(), + this.createTime = const Value.absent(), + this.updateTime = const Value.absent(), + this.rowid = const Value.absent(), + }) : userId = Value(userId); + static Insertable custom({ + Expression? userId, + Expression? givenName, + Expression? familyName, + Expression? timeZone, + Expression? languageCode, + Expression? createTime, + Expression? updateTime, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (userId != null) 'user_id': userId, + if (givenName != null) 'given_name': givenName, + if (familyName != null) 'family_name': familyName, + if (timeZone != null) 'time_zone': timeZone, + if (languageCode != null) 'language_code': languageCode, + if (createTime != null) 'create_time': createTime, + if (updateTime != null) 'update_time': updateTime, + if (rowid != null) 'rowid': rowid, + }); + } + + CloudAuthUsersCompanion copyWith({ + Value? userId, + Value? givenName, + Value? familyName, + Value? timeZone, + Value? languageCode, + Value? createTime, + Value? updateTime, + Value? rowid, + }) { + return CloudAuthUsersCompanion( + userId: userId ?? this.userId, + givenName: givenName ?? this.givenName, + familyName: familyName ?? this.familyName, + timeZone: timeZone ?? this.timeZone, + languageCode: languageCode ?? this.languageCode, + createTime: createTime ?? this.createTime, + updateTime: updateTime ?? this.updateTime, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (userId.present) { + map['user_id'] = Variable(userId.value); + } + if (givenName.present) { + map['given_name'] = Variable(givenName.value); + } + if (familyName.present) { + map['family_name'] = Variable(familyName.value); + } + if (timeZone.present) { + map['time_zone'] = Variable(timeZone.value); + } + if (languageCode.present) { + map['language_code'] = Variable(languageCode.value); + } + if (createTime.present) { + map['create_time'] = Variable(createTime.value); + } + if (updateTime.present) { + map['update_time'] = Variable(updateTime.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('CloudAuthUsersCompanion(') + ..write('userId: $userId, ') + ..write('givenName: $givenName, ') + ..write('familyName: $familyName, ') + ..write('timeZone: $timeZone, ') + ..write('languageCode: $languageCode, ') + ..write('createTime: $createTime, ') + ..write('updateTime: $updateTime, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +class CedarTypes extends Table with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + CedarTypes(this.attachedDatabase, [this._alias]); + late final GeneratedColumn fqn = GeneratedColumn( + 'fqn', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); + @override + List get $columns => [fqn]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'cedar_types'; + @override + Set get $primaryKey => {fqn}; + @override + CedarTypesData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return CedarTypesData( + fqn: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}fqn'], + )!, + ); + } + + @override + CedarTypes createAlias(String alias) { + return CedarTypes(attachedDatabase, alias); + } + + @override + bool get dontWriteConstraints => true; +} + +class CedarTypesData extends DataClass implements Insertable { + final String fqn; + const CedarTypesData({required this.fqn}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['fqn'] = Variable(fqn); + return map; + } + + CedarTypesCompanion toCompanion(bool nullToAbsent) { + return CedarTypesCompanion(fqn: Value(fqn)); + } + + factory CedarTypesData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return CedarTypesData(fqn: serializer.fromJson(json['fqn'])); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return {'fqn': serializer.toJson(fqn)}; + } + + CedarTypesData copyWith({String? fqn}) => + CedarTypesData(fqn: fqn ?? this.fqn); + CedarTypesData copyWithCompanion(CedarTypesCompanion data) { + return CedarTypesData(fqn: data.fqn.present ? data.fqn.value : this.fqn); + } + + @override + String toString() { + return (StringBuffer('CedarTypesData(') + ..write('fqn: $fqn') + ..write(')')) + .toString(); + } + + @override + int get hashCode => fqn.hashCode; + @override + bool operator ==(Object other) => + identical(this, other) || + (other is CedarTypesData && other.fqn == this.fqn); +} + +class CedarTypesCompanion extends UpdateCompanion { + final Value fqn; + final Value rowid; + const CedarTypesCompanion({ + this.fqn = const Value.absent(), + this.rowid = const Value.absent(), + }); + CedarTypesCompanion.insert({ + required String fqn, + this.rowid = const Value.absent(), + }) : fqn = Value(fqn); + static Insertable custom({ + Expression? fqn, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (fqn != null) 'fqn': fqn, + if (rowid != null) 'rowid': rowid, + }); + } + + CedarTypesCompanion copyWith({Value? fqn, Value? rowid}) { + return CedarTypesCompanion( + fqn: fqn ?? this.fqn, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (fqn.present) { + map['fqn'] = Variable(fqn.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('CedarTypesCompanion(') + ..write('fqn: $fqn, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +class CedarEntities extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + CedarEntities(this.attachedDatabase, [this._alias]); + late final GeneratedColumn entityType = GeneratedColumn( + 'entity_type', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL REFERENCES cedar_types(fqn)', + ); + late final GeneratedColumn entityId = GeneratedColumn( + 'entity_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn attributeJson = GeneratedColumn( + 'attribute_json', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT \'{}\'', + defaultValue: const CustomExpression('\'{}\''), + ); + late final GeneratedColumn entityJson = GeneratedColumn( + 'entity_json', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: + 'NOT NULL GENERATED ALWAYS AS (json_object(\'type\', entity_type, \'id\', entity_id)) VIRTUAL', + ); + @override + List get $columns => [ + entityType, + entityId, + attributeJson, + entityJson, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'cedar_entities'; + @override + Set get $primaryKey => {entityType, entityId}; + @override + CedarEntitiesData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return CedarEntitiesData( + entityType: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}entity_type'], + )!, + entityId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}entity_id'], + )!, + attributeJson: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}attribute_json'], + )!, + entityJson: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}entity_json'], + )!, + ); + } + + @override + CedarEntities createAlias(String alias) { + return CedarEntities(attachedDatabase, alias); + } + + @override + bool get withoutRowId => true; + @override + List get customConstraints => const [ + 'CONSTRAINT cedar_entities_pk PRIMARY KEY(entity_type, entity_id)ON CONFLICT IGNORE', + ]; + @override + bool get dontWriteConstraints => true; +} + +class CedarEntitiesData extends DataClass + implements Insertable { + final String entityType; + final String entityId; + final String attributeJson; + final String entityJson; + const CedarEntitiesData({ + required this.entityType, + required this.entityId, + required this.attributeJson, + required this.entityJson, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['entity_type'] = Variable(entityType); + map['entity_id'] = Variable(entityId); + map['attribute_json'] = Variable(attributeJson); + map['entity_json'] = Variable(entityJson); + return map; + } + + CedarEntitiesCompanion toCompanion(bool nullToAbsent) { + return CedarEntitiesCompanion( + entityType: Value(entityType), + entityId: Value(entityId), + attributeJson: Value(attributeJson), + entityJson: Value(entityJson), + ); + } + + factory CedarEntitiesData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return CedarEntitiesData( + entityType: serializer.fromJson(json['entityType']), + entityId: serializer.fromJson(json['entityId']), + attributeJson: serializer.fromJson(json['attributeJson']), + entityJson: serializer.fromJson(json['entityJson']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'entityType': serializer.toJson(entityType), + 'entityId': serializer.toJson(entityId), + 'attributeJson': serializer.toJson(attributeJson), + 'entityJson': serializer.toJson(entityJson), + }; + } + + CedarEntitiesData copyWith({ + String? entityType, + String? entityId, + String? attributeJson, + String? entityJson, + }) => CedarEntitiesData( + entityType: entityType ?? this.entityType, + entityId: entityId ?? this.entityId, + attributeJson: attributeJson ?? this.attributeJson, + entityJson: entityJson ?? this.entityJson, + ); + CedarEntitiesData copyWithCompanion(CedarEntitiesCompanion data) { + return CedarEntitiesData( + entityType: + data.entityType.present ? data.entityType.value : this.entityType, + entityId: data.entityId.present ? data.entityId.value : this.entityId, + attributeJson: + data.attributeJson.present + ? data.attributeJson.value + : this.attributeJson, + entityJson: + data.entityJson.present ? data.entityJson.value : this.entityJson, + ); + } + + @override + String toString() { + return (StringBuffer('CedarEntitiesData(') + ..write('entityType: $entityType, ') + ..write('entityId: $entityId, ') + ..write('attributeJson: $attributeJson, ') + ..write('entityJson: $entityJson') + ..write(')')) + .toString(); + } + + @override + int get hashCode => + Object.hash(entityType, entityId, attributeJson, entityJson); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is CedarEntitiesData && + other.entityType == this.entityType && + other.entityId == this.entityId && + other.attributeJson == this.attributeJson && + other.entityJson == this.entityJson); +} + +class CedarEntitiesCompanion extends UpdateCompanion { + final Value entityType; + final Value entityId; + final Value attributeJson; + final Value entityJson; + const CedarEntitiesCompanion({ + this.entityType = const Value.absent(), + this.entityId = const Value.absent(), + this.attributeJson = const Value.absent(), + this.entityJson = const Value.absent(), + }); + CedarEntitiesCompanion.insert({ + required String entityType, + required String entityId, + this.attributeJson = const Value.absent(), + required String entityJson, + }) : entityType = Value(entityType), + entityId = Value(entityId), + entityJson = Value(entityJson); + static Insertable custom({ + Expression? entityType, + Expression? entityId, + Expression? attributeJson, + Expression? entityJson, + }) { + return RawValuesInsertable({ + if (entityType != null) 'entity_type': entityType, + if (entityId != null) 'entity_id': entityId, + if (attributeJson != null) 'attribute_json': attributeJson, + if (entityJson != null) 'entity_json': entityJson, + }); + } + + CedarEntitiesCompanion copyWith({ + Value? entityType, + Value? entityId, + Value? attributeJson, + Value? entityJson, + }) { + return CedarEntitiesCompanion( + entityType: entityType ?? this.entityType, + entityId: entityId ?? this.entityId, + attributeJson: attributeJson ?? this.attributeJson, + entityJson: entityJson ?? this.entityJson, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (entityType.present) { + map['entity_type'] = Variable(entityType.value); + } + if (entityId.present) { + map['entity_id'] = Variable(entityId.value); + } + if (attributeJson.present) { + map['attribute_json'] = Variable(attributeJson.value); + } + if (entityJson.present) { + map['entity_json'] = Variable(entityJson.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('CedarEntitiesCompanion(') + ..write('entityType: $entityType, ') + ..write('entityId: $entityId, ') + ..write('attributeJson: $attributeJson, ') + ..write('entityJson: $entityJson') + ..write(')')) + .toString(); + } +} + +class CedarRelationships extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + CedarRelationships(this.attachedDatabase, [this._alias]); + late final GeneratedColumn entityType = GeneratedColumn( + 'entity_type', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn entityId = GeneratedColumn( + 'entity_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn entityJson = GeneratedColumn( + 'entity_json', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: + 'NOT NULL GENERATED ALWAYS AS (json_object(\'type\', entity_type, \'id\', entity_id)) VIRTUAL', + ); + late final GeneratedColumn parentType = GeneratedColumn( + 'parent_type', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn parentId = GeneratedColumn( + 'parent_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn parentJson = GeneratedColumn( + 'parent_json', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: + 'NOT NULL GENERATED ALWAYS AS (json_object(\'type\', parent_type, \'id\', parent_id)) VIRTUAL', + ); + @override + List get $columns => [ + entityType, + entityId, + entityJson, + parentType, + parentId, + parentJson, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'cedar_relationships'; + @override + Set get $primaryKey => { + entityType, + entityId, + parentType, + parentId, + }; + @override + CedarRelationshipsData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return CedarRelationshipsData( + entityType: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}entity_type'], + )!, + entityId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}entity_id'], + )!, + entityJson: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}entity_json'], + )!, + parentType: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}parent_type'], + )!, + parentId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}parent_id'], + )!, + parentJson: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}parent_json'], + )!, + ); + } + + @override + CedarRelationships createAlias(String alias) { + return CedarRelationships(attachedDatabase, alias); + } + + @override + bool get withoutRowId => true; + @override + List get customConstraints => const [ + 'CONSTRAINT cedar_relationships_pk PRIMARY KEY(entity_type, entity_id, parent_type, parent_id)ON CONFLICT IGNORE', + 'CONSTRAINT cedar_relationships_fk_entity FOREIGN KEY(entity_type, entity_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE CASCADE', + 'CONSTRAINT cedar_relationships_fk_parent FOREIGN KEY(parent_type, parent_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE CASCADE', + ]; + @override + bool get dontWriteConstraints => true; +} + +class CedarRelationshipsData extends DataClass + implements Insertable { + final String entityType; + final String entityId; + final String entityJson; + final String parentType; + final String parentId; + final String parentJson; + const CedarRelationshipsData({ + required this.entityType, + required this.entityId, + required this.entityJson, + required this.parentType, + required this.parentId, + required this.parentJson, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['entity_type'] = Variable(entityType); + map['entity_id'] = Variable(entityId); + map['entity_json'] = Variable(entityJson); + map['parent_type'] = Variable(parentType); + map['parent_id'] = Variable(parentId); + map['parent_json'] = Variable(parentJson); + return map; + } + + CedarRelationshipsCompanion toCompanion(bool nullToAbsent) { + return CedarRelationshipsCompanion( + entityType: Value(entityType), + entityId: Value(entityId), + entityJson: Value(entityJson), + parentType: Value(parentType), + parentId: Value(parentId), + parentJson: Value(parentJson), + ); + } + + factory CedarRelationshipsData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return CedarRelationshipsData( + entityType: serializer.fromJson(json['entityType']), + entityId: serializer.fromJson(json['entityId']), + entityJson: serializer.fromJson(json['entityJson']), + parentType: serializer.fromJson(json['parentType']), + parentId: serializer.fromJson(json['parentId']), + parentJson: serializer.fromJson(json['parentJson']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'entityType': serializer.toJson(entityType), + 'entityId': serializer.toJson(entityId), + 'entityJson': serializer.toJson(entityJson), + 'parentType': serializer.toJson(parentType), + 'parentId': serializer.toJson(parentId), + 'parentJson': serializer.toJson(parentJson), + }; + } + + CedarRelationshipsData copyWith({ + String? entityType, + String? entityId, + String? entityJson, + String? parentType, + String? parentId, + String? parentJson, + }) => CedarRelationshipsData( + entityType: entityType ?? this.entityType, + entityId: entityId ?? this.entityId, + entityJson: entityJson ?? this.entityJson, + parentType: parentType ?? this.parentType, + parentId: parentId ?? this.parentId, + parentJson: parentJson ?? this.parentJson, + ); + CedarRelationshipsData copyWithCompanion(CedarRelationshipsCompanion data) { + return CedarRelationshipsData( + entityType: + data.entityType.present ? data.entityType.value : this.entityType, + entityId: data.entityId.present ? data.entityId.value : this.entityId, + entityJson: + data.entityJson.present ? data.entityJson.value : this.entityJson, + parentType: + data.parentType.present ? data.parentType.value : this.parentType, + parentId: data.parentId.present ? data.parentId.value : this.parentId, + parentJson: + data.parentJson.present ? data.parentJson.value : this.parentJson, + ); + } + + @override + String toString() { + return (StringBuffer('CedarRelationshipsData(') + ..write('entityType: $entityType, ') + ..write('entityId: $entityId, ') + ..write('entityJson: $entityJson, ') + ..write('parentType: $parentType, ') + ..write('parentId: $parentId, ') + ..write('parentJson: $parentJson') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + entityType, + entityId, + entityJson, + parentType, + parentId, + parentJson, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is CedarRelationshipsData && + other.entityType == this.entityType && + other.entityId == this.entityId && + other.entityJson == this.entityJson && + other.parentType == this.parentType && + other.parentId == this.parentId && + other.parentJson == this.parentJson); +} + +class CedarRelationshipsCompanion + extends UpdateCompanion { + final Value entityType; + final Value entityId; + final Value entityJson; + final Value parentType; + final Value parentId; + final Value parentJson; + const CedarRelationshipsCompanion({ + this.entityType = const Value.absent(), + this.entityId = const Value.absent(), + this.entityJson = const Value.absent(), + this.parentType = const Value.absent(), + this.parentId = const Value.absent(), + this.parentJson = const Value.absent(), + }); + CedarRelationshipsCompanion.insert({ + required String entityType, + required String entityId, + required String entityJson, + required String parentType, + required String parentId, + required String parentJson, + }) : entityType = Value(entityType), + entityId = Value(entityId), + entityJson = Value(entityJson), + parentType = Value(parentType), + parentId = Value(parentId), + parentJson = Value(parentJson); + static Insertable custom({ + Expression? entityType, + Expression? entityId, + Expression? entityJson, + Expression? parentType, + Expression? parentId, + Expression? parentJson, + }) { + return RawValuesInsertable({ + if (entityType != null) 'entity_type': entityType, + if (entityId != null) 'entity_id': entityId, + if (entityJson != null) 'entity_json': entityJson, + if (parentType != null) 'parent_type': parentType, + if (parentId != null) 'parent_id': parentId, + if (parentJson != null) 'parent_json': parentJson, + }); + } + + CedarRelationshipsCompanion copyWith({ + Value? entityType, + Value? entityId, + Value? entityJson, + Value? parentType, + Value? parentId, + Value? parentJson, + }) { + return CedarRelationshipsCompanion( + entityType: entityType ?? this.entityType, + entityId: entityId ?? this.entityId, + entityJson: entityJson ?? this.entityJson, + parentType: parentType ?? this.parentType, + parentId: parentId ?? this.parentId, + parentJson: parentJson ?? this.parentJson, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (entityType.present) { + map['entity_type'] = Variable(entityType.value); + } + if (entityId.present) { + map['entity_id'] = Variable(entityId.value); + } + if (entityJson.present) { + map['entity_json'] = Variable(entityJson.value); + } + if (parentType.present) { + map['parent_type'] = Variable(parentType.value); + } + if (parentId.present) { + map['parent_id'] = Variable(parentId.value); + } + if (parentJson.present) { + map['parent_json'] = Variable(parentJson.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('CedarRelationshipsCompanion(') + ..write('entityType: $entityType, ') + ..write('entityId: $entityId, ') + ..write('entityJson: $entityJson, ') + ..write('parentType: $parentType, ') + ..write('parentId: $parentId, ') + ..write('parentJson: $parentJson') + ..write(')')) + .toString(); + } +} + +class CloudAuthUserEmails extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + CloudAuthUserEmails(this.attachedDatabase, [this._alias]); + late final GeneratedColumn userId = GeneratedColumn( + 'user_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn email = GeneratedColumn( + 'email', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn isVerified = GeneratedColumn( + 'is_verified', + aliasedName, + false, + type: DriftSqlType.bool, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT FALSE', + defaultValue: const CustomExpression('FALSE'), + ); + late final GeneratedColumn isPrimary = GeneratedColumn( + 'is_primary', + aliasedName, + false, + type: DriftSqlType.bool, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT FALSE', + defaultValue: const CustomExpression('FALSE'), + ); + @override + List get $columns => [userId, email, isVerified, isPrimary]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'cloud_auth_user_emails'; + @override + Set get $primaryKey => {userId, email}; + @override + CloudAuthUserEmailsData map( + Map data, { + String? tablePrefix, + }) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return CloudAuthUserEmailsData( + userId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}user_id'], + )!, + email: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}email'], + )!, + isVerified: + attachedDatabase.typeMapping.read( + DriftSqlType.bool, + data['${effectivePrefix}is_verified'], + )!, + isPrimary: + attachedDatabase.typeMapping.read( + DriftSqlType.bool, + data['${effectivePrefix}is_primary'], + )!, + ); + } + + @override + CloudAuthUserEmails createAlias(String alias) { + return CloudAuthUserEmails(attachedDatabase, alias); + } + + @override + bool get withoutRowId => true; + @override + List get customConstraints => const [ + 'CONSTRAINT cloud_auth_user_emails_pk PRIMARY KEY(user_id, email)', + 'CONSTRAINT cloud_auth_user_emails_user_fk FOREIGN KEY(user_id)REFERENCES cloud_auth_users(user_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED', + ]; + @override + bool get dontWriteConstraints => true; +} + +class CloudAuthUserEmailsData extends DataClass + implements Insertable { + final String userId; + final String email; + final bool isVerified; + final bool isPrimary; + const CloudAuthUserEmailsData({ + required this.userId, + required this.email, + required this.isVerified, + required this.isPrimary, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['user_id'] = Variable(userId); + map['email'] = Variable(email); + map['is_verified'] = Variable(isVerified); + map['is_primary'] = Variable(isPrimary); + return map; + } + + CloudAuthUserEmailsCompanion toCompanion(bool nullToAbsent) { + return CloudAuthUserEmailsCompanion( + userId: Value(userId), + email: Value(email), + isVerified: Value(isVerified), + isPrimary: Value(isPrimary), + ); + } + + factory CloudAuthUserEmailsData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return CloudAuthUserEmailsData( + userId: serializer.fromJson(json['userId']), + email: serializer.fromJson(json['email']), + isVerified: serializer.fromJson(json['isVerified']), + isPrimary: serializer.fromJson(json['isPrimary']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'userId': serializer.toJson(userId), + 'email': serializer.toJson(email), + 'isVerified': serializer.toJson(isVerified), + 'isPrimary': serializer.toJson(isPrimary), + }; + } + + CloudAuthUserEmailsData copyWith({ + String? userId, + String? email, + bool? isVerified, + bool? isPrimary, + }) => CloudAuthUserEmailsData( + userId: userId ?? this.userId, + email: email ?? this.email, + isVerified: isVerified ?? this.isVerified, + isPrimary: isPrimary ?? this.isPrimary, + ); + CloudAuthUserEmailsData copyWithCompanion(CloudAuthUserEmailsCompanion data) { + return CloudAuthUserEmailsData( + userId: data.userId.present ? data.userId.value : this.userId, + email: data.email.present ? data.email.value : this.email, + isVerified: + data.isVerified.present ? data.isVerified.value : this.isVerified, + isPrimary: data.isPrimary.present ? data.isPrimary.value : this.isPrimary, + ); + } + + @override + String toString() { + return (StringBuffer('CloudAuthUserEmailsData(') + ..write('userId: $userId, ') + ..write('email: $email, ') + ..write('isVerified: $isVerified, ') + ..write('isPrimary: $isPrimary') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(userId, email, isVerified, isPrimary); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is CloudAuthUserEmailsData && + other.userId == this.userId && + other.email == this.email && + other.isVerified == this.isVerified && + other.isPrimary == this.isPrimary); +} + +class CloudAuthUserEmailsCompanion + extends UpdateCompanion { + final Value userId; + final Value email; + final Value isVerified; + final Value isPrimary; + const CloudAuthUserEmailsCompanion({ + this.userId = const Value.absent(), + this.email = const Value.absent(), + this.isVerified = const Value.absent(), + this.isPrimary = const Value.absent(), + }); + CloudAuthUserEmailsCompanion.insert({ + required String userId, + required String email, + this.isVerified = const Value.absent(), + this.isPrimary = const Value.absent(), + }) : userId = Value(userId), + email = Value(email); + static Insertable custom({ + Expression? userId, + Expression? email, + Expression? isVerified, + Expression? isPrimary, + }) { + return RawValuesInsertable({ + if (userId != null) 'user_id': userId, + if (email != null) 'email': email, + if (isVerified != null) 'is_verified': isVerified, + if (isPrimary != null) 'is_primary': isPrimary, + }); + } + + CloudAuthUserEmailsCompanion copyWith({ + Value? userId, + Value? email, + Value? isVerified, + Value? isPrimary, + }) { + return CloudAuthUserEmailsCompanion( + userId: userId ?? this.userId, + email: email ?? this.email, + isVerified: isVerified ?? this.isVerified, + isPrimary: isPrimary ?? this.isPrimary, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (userId.present) { + map['user_id'] = Variable(userId.value); + } + if (email.present) { + map['email'] = Variable(email.value); + } + if (isVerified.present) { + map['is_verified'] = Variable(isVerified.value); + } + if (isPrimary.present) { + map['is_primary'] = Variable(isPrimary.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('CloudAuthUserEmailsCompanion(') + ..write('userId: $userId, ') + ..write('email: $email, ') + ..write('isVerified: $isVerified, ') + ..write('isPrimary: $isPrimary') + ..write(')')) + .toString(); + } +} + +class CloudAuthUserPhoneNumbers extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + CloudAuthUserPhoneNumbers(this.attachedDatabase, [this._alias]); + late final GeneratedColumn userId = GeneratedColumn( + 'user_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn phoneNumber = GeneratedColumn( + 'phone_number', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn isVerified = GeneratedColumn( + 'is_verified', + aliasedName, + false, + type: DriftSqlType.bool, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT FALSE', + defaultValue: const CustomExpression('FALSE'), + ); + late final GeneratedColumn isPrimary = GeneratedColumn( + 'is_primary', + aliasedName, + false, + type: DriftSqlType.bool, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT FALSE', + defaultValue: const CustomExpression('FALSE'), + ); + @override + List get $columns => [ + userId, + phoneNumber, + isVerified, + isPrimary, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'cloud_auth_user_phone_numbers'; + @override + Set get $primaryKey => {userId, phoneNumber}; + @override + CloudAuthUserPhoneNumbersData map( + Map data, { + String? tablePrefix, + }) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return CloudAuthUserPhoneNumbersData( + userId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}user_id'], + )!, + phoneNumber: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}phone_number'], + )!, + isVerified: + attachedDatabase.typeMapping.read( + DriftSqlType.bool, + data['${effectivePrefix}is_verified'], + )!, + isPrimary: + attachedDatabase.typeMapping.read( + DriftSqlType.bool, + data['${effectivePrefix}is_primary'], + )!, + ); + } + + @override + CloudAuthUserPhoneNumbers createAlias(String alias) { + return CloudAuthUserPhoneNumbers(attachedDatabase, alias); + } + + @override + bool get withoutRowId => true; + @override + List get customConstraints => const [ + 'CONSTRAINT cloud_auth_user_phone_numbers_pk PRIMARY KEY(user_id, phone_number)', + 'CONSTRAINT cloud_auth_user_phone_numbers_user_fk FOREIGN KEY(user_id)REFERENCES cloud_auth_users(user_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED', + ]; + @override + bool get dontWriteConstraints => true; +} + +class CloudAuthUserPhoneNumbersData extends DataClass + implements Insertable { + final String userId; + final String phoneNumber; + final bool isVerified; + final bool isPrimary; + const CloudAuthUserPhoneNumbersData({ + required this.userId, + required this.phoneNumber, + required this.isVerified, + required this.isPrimary, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['user_id'] = Variable(userId); + map['phone_number'] = Variable(phoneNumber); + map['is_verified'] = Variable(isVerified); + map['is_primary'] = Variable(isPrimary); + return map; + } + + CloudAuthUserPhoneNumbersCompanion toCompanion(bool nullToAbsent) { + return CloudAuthUserPhoneNumbersCompanion( + userId: Value(userId), + phoneNumber: Value(phoneNumber), + isVerified: Value(isVerified), + isPrimary: Value(isPrimary), + ); + } + + factory CloudAuthUserPhoneNumbersData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return CloudAuthUserPhoneNumbersData( + userId: serializer.fromJson(json['userId']), + phoneNumber: serializer.fromJson(json['phoneNumber']), + isVerified: serializer.fromJson(json['isVerified']), + isPrimary: serializer.fromJson(json['isPrimary']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'userId': serializer.toJson(userId), + 'phoneNumber': serializer.toJson(phoneNumber), + 'isVerified': serializer.toJson(isVerified), + 'isPrimary': serializer.toJson(isPrimary), + }; + } + + CloudAuthUserPhoneNumbersData copyWith({ + String? userId, + String? phoneNumber, + bool? isVerified, + bool? isPrimary, + }) => CloudAuthUserPhoneNumbersData( + userId: userId ?? this.userId, + phoneNumber: phoneNumber ?? this.phoneNumber, + isVerified: isVerified ?? this.isVerified, + isPrimary: isPrimary ?? this.isPrimary, + ); + CloudAuthUserPhoneNumbersData copyWithCompanion( + CloudAuthUserPhoneNumbersCompanion data, + ) { + return CloudAuthUserPhoneNumbersData( + userId: data.userId.present ? data.userId.value : this.userId, + phoneNumber: + data.phoneNumber.present ? data.phoneNumber.value : this.phoneNumber, + isVerified: + data.isVerified.present ? data.isVerified.value : this.isVerified, + isPrimary: data.isPrimary.present ? data.isPrimary.value : this.isPrimary, + ); + } + + @override + String toString() { + return (StringBuffer('CloudAuthUserPhoneNumbersData(') + ..write('userId: $userId, ') + ..write('phoneNumber: $phoneNumber, ') + ..write('isVerified: $isVerified, ') + ..write('isPrimary: $isPrimary') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(userId, phoneNumber, isVerified, isPrimary); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is CloudAuthUserPhoneNumbersData && + other.userId == this.userId && + other.phoneNumber == this.phoneNumber && + other.isVerified == this.isVerified && + other.isPrimary == this.isPrimary); +} + +class CloudAuthUserPhoneNumbersCompanion + extends UpdateCompanion { + final Value userId; + final Value phoneNumber; + final Value isVerified; + final Value isPrimary; + const CloudAuthUserPhoneNumbersCompanion({ + this.userId = const Value.absent(), + this.phoneNumber = const Value.absent(), + this.isVerified = const Value.absent(), + this.isPrimary = const Value.absent(), + }); + CloudAuthUserPhoneNumbersCompanion.insert({ + required String userId, + required String phoneNumber, + this.isVerified = const Value.absent(), + this.isPrimary = const Value.absent(), + }) : userId = Value(userId), + phoneNumber = Value(phoneNumber); + static Insertable custom({ + Expression? userId, + Expression? phoneNumber, + Expression? isVerified, + Expression? isPrimary, + }) { + return RawValuesInsertable({ + if (userId != null) 'user_id': userId, + if (phoneNumber != null) 'phone_number': phoneNumber, + if (isVerified != null) 'is_verified': isVerified, + if (isPrimary != null) 'is_primary': isPrimary, + }); + } + + CloudAuthUserPhoneNumbersCompanion copyWith({ + Value? userId, + Value? phoneNumber, + Value? isVerified, + Value? isPrimary, + }) { + return CloudAuthUserPhoneNumbersCompanion( + userId: userId ?? this.userId, + phoneNumber: phoneNumber ?? this.phoneNumber, + isVerified: isVerified ?? this.isVerified, + isPrimary: isPrimary ?? this.isPrimary, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (userId.present) { + map['user_id'] = Variable(userId.value); + } + if (phoneNumber.present) { + map['phone_number'] = Variable(phoneNumber.value); + } + if (isVerified.present) { + map['is_verified'] = Variable(isVerified.value); + } + if (isPrimary.present) { + map['is_primary'] = Variable(isPrimary.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('CloudAuthUserPhoneNumbersCompanion(') + ..write('userId: $userId, ') + ..write('phoneNumber: $phoneNumber, ') + ..write('isVerified: $isVerified, ') + ..write('isPrimary: $isPrimary') + ..write(')')) + .toString(); + } +} + +class CloudAuthProjects extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + CloudAuthProjects(this.attachedDatabase, [this._alias]); + late final GeneratedColumn projectId = GeneratedColumn( + 'project_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); + late final GeneratedColumn version = GeneratedColumn( + 'version', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn resolvedAst = + GeneratedColumn( + 'resolved_ast', + aliasedName, + false, + type: DriftSqlType.blob, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn etag = GeneratedColumn( + 'etag', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + @override + List get $columns => [projectId, version, resolvedAst, etag]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'cloud_auth_projects'; + @override + Set get $primaryKey => {projectId}; + @override + CloudAuthProjectsData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return CloudAuthProjectsData( + projectId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}project_id'], + )!, + version: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}version'], + )!, + resolvedAst: + attachedDatabase.typeMapping.read( + DriftSqlType.blob, + data['${effectivePrefix}resolved_ast'], + )!, + etag: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}etag'], + )!, + ); + } + + @override + CloudAuthProjects createAlias(String alias) { + return CloudAuthProjects(attachedDatabase, alias); + } + + @override + bool get dontWriteConstraints => true; +} + +class CloudAuthProjectsData extends DataClass + implements Insertable { + final String projectId; + final String version; + final Uint8List resolvedAst; + final String etag; + const CloudAuthProjectsData({ + required this.projectId, + required this.version, + required this.resolvedAst, + required this.etag, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['project_id'] = Variable(projectId); + map['version'] = Variable(version); + map['resolved_ast'] = Variable(resolvedAst); + map['etag'] = Variable(etag); + return map; + } + + CloudAuthProjectsCompanion toCompanion(bool nullToAbsent) { + return CloudAuthProjectsCompanion( + projectId: Value(projectId), + version: Value(version), + resolvedAst: Value(resolvedAst), + etag: Value(etag), + ); + } + + factory CloudAuthProjectsData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return CloudAuthProjectsData( + projectId: serializer.fromJson(json['projectId']), + version: serializer.fromJson(json['version']), + resolvedAst: serializer.fromJson(json['resolvedAst']), + etag: serializer.fromJson(json['etag']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'projectId': serializer.toJson(projectId), + 'version': serializer.toJson(version), + 'resolvedAst': serializer.toJson(resolvedAst), + 'etag': serializer.toJson(etag), + }; + } + + CloudAuthProjectsData copyWith({ + String? projectId, + String? version, + Uint8List? resolvedAst, + String? etag, + }) => CloudAuthProjectsData( + projectId: projectId ?? this.projectId, + version: version ?? this.version, + resolvedAst: resolvedAst ?? this.resolvedAst, + etag: etag ?? this.etag, + ); + CloudAuthProjectsData copyWithCompanion(CloudAuthProjectsCompanion data) { + return CloudAuthProjectsData( + projectId: data.projectId.present ? data.projectId.value : this.projectId, + version: data.version.present ? data.version.value : this.version, + resolvedAst: + data.resolvedAst.present ? data.resolvedAst.value : this.resolvedAst, + etag: data.etag.present ? data.etag.value : this.etag, + ); + } + + @override + String toString() { + return (StringBuffer('CloudAuthProjectsData(') + ..write('projectId: $projectId, ') + ..write('version: $version, ') + ..write('resolvedAst: $resolvedAst, ') + ..write('etag: $etag') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + projectId, + version, + $driftBlobEquality.hash(resolvedAst), + etag, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is CloudAuthProjectsData && + other.projectId == this.projectId && + other.version == this.version && + $driftBlobEquality.equals(other.resolvedAst, this.resolvedAst) && + other.etag == this.etag); +} + +class CloudAuthProjectsCompanion + extends UpdateCompanion { + final Value projectId; + final Value version; + final Value resolvedAst; + final Value etag; + final Value rowid; + const CloudAuthProjectsCompanion({ + this.projectId = const Value.absent(), + this.version = const Value.absent(), + this.resolvedAst = const Value.absent(), + this.etag = const Value.absent(), + this.rowid = const Value.absent(), + }); + CloudAuthProjectsCompanion.insert({ + required String projectId, + required String version, + required Uint8List resolvedAst, + required String etag, + this.rowid = const Value.absent(), + }) : projectId = Value(projectId), + version = Value(version), + resolvedAst = Value(resolvedAst), + etag = Value(etag); + static Insertable custom({ + Expression? projectId, + Expression? version, + Expression? resolvedAst, + Expression? etag, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (projectId != null) 'project_id': projectId, + if (version != null) 'version': version, + if (resolvedAst != null) 'resolved_ast': resolvedAst, + if (etag != null) 'etag': etag, + if (rowid != null) 'rowid': rowid, + }); + } + + CloudAuthProjectsCompanion copyWith({ + Value? projectId, + Value? version, + Value? resolvedAst, + Value? etag, + Value? rowid, + }) { + return CloudAuthProjectsCompanion( + projectId: projectId ?? this.projectId, + version: version ?? this.version, + resolvedAst: resolvedAst ?? this.resolvedAst, + etag: etag ?? this.etag, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (projectId.present) { + map['project_id'] = Variable(projectId.value); + } + if (version.present) { + map['version'] = Variable(version.value); + } + if (resolvedAst.present) { + map['resolved_ast'] = Variable(resolvedAst.value); + } + if (etag.present) { + map['etag'] = Variable(etag.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('CloudAuthProjectsCompanion(') + ..write('projectId: $projectId, ') + ..write('version: $version, ') + ..write('resolvedAst: $resolvedAst, ') + ..write('etag: $etag, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +class CloudAuthApis extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + CloudAuthApis(this.attachedDatabase, [this._alias]); + late final GeneratedColumn apiId = GeneratedColumn( + 'api_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); + late final GeneratedColumn projectId = GeneratedColumn( + 'project_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn resolvedAst = + GeneratedColumn( + 'resolved_ast', + aliasedName, + false, + type: DriftSqlType.blob, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn etag = GeneratedColumn( + 'etag', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + @override + List get $columns => [apiId, projectId, resolvedAst, etag]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'cloud_auth_apis'; + @override + Set get $primaryKey => {apiId}; + @override + CloudAuthApisData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return CloudAuthApisData( + apiId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}api_id'], + )!, + projectId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}project_id'], + )!, + resolvedAst: + attachedDatabase.typeMapping.read( + DriftSqlType.blob, + data['${effectivePrefix}resolved_ast'], + )!, + etag: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}etag'], + )!, + ); + } + + @override + CloudAuthApis createAlias(String alias) { + return CloudAuthApis(attachedDatabase, alias); + } + + @override + List get customConstraints => const [ + 'CONSTRAINT cloud_auth_apis_project_fk FOREIGN KEY(project_id)REFERENCES cloud_auth_projects(project_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED', + ]; + @override + bool get dontWriteConstraints => true; +} + +class CloudAuthApisData extends DataClass + implements Insertable { + final String apiId; + final String projectId; + final Uint8List resolvedAst; + final String etag; + const CloudAuthApisData({ + required this.apiId, + required this.projectId, + required this.resolvedAst, + required this.etag, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['api_id'] = Variable(apiId); + map['project_id'] = Variable(projectId); + map['resolved_ast'] = Variable(resolvedAst); + map['etag'] = Variable(etag); + return map; + } + + CloudAuthApisCompanion toCompanion(bool nullToAbsent) { + return CloudAuthApisCompanion( + apiId: Value(apiId), + projectId: Value(projectId), + resolvedAst: Value(resolvedAst), + etag: Value(etag), + ); + } + + factory CloudAuthApisData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return CloudAuthApisData( + apiId: serializer.fromJson(json['apiId']), + projectId: serializer.fromJson(json['projectId']), + resolvedAst: serializer.fromJson(json['resolvedAst']), + etag: serializer.fromJson(json['etag']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'apiId': serializer.toJson(apiId), + 'projectId': serializer.toJson(projectId), + 'resolvedAst': serializer.toJson(resolvedAst), + 'etag': serializer.toJson(etag), + }; + } + + CloudAuthApisData copyWith({ + String? apiId, + String? projectId, + Uint8List? resolvedAst, + String? etag, + }) => CloudAuthApisData( + apiId: apiId ?? this.apiId, + projectId: projectId ?? this.projectId, + resolvedAst: resolvedAst ?? this.resolvedAst, + etag: etag ?? this.etag, + ); + CloudAuthApisData copyWithCompanion(CloudAuthApisCompanion data) { + return CloudAuthApisData( + apiId: data.apiId.present ? data.apiId.value : this.apiId, + projectId: data.projectId.present ? data.projectId.value : this.projectId, + resolvedAst: + data.resolvedAst.present ? data.resolvedAst.value : this.resolvedAst, + etag: data.etag.present ? data.etag.value : this.etag, + ); + } + + @override + String toString() { + return (StringBuffer('CloudAuthApisData(') + ..write('apiId: $apiId, ') + ..write('projectId: $projectId, ') + ..write('resolvedAst: $resolvedAst, ') + ..write('etag: $etag') + ..write(')')) + .toString(); + } + + @override + int get hashCode => + Object.hash(apiId, projectId, $driftBlobEquality.hash(resolvedAst), etag); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is CloudAuthApisData && + other.apiId == this.apiId && + other.projectId == this.projectId && + $driftBlobEquality.equals(other.resolvedAst, this.resolvedAst) && + other.etag == this.etag); +} + +class CloudAuthApisCompanion extends UpdateCompanion { + final Value apiId; + final Value projectId; + final Value resolvedAst; + final Value etag; + final Value rowid; + const CloudAuthApisCompanion({ + this.apiId = const Value.absent(), + this.projectId = const Value.absent(), + this.resolvedAst = const Value.absent(), + this.etag = const Value.absent(), + this.rowid = const Value.absent(), + }); + CloudAuthApisCompanion.insert({ + required String apiId, + required String projectId, + required Uint8List resolvedAst, + required String etag, + this.rowid = const Value.absent(), + }) : apiId = Value(apiId), + projectId = Value(projectId), + resolvedAst = Value(resolvedAst), + etag = Value(etag); + static Insertable custom({ + Expression? apiId, + Expression? projectId, + Expression? resolvedAst, + Expression? etag, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (apiId != null) 'api_id': apiId, + if (projectId != null) 'project_id': projectId, + if (resolvedAst != null) 'resolved_ast': resolvedAst, + if (etag != null) 'etag': etag, + if (rowid != null) 'rowid': rowid, + }); + } + + CloudAuthApisCompanion copyWith({ + Value? apiId, + Value? projectId, + Value? resolvedAst, + Value? etag, + Value? rowid, + }) { + return CloudAuthApisCompanion( + apiId: apiId ?? this.apiId, + projectId: projectId ?? this.projectId, + resolvedAst: resolvedAst ?? this.resolvedAst, + etag: etag ?? this.etag, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (apiId.present) { + map['api_id'] = Variable(apiId.value); + } + if (projectId.present) { + map['project_id'] = Variable(projectId.value); + } + if (resolvedAst.present) { + map['resolved_ast'] = Variable(resolvedAst.value); + } + if (etag.present) { + map['etag'] = Variable(etag.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('CloudAuthApisCompanion(') + ..write('apiId: $apiId, ') + ..write('projectId: $projectId, ') + ..write('resolvedAst: $resolvedAst, ') + ..write('etag: $etag, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +class CloudAuthFunctions extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + CloudAuthFunctions(this.attachedDatabase, [this._alias]); + late final GeneratedColumn functionId = GeneratedColumn( + 'function_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); + late final GeneratedColumn apiId = GeneratedColumn( + 'api_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn resolvedAst = + GeneratedColumn( + 'resolved_ast', + aliasedName, + false, + type: DriftSqlType.blob, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn etag = GeneratedColumn( + 'etag', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + @override + List get $columns => [functionId, apiId, resolvedAst, etag]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'cloud_auth_functions'; + @override + Set get $primaryKey => {functionId}; + @override + CloudAuthFunctionsData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return CloudAuthFunctionsData( + functionId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}function_id'], + )!, + apiId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}api_id'], + )!, + resolvedAst: + attachedDatabase.typeMapping.read( + DriftSqlType.blob, + data['${effectivePrefix}resolved_ast'], + )!, + etag: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}etag'], + )!, + ); + } + + @override + CloudAuthFunctions createAlias(String alias) { + return CloudAuthFunctions(attachedDatabase, alias); + } + + @override + List get customConstraints => const [ + 'CONSTRAINT cloud_auth_functions_api_fk FOREIGN KEY(api_id)REFERENCES cloud_auth_apis(api_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED', + ]; + @override + bool get dontWriteConstraints => true; +} + +class CloudAuthFunctionsData extends DataClass + implements Insertable { + final String functionId; + final String apiId; + final Uint8List resolvedAst; + final String etag; + const CloudAuthFunctionsData({ + required this.functionId, + required this.apiId, + required this.resolvedAst, + required this.etag, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['function_id'] = Variable(functionId); + map['api_id'] = Variable(apiId); + map['resolved_ast'] = Variable(resolvedAst); + map['etag'] = Variable(etag); + return map; + } + + CloudAuthFunctionsCompanion toCompanion(bool nullToAbsent) { + return CloudAuthFunctionsCompanion( + functionId: Value(functionId), + apiId: Value(apiId), + resolvedAst: Value(resolvedAst), + etag: Value(etag), + ); + } + + factory CloudAuthFunctionsData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return CloudAuthFunctionsData( + functionId: serializer.fromJson(json['functionId']), + apiId: serializer.fromJson(json['apiId']), + resolvedAst: serializer.fromJson(json['resolvedAst']), + etag: serializer.fromJson(json['etag']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'functionId': serializer.toJson(functionId), + 'apiId': serializer.toJson(apiId), + 'resolvedAst': serializer.toJson(resolvedAst), + 'etag': serializer.toJson(etag), + }; + } + + CloudAuthFunctionsData copyWith({ + String? functionId, + String? apiId, + Uint8List? resolvedAst, + String? etag, + }) => CloudAuthFunctionsData( + functionId: functionId ?? this.functionId, + apiId: apiId ?? this.apiId, + resolvedAst: resolvedAst ?? this.resolvedAst, + etag: etag ?? this.etag, + ); + CloudAuthFunctionsData copyWithCompanion(CloudAuthFunctionsCompanion data) { + return CloudAuthFunctionsData( + functionId: + data.functionId.present ? data.functionId.value : this.functionId, + apiId: data.apiId.present ? data.apiId.value : this.apiId, + resolvedAst: + data.resolvedAst.present ? data.resolvedAst.value : this.resolvedAst, + etag: data.etag.present ? data.etag.value : this.etag, + ); + } + + @override + String toString() { + return (StringBuffer('CloudAuthFunctionsData(') + ..write('functionId: $functionId, ') + ..write('apiId: $apiId, ') + ..write('resolvedAst: $resolvedAst, ') + ..write('etag: $etag') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + functionId, + apiId, + $driftBlobEquality.hash(resolvedAst), + etag, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is CloudAuthFunctionsData && + other.functionId == this.functionId && + other.apiId == this.apiId && + $driftBlobEquality.equals(other.resolvedAst, this.resolvedAst) && + other.etag == this.etag); +} + +class CloudAuthFunctionsCompanion + extends UpdateCompanion { + final Value functionId; + final Value apiId; + final Value resolvedAst; + final Value etag; + final Value rowid; + const CloudAuthFunctionsCompanion({ + this.functionId = const Value.absent(), + this.apiId = const Value.absent(), + this.resolvedAst = const Value.absent(), + this.etag = const Value.absent(), + this.rowid = const Value.absent(), + }); + CloudAuthFunctionsCompanion.insert({ + required String functionId, + required String apiId, + required Uint8List resolvedAst, + required String etag, + this.rowid = const Value.absent(), + }) : functionId = Value(functionId), + apiId = Value(apiId), + resolvedAst = Value(resolvedAst), + etag = Value(etag); + static Insertable custom({ + Expression? functionId, + Expression? apiId, + Expression? resolvedAst, + Expression? etag, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (functionId != null) 'function_id': functionId, + if (apiId != null) 'api_id': apiId, + if (resolvedAst != null) 'resolved_ast': resolvedAst, + if (etag != null) 'etag': etag, + if (rowid != null) 'rowid': rowid, + }); + } + + CloudAuthFunctionsCompanion copyWith({ + Value? functionId, + Value? apiId, + Value? resolvedAst, + Value? etag, + Value? rowid, + }) { + return CloudAuthFunctionsCompanion( + functionId: functionId ?? this.functionId, + apiId: apiId ?? this.apiId, + resolvedAst: resolvedAst ?? this.resolvedAst, + etag: etag ?? this.etag, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (functionId.present) { + map['function_id'] = Variable(functionId.value); + } + if (apiId.present) { + map['api_id'] = Variable(apiId.value); + } + if (resolvedAst.present) { + map['resolved_ast'] = Variable(resolvedAst.value); + } + if (etag.present) { + map['etag'] = Variable(etag.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('CloudAuthFunctionsCompanion(') + ..write('functionId: $functionId, ') + ..write('apiId: $apiId, ') + ..write('resolvedAst: $resolvedAst, ') + ..write('etag: $etag, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +class CloudAuthMeta extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + CloudAuthMeta(this.attachedDatabase, [this._alias]); + late final GeneratedColumn schemaVersion = GeneratedColumn( + 'schema_version', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); + @override + List get $columns => [schemaVersion]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'cloud_auth_meta'; + @override + Set get $primaryKey => {schemaVersion}; + @override + CloudAuthMetaData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return CloudAuthMetaData( + schemaVersion: + attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}schema_version'], + )!, + ); + } + + @override + CloudAuthMeta createAlias(String alias) { + return CloudAuthMeta(attachedDatabase, alias); + } + + @override + bool get dontWriteConstraints => true; +} + +class CloudAuthMetaData extends DataClass + implements Insertable { + final int schemaVersion; + const CloudAuthMetaData({required this.schemaVersion}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['schema_version'] = Variable(schemaVersion); + return map; + } + + CloudAuthMetaCompanion toCompanion(bool nullToAbsent) { + return CloudAuthMetaCompanion(schemaVersion: Value(schemaVersion)); + } + + factory CloudAuthMetaData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return CloudAuthMetaData( + schemaVersion: serializer.fromJson(json['schemaVersion']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'schemaVersion': serializer.toJson(schemaVersion), + }; + } + + CloudAuthMetaData copyWith({int? schemaVersion}) => + CloudAuthMetaData(schemaVersion: schemaVersion ?? this.schemaVersion); + CloudAuthMetaData copyWithCompanion(CloudAuthMetaCompanion data) { + return CloudAuthMetaData( + schemaVersion: + data.schemaVersion.present + ? data.schemaVersion.value + : this.schemaVersion, + ); + } + + @override + String toString() { + return (StringBuffer('CloudAuthMetaData(') + ..write('schemaVersion: $schemaVersion') + ..write(')')) + .toString(); + } + + @override + int get hashCode => schemaVersion.hashCode; + @override + bool operator ==(Object other) => + identical(this, other) || + (other is CloudAuthMetaData && other.schemaVersion == this.schemaVersion); +} + +class CloudAuthMetaCompanion extends UpdateCompanion { + final Value schemaVersion; + const CloudAuthMetaCompanion({this.schemaVersion = const Value.absent()}); + CloudAuthMetaCompanion.insert({this.schemaVersion = const Value.absent()}); + static Insertable custom({ + Expression? schemaVersion, + }) { + return RawValuesInsertable({ + if (schemaVersion != null) 'schema_version': schemaVersion, + }); + } + + CloudAuthMetaCompanion copyWith({Value? schemaVersion}) { + return CloudAuthMetaCompanion( + schemaVersion: schemaVersion ?? this.schemaVersion, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (schemaVersion.present) { + map['schema_version'] = Variable(schemaVersion.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('CloudAuthMetaCompanion(') + ..write('schemaVersion: $schemaVersion') + ..write(')')) + .toString(); + } +} + +class CloudAuthCryptoKeys extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + CloudAuthCryptoKeys(this.attachedDatabase, [this._alias]); + late final GeneratedColumn cryptoKeyId = + GeneratedColumn( + 'crypto_key_id', + aliasedName, + false, + type: DriftSqlType.blob, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); + late final GeneratedColumn keyPurpose = GeneratedColumn( + 'key_purpose', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn keyAlgorithm = GeneratedColumn( + 'key_algorithm', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn keyMaterial = + GeneratedColumn( + 'key_material', + aliasedName, + true, + type: DriftSqlType.blob, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn externalCryptoKeyId = + GeneratedColumn( + 'external_crypto_key_id', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'UNIQUE', + ); + @override + List get $columns => [ + cryptoKeyId, + keyPurpose, + keyAlgorithm, + keyMaterial, + externalCryptoKeyId, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'cloud_auth_crypto_keys'; + @override + Set get $primaryKey => {cryptoKeyId}; + @override + CloudAuthCryptoKeysData map( + Map data, { + String? tablePrefix, + }) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return CloudAuthCryptoKeysData( + cryptoKeyId: + attachedDatabase.typeMapping.read( + DriftSqlType.blob, + data['${effectivePrefix}crypto_key_id'], + )!, + keyPurpose: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}key_purpose'], + )!, + keyAlgorithm: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}key_algorithm'], + )!, + keyMaterial: attachedDatabase.typeMapping.read( + DriftSqlType.blob, + data['${effectivePrefix}key_material'], + ), + externalCryptoKeyId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}external_crypto_key_id'], + ), + ); + } + + @override + CloudAuthCryptoKeys createAlias(String alias) { + return CloudAuthCryptoKeys(attachedDatabase, alias); + } + + @override + List get customConstraints => const [ + 'CHECK(key_material IS NOT NULL OR external_crypto_key_id IS NOT NULL)', + ]; + @override + bool get dontWriteConstraints => true; +} + +class CloudAuthCryptoKeysData extends DataClass + implements Insertable { + final Uint8List cryptoKeyId; + final String keyPurpose; + final String keyAlgorithm; + final Uint8List? keyMaterial; + final String? externalCryptoKeyId; + const CloudAuthCryptoKeysData({ + required this.cryptoKeyId, + required this.keyPurpose, + required this.keyAlgorithm, + this.keyMaterial, + this.externalCryptoKeyId, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['crypto_key_id'] = Variable(cryptoKeyId); + map['key_purpose'] = Variable(keyPurpose); + map['key_algorithm'] = Variable(keyAlgorithm); + if (!nullToAbsent || keyMaterial != null) { + map['key_material'] = Variable(keyMaterial); + } + if (!nullToAbsent || externalCryptoKeyId != null) { + map['external_crypto_key_id'] = Variable(externalCryptoKeyId); + } + return map; + } + + CloudAuthCryptoKeysCompanion toCompanion(bool nullToAbsent) { + return CloudAuthCryptoKeysCompanion( + cryptoKeyId: Value(cryptoKeyId), + keyPurpose: Value(keyPurpose), + keyAlgorithm: Value(keyAlgorithm), + keyMaterial: + keyMaterial == null && nullToAbsent + ? const Value.absent() + : Value(keyMaterial), + externalCryptoKeyId: + externalCryptoKeyId == null && nullToAbsent + ? const Value.absent() + : Value(externalCryptoKeyId), + ); + } + + factory CloudAuthCryptoKeysData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return CloudAuthCryptoKeysData( + cryptoKeyId: serializer.fromJson(json['cryptoKeyId']), + keyPurpose: serializer.fromJson(json['keyPurpose']), + keyAlgorithm: serializer.fromJson(json['keyAlgorithm']), + keyMaterial: serializer.fromJson(json['keyMaterial']), + externalCryptoKeyId: serializer.fromJson( + json['externalCryptoKeyId'], + ), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'cryptoKeyId': serializer.toJson(cryptoKeyId), + 'keyPurpose': serializer.toJson(keyPurpose), + 'keyAlgorithm': serializer.toJson(keyAlgorithm), + 'keyMaterial': serializer.toJson(keyMaterial), + 'externalCryptoKeyId': serializer.toJson(externalCryptoKeyId), + }; + } + + CloudAuthCryptoKeysData copyWith({ + Uint8List? cryptoKeyId, + String? keyPurpose, + String? keyAlgorithm, + Value keyMaterial = const Value.absent(), + Value externalCryptoKeyId = const Value.absent(), + }) => CloudAuthCryptoKeysData( + cryptoKeyId: cryptoKeyId ?? this.cryptoKeyId, + keyPurpose: keyPurpose ?? this.keyPurpose, + keyAlgorithm: keyAlgorithm ?? this.keyAlgorithm, + keyMaterial: keyMaterial.present ? keyMaterial.value : this.keyMaterial, + externalCryptoKeyId: + externalCryptoKeyId.present + ? externalCryptoKeyId.value + : this.externalCryptoKeyId, + ); + CloudAuthCryptoKeysData copyWithCompanion(CloudAuthCryptoKeysCompanion data) { + return CloudAuthCryptoKeysData( + cryptoKeyId: + data.cryptoKeyId.present ? data.cryptoKeyId.value : this.cryptoKeyId, + keyPurpose: + data.keyPurpose.present ? data.keyPurpose.value : this.keyPurpose, + keyAlgorithm: + data.keyAlgorithm.present + ? data.keyAlgorithm.value + : this.keyAlgorithm, + keyMaterial: + data.keyMaterial.present ? data.keyMaterial.value : this.keyMaterial, + externalCryptoKeyId: + data.externalCryptoKeyId.present + ? data.externalCryptoKeyId.value + : this.externalCryptoKeyId, + ); + } + + @override + String toString() { + return (StringBuffer('CloudAuthCryptoKeysData(') + ..write('cryptoKeyId: $cryptoKeyId, ') + ..write('keyPurpose: $keyPurpose, ') + ..write('keyAlgorithm: $keyAlgorithm, ') + ..write('keyMaterial: $keyMaterial, ') + ..write('externalCryptoKeyId: $externalCryptoKeyId') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + $driftBlobEquality.hash(cryptoKeyId), + keyPurpose, + keyAlgorithm, + $driftBlobEquality.hash(keyMaterial), + externalCryptoKeyId, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is CloudAuthCryptoKeysData && + $driftBlobEquality.equals(other.cryptoKeyId, this.cryptoKeyId) && + other.keyPurpose == this.keyPurpose && + other.keyAlgorithm == this.keyAlgorithm && + $driftBlobEquality.equals(other.keyMaterial, this.keyMaterial) && + other.externalCryptoKeyId == this.externalCryptoKeyId); +} + +class CloudAuthCryptoKeysCompanion + extends UpdateCompanion { + final Value cryptoKeyId; + final Value keyPurpose; + final Value keyAlgorithm; + final Value keyMaterial; + final Value externalCryptoKeyId; + final Value rowid; + const CloudAuthCryptoKeysCompanion({ + this.cryptoKeyId = const Value.absent(), + this.keyPurpose = const Value.absent(), + this.keyAlgorithm = const Value.absent(), + this.keyMaterial = const Value.absent(), + this.externalCryptoKeyId = const Value.absent(), + this.rowid = const Value.absent(), + }); + CloudAuthCryptoKeysCompanion.insert({ + required Uint8List cryptoKeyId, + required String keyPurpose, + required String keyAlgorithm, + this.keyMaterial = const Value.absent(), + this.externalCryptoKeyId = const Value.absent(), + this.rowid = const Value.absent(), + }) : cryptoKeyId = Value(cryptoKeyId), + keyPurpose = Value(keyPurpose), + keyAlgorithm = Value(keyAlgorithm); + static Insertable custom({ + Expression? cryptoKeyId, + Expression? keyPurpose, + Expression? keyAlgorithm, + Expression? keyMaterial, + Expression? externalCryptoKeyId, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (cryptoKeyId != null) 'crypto_key_id': cryptoKeyId, + if (keyPurpose != null) 'key_purpose': keyPurpose, + if (keyAlgorithm != null) 'key_algorithm': keyAlgorithm, + if (keyMaterial != null) 'key_material': keyMaterial, + if (externalCryptoKeyId != null) + 'external_crypto_key_id': externalCryptoKeyId, + if (rowid != null) 'rowid': rowid, + }); + } + + CloudAuthCryptoKeysCompanion copyWith({ + Value? cryptoKeyId, + Value? keyPurpose, + Value? keyAlgorithm, + Value? keyMaterial, + Value? externalCryptoKeyId, + Value? rowid, + }) { + return CloudAuthCryptoKeysCompanion( + cryptoKeyId: cryptoKeyId ?? this.cryptoKeyId, + keyPurpose: keyPurpose ?? this.keyPurpose, + keyAlgorithm: keyAlgorithm ?? this.keyAlgorithm, + keyMaterial: keyMaterial ?? this.keyMaterial, + externalCryptoKeyId: externalCryptoKeyId ?? this.externalCryptoKeyId, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (cryptoKeyId.present) { + map['crypto_key_id'] = Variable(cryptoKeyId.value); + } + if (keyPurpose.present) { + map['key_purpose'] = Variable(keyPurpose.value); + } + if (keyAlgorithm.present) { + map['key_algorithm'] = Variable(keyAlgorithm.value); + } + if (keyMaterial.present) { + map['key_material'] = Variable(keyMaterial.value); + } + if (externalCryptoKeyId.present) { + map['external_crypto_key_id'] = Variable( + externalCryptoKeyId.value, + ); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('CloudAuthCryptoKeysCompanion(') + ..write('cryptoKeyId: $cryptoKeyId, ') + ..write('keyPurpose: $keyPurpose, ') + ..write('keyAlgorithm: $keyAlgorithm, ') + ..write('keyMaterial: $keyMaterial, ') + ..write('externalCryptoKeyId: $externalCryptoKeyId, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +class CloudAuthSessions extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + CloudAuthSessions(this.attachedDatabase, [this._alias]); + late final GeneratedColumn rowid = GeneratedColumn( + 'rowid', + aliasedName, + false, + hasAutoIncrement: true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'PRIMARY KEY AUTOINCREMENT', + ); + late final GeneratedColumn sessionId = GeneratedColumn( + 'session_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL UNIQUE', + ); + late final GeneratedColumn cryptoKeyId = + GeneratedColumn( + 'crypto_key_id', + aliasedName, + false, + type: DriftSqlType.blob, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn userId = GeneratedColumn( + 'user_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn clientInfo = GeneratedColumn( + 'client_info', + aliasedName, + true, + type: DriftSqlType.blob, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn authenticationFactor = + GeneratedColumn( + 'authentication_factor', + aliasedName, + false, + type: DriftSqlType.blob, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn state = GeneratedColumn( + 'state', + aliasedName, + true, + type: DriftSqlType.blob, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn ipAddress = GeneratedColumn( + 'ip_address', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn externalSessionId = + GeneratedColumn( + 'external_session_id', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn createTime = GeneratedColumn( + 'create_time', + aliasedName, + false, + type: DriftSqlType.double, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT (unixepoch(\'now\', \'subsec\'))', + defaultValue: const CustomExpression('unixepoch(\'now\', \'subsec\')'), + ); + late final GeneratedColumn updateTime = GeneratedColumn( + 'update_time', + aliasedName, + true, + type: DriftSqlType.double, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn expireTime = GeneratedColumn( + 'expire_time', + aliasedName, + false, + type: DriftSqlType.double, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + @override + List get $columns => [ + rowid, + sessionId, + cryptoKeyId, + userId, + clientInfo, + authenticationFactor, + state, + ipAddress, + externalSessionId, + createTime, + updateTime, + expireTime, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'cloud_auth_sessions'; + @override + Set get $primaryKey => {rowid}; + @override + CloudAuthSessionsData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return CloudAuthSessionsData( + rowid: + attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}rowid'], + )!, + sessionId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}session_id'], + )!, + cryptoKeyId: + attachedDatabase.typeMapping.read( + DriftSqlType.blob, + data['${effectivePrefix}crypto_key_id'], + )!, + userId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}user_id'], + )!, + clientInfo: attachedDatabase.typeMapping.read( + DriftSqlType.blob, + data['${effectivePrefix}client_info'], + ), + authenticationFactor: + attachedDatabase.typeMapping.read( + DriftSqlType.blob, + data['${effectivePrefix}authentication_factor'], + )!, + state: attachedDatabase.typeMapping.read( + DriftSqlType.blob, + data['${effectivePrefix}state'], + ), + ipAddress: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}ip_address'], + ), + externalSessionId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}external_session_id'], + ), + createTime: + attachedDatabase.typeMapping.read( + DriftSqlType.double, + data['${effectivePrefix}create_time'], + )!, + updateTime: attachedDatabase.typeMapping.read( + DriftSqlType.double, + data['${effectivePrefix}update_time'], + ), + expireTime: + attachedDatabase.typeMapping.read( + DriftSqlType.double, + data['${effectivePrefix}expire_time'], + )!, + ); + } + + @override + CloudAuthSessions createAlias(String alias) { + return CloudAuthSessions(attachedDatabase, alias); + } + + @override + List get customConstraints => const [ + 'CONSTRAINT cloud_auth_sessions_user_fk FOREIGN KEY(user_id)REFERENCES cloud_auth_users(user_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED', + 'CONSTRAINT cloud_auth_sessions_key_fk FOREIGN KEY(crypto_key_id)REFERENCES cloud_auth_crypto_keys(crypto_key_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED', + ]; + @override + bool get dontWriteConstraints => true; +} + +class CloudAuthSessionsData extends DataClass + implements Insertable { + final int rowid; + final String sessionId; + final Uint8List cryptoKeyId; + final String userId; + final Uint8List? clientInfo; + final Uint8List authenticationFactor; + final Uint8List? state; + final String? ipAddress; + final String? externalSessionId; + final double createTime; + final double? updateTime; + final double expireTime; + const CloudAuthSessionsData({ + required this.rowid, + required this.sessionId, + required this.cryptoKeyId, + required this.userId, + this.clientInfo, + required this.authenticationFactor, + this.state, + this.ipAddress, + this.externalSessionId, + required this.createTime, + this.updateTime, + required this.expireTime, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['rowid'] = Variable(rowid); + map['session_id'] = Variable(sessionId); + map['crypto_key_id'] = Variable(cryptoKeyId); + map['user_id'] = Variable(userId); + if (!nullToAbsent || clientInfo != null) { + map['client_info'] = Variable(clientInfo); + } + map['authentication_factor'] = Variable(authenticationFactor); + if (!nullToAbsent || state != null) { + map['state'] = Variable(state); + } + if (!nullToAbsent || ipAddress != null) { + map['ip_address'] = Variable(ipAddress); + } + if (!nullToAbsent || externalSessionId != null) { + map['external_session_id'] = Variable(externalSessionId); + } + map['create_time'] = Variable(createTime); + if (!nullToAbsent || updateTime != null) { + map['update_time'] = Variable(updateTime); + } + map['expire_time'] = Variable(expireTime); + return map; + } + + CloudAuthSessionsCompanion toCompanion(bool nullToAbsent) { + return CloudAuthSessionsCompanion( + rowid: Value(rowid), + sessionId: Value(sessionId), + cryptoKeyId: Value(cryptoKeyId), + userId: Value(userId), + clientInfo: + clientInfo == null && nullToAbsent + ? const Value.absent() + : Value(clientInfo), + authenticationFactor: Value(authenticationFactor), + state: + state == null && nullToAbsent ? const Value.absent() : Value(state), + ipAddress: + ipAddress == null && nullToAbsent + ? const Value.absent() + : Value(ipAddress), + externalSessionId: + externalSessionId == null && nullToAbsent + ? const Value.absent() + : Value(externalSessionId), + createTime: Value(createTime), + updateTime: + updateTime == null && nullToAbsent + ? const Value.absent() + : Value(updateTime), + expireTime: Value(expireTime), + ); + } + + factory CloudAuthSessionsData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return CloudAuthSessionsData( + rowid: serializer.fromJson(json['rowid']), + sessionId: serializer.fromJson(json['sessionId']), + cryptoKeyId: serializer.fromJson(json['cryptoKeyId']), + userId: serializer.fromJson(json['userId']), + clientInfo: serializer.fromJson(json['clientInfo']), + authenticationFactor: serializer.fromJson( + json['authenticationFactor'], + ), + state: serializer.fromJson(json['state']), + ipAddress: serializer.fromJson(json['ipAddress']), + externalSessionId: serializer.fromJson( + json['externalSessionId'], + ), + createTime: serializer.fromJson(json['createTime']), + updateTime: serializer.fromJson(json['updateTime']), + expireTime: serializer.fromJson(json['expireTime']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'rowid': serializer.toJson(rowid), + 'sessionId': serializer.toJson(sessionId), + 'cryptoKeyId': serializer.toJson(cryptoKeyId), + 'userId': serializer.toJson(userId), + 'clientInfo': serializer.toJson(clientInfo), + 'authenticationFactor': serializer.toJson( + authenticationFactor, + ), + 'state': serializer.toJson(state), + 'ipAddress': serializer.toJson(ipAddress), + 'externalSessionId': serializer.toJson(externalSessionId), + 'createTime': serializer.toJson(createTime), + 'updateTime': serializer.toJson(updateTime), + 'expireTime': serializer.toJson(expireTime), + }; + } + + CloudAuthSessionsData copyWith({ + int? rowid, + String? sessionId, + Uint8List? cryptoKeyId, + String? userId, + Value clientInfo = const Value.absent(), + Uint8List? authenticationFactor, + Value state = const Value.absent(), + Value ipAddress = const Value.absent(), + Value externalSessionId = const Value.absent(), + double? createTime, + Value updateTime = const Value.absent(), + double? expireTime, + }) => CloudAuthSessionsData( + rowid: rowid ?? this.rowid, + sessionId: sessionId ?? this.sessionId, + cryptoKeyId: cryptoKeyId ?? this.cryptoKeyId, + userId: userId ?? this.userId, + clientInfo: clientInfo.present ? clientInfo.value : this.clientInfo, + authenticationFactor: authenticationFactor ?? this.authenticationFactor, + state: state.present ? state.value : this.state, + ipAddress: ipAddress.present ? ipAddress.value : this.ipAddress, + externalSessionId: + externalSessionId.present + ? externalSessionId.value + : this.externalSessionId, + createTime: createTime ?? this.createTime, + updateTime: updateTime.present ? updateTime.value : this.updateTime, + expireTime: expireTime ?? this.expireTime, + ); + CloudAuthSessionsData copyWithCompanion(CloudAuthSessionsCompanion data) { + return CloudAuthSessionsData( + rowid: data.rowid.present ? data.rowid.value : this.rowid, + sessionId: data.sessionId.present ? data.sessionId.value : this.sessionId, + cryptoKeyId: + data.cryptoKeyId.present ? data.cryptoKeyId.value : this.cryptoKeyId, + userId: data.userId.present ? data.userId.value : this.userId, + clientInfo: + data.clientInfo.present ? data.clientInfo.value : this.clientInfo, + authenticationFactor: + data.authenticationFactor.present + ? data.authenticationFactor.value + : this.authenticationFactor, + state: data.state.present ? data.state.value : this.state, + ipAddress: data.ipAddress.present ? data.ipAddress.value : this.ipAddress, + externalSessionId: + data.externalSessionId.present + ? data.externalSessionId.value + : this.externalSessionId, + createTime: + data.createTime.present ? data.createTime.value : this.createTime, + updateTime: + data.updateTime.present ? data.updateTime.value : this.updateTime, + expireTime: + data.expireTime.present ? data.expireTime.value : this.expireTime, + ); + } + + @override + String toString() { + return (StringBuffer('CloudAuthSessionsData(') + ..write('rowid: $rowid, ') + ..write('sessionId: $sessionId, ') + ..write('cryptoKeyId: $cryptoKeyId, ') + ..write('userId: $userId, ') + ..write('clientInfo: $clientInfo, ') + ..write('authenticationFactor: $authenticationFactor, ') + ..write('state: $state, ') + ..write('ipAddress: $ipAddress, ') + ..write('externalSessionId: $externalSessionId, ') + ..write('createTime: $createTime, ') + ..write('updateTime: $updateTime, ') + ..write('expireTime: $expireTime') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + rowid, + sessionId, + $driftBlobEquality.hash(cryptoKeyId), + userId, + $driftBlobEquality.hash(clientInfo), + $driftBlobEquality.hash(authenticationFactor), + $driftBlobEquality.hash(state), + ipAddress, + externalSessionId, + createTime, + updateTime, + expireTime, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is CloudAuthSessionsData && + other.rowid == this.rowid && + other.sessionId == this.sessionId && + $driftBlobEquality.equals(other.cryptoKeyId, this.cryptoKeyId) && + other.userId == this.userId && + $driftBlobEquality.equals(other.clientInfo, this.clientInfo) && + $driftBlobEquality.equals( + other.authenticationFactor, + this.authenticationFactor, + ) && + $driftBlobEquality.equals(other.state, this.state) && + other.ipAddress == this.ipAddress && + other.externalSessionId == this.externalSessionId && + other.createTime == this.createTime && + other.updateTime == this.updateTime && + other.expireTime == this.expireTime); +} + +class CloudAuthSessionsCompanion + extends UpdateCompanion { + final Value rowid; + final Value sessionId; + final Value cryptoKeyId; + final Value userId; + final Value clientInfo; + final Value authenticationFactor; + final Value state; + final Value ipAddress; + final Value externalSessionId; + final Value createTime; + final Value updateTime; + final Value expireTime; + const CloudAuthSessionsCompanion({ + this.rowid = const Value.absent(), + this.sessionId = const Value.absent(), + this.cryptoKeyId = const Value.absent(), + this.userId = const Value.absent(), + this.clientInfo = const Value.absent(), + this.authenticationFactor = const Value.absent(), + this.state = const Value.absent(), + this.ipAddress = const Value.absent(), + this.externalSessionId = const Value.absent(), + this.createTime = const Value.absent(), + this.updateTime = const Value.absent(), + this.expireTime = const Value.absent(), + }); + CloudAuthSessionsCompanion.insert({ + this.rowid = const Value.absent(), + required String sessionId, + required Uint8List cryptoKeyId, + required String userId, + this.clientInfo = const Value.absent(), + required Uint8List authenticationFactor, + this.state = const Value.absent(), + this.ipAddress = const Value.absent(), + this.externalSessionId = const Value.absent(), + this.createTime = const Value.absent(), + this.updateTime = const Value.absent(), + required double expireTime, + }) : sessionId = Value(sessionId), + cryptoKeyId = Value(cryptoKeyId), + userId = Value(userId), + authenticationFactor = Value(authenticationFactor), + expireTime = Value(expireTime); + static Insertable custom({ + Expression? rowid, + Expression? sessionId, + Expression? cryptoKeyId, + Expression? userId, + Expression? clientInfo, + Expression? authenticationFactor, + Expression? state, + Expression? ipAddress, + Expression? externalSessionId, + Expression? createTime, + Expression? updateTime, + Expression? expireTime, + }) { + return RawValuesInsertable({ + if (rowid != null) 'rowid': rowid, + if (sessionId != null) 'session_id': sessionId, + if (cryptoKeyId != null) 'crypto_key_id': cryptoKeyId, + if (userId != null) 'user_id': userId, + if (clientInfo != null) 'client_info': clientInfo, + if (authenticationFactor != null) + 'authentication_factor': authenticationFactor, + if (state != null) 'state': state, + if (ipAddress != null) 'ip_address': ipAddress, + if (externalSessionId != null) 'external_session_id': externalSessionId, + if (createTime != null) 'create_time': createTime, + if (updateTime != null) 'update_time': updateTime, + if (expireTime != null) 'expire_time': expireTime, + }); + } + + CloudAuthSessionsCompanion copyWith({ + Value? rowid, + Value? sessionId, + Value? cryptoKeyId, + Value? userId, + Value? clientInfo, + Value? authenticationFactor, + Value? state, + Value? ipAddress, + Value? externalSessionId, + Value? createTime, + Value? updateTime, + Value? expireTime, + }) { + return CloudAuthSessionsCompanion( + rowid: rowid ?? this.rowid, + sessionId: sessionId ?? this.sessionId, + cryptoKeyId: cryptoKeyId ?? this.cryptoKeyId, + userId: userId ?? this.userId, + clientInfo: clientInfo ?? this.clientInfo, + authenticationFactor: authenticationFactor ?? this.authenticationFactor, + state: state ?? this.state, + ipAddress: ipAddress ?? this.ipAddress, + externalSessionId: externalSessionId ?? this.externalSessionId, + createTime: createTime ?? this.createTime, + updateTime: updateTime ?? this.updateTime, + expireTime: expireTime ?? this.expireTime, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + if (sessionId.present) { + map['session_id'] = Variable(sessionId.value); + } + if (cryptoKeyId.present) { + map['crypto_key_id'] = Variable(cryptoKeyId.value); + } + if (userId.present) { + map['user_id'] = Variable(userId.value); + } + if (clientInfo.present) { + map['client_info'] = Variable(clientInfo.value); + } + if (authenticationFactor.present) { + map['authentication_factor'] = Variable( + authenticationFactor.value, + ); + } + if (state.present) { + map['state'] = Variable(state.value); + } + if (ipAddress.present) { + map['ip_address'] = Variable(ipAddress.value); + } + if (externalSessionId.present) { + map['external_session_id'] = Variable(externalSessionId.value); + } + if (createTime.present) { + map['create_time'] = Variable(createTime.value); + } + if (updateTime.present) { + map['update_time'] = Variable(updateTime.value); + } + if (expireTime.present) { + map['expire_time'] = Variable(expireTime.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('CloudAuthSessionsCompanion(') + ..write('rowid: $rowid, ') + ..write('sessionId: $sessionId, ') + ..write('cryptoKeyId: $cryptoKeyId, ') + ..write('userId: $userId, ') + ..write('clientInfo: $clientInfo, ') + ..write('authenticationFactor: $authenticationFactor, ') + ..write('state: $state, ') + ..write('ipAddress: $ipAddress, ') + ..write('externalSessionId: $externalSessionId, ') + ..write('createTime: $createTime, ') + ..write('updateTime: $updateTime, ') + ..write('expireTime: $expireTime') + ..write(')')) + .toString(); + } +} + +class CloudAuthOtpCodes extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + CloudAuthOtpCodes(this.attachedDatabase, [this._alias]); + late final GeneratedColumn rowid = GeneratedColumn( + 'rowid', + aliasedName, + false, + hasAutoIncrement: true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'PRIMARY KEY AUTOINCREMENT', + ); + late final GeneratedColumn sessionId = GeneratedColumn( + 'session_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL UNIQUE', + ); + late final GeneratedColumn resendAttempt = GeneratedColumn( + 'resend_attempt', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT 0', + defaultValue: const CustomExpression('0'), + ); + late final GeneratedColumn verifyAttempt = GeneratedColumn( + 'verify_attempt', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT 0', + defaultValue: const CustomExpression('0'), + ); + late final GeneratedColumn updateTime = GeneratedColumn( + 'update_time', + aliasedName, + false, + type: DriftSqlType.double, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT (unixepoch(\'now\', \'subsec\'))', + defaultValue: const CustomExpression('unixepoch(\'now\', \'subsec\')'), + ); + @override + List get $columns => [ + rowid, + sessionId, + resendAttempt, + verifyAttempt, + updateTime, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'cloud_auth_otp_codes'; + @override + Set get $primaryKey => {rowid}; + @override + CloudAuthOtpCodesData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return CloudAuthOtpCodesData( + rowid: + attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}rowid'], + )!, + sessionId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}session_id'], + )!, + resendAttempt: + attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}resend_attempt'], + )!, + verifyAttempt: + attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}verify_attempt'], + )!, + updateTime: + attachedDatabase.typeMapping.read( + DriftSqlType.double, + data['${effectivePrefix}update_time'], + )!, + ); + } + + @override + CloudAuthOtpCodes createAlias(String alias) { + return CloudAuthOtpCodes(attachedDatabase, alias); + } + + @override + List get customConstraints => const [ + 'CONSTRAINT cloud_auth_otp_codes_session_id_fk FOREIGN KEY(session_id)REFERENCES cloud_auth_sessions(session_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED', + ]; + @override + bool get dontWriteConstraints => true; +} + +class CloudAuthOtpCodesData extends DataClass + implements Insertable { + final int rowid; + final String sessionId; + final int resendAttempt; + final int verifyAttempt; + final double updateTime; + const CloudAuthOtpCodesData({ + required this.rowid, + required this.sessionId, + required this.resendAttempt, + required this.verifyAttempt, + required this.updateTime, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['rowid'] = Variable(rowid); + map['session_id'] = Variable(sessionId); + map['resend_attempt'] = Variable(resendAttempt); + map['verify_attempt'] = Variable(verifyAttempt); + map['update_time'] = Variable(updateTime); + return map; + } + + CloudAuthOtpCodesCompanion toCompanion(bool nullToAbsent) { + return CloudAuthOtpCodesCompanion( + rowid: Value(rowid), + sessionId: Value(sessionId), + resendAttempt: Value(resendAttempt), + verifyAttempt: Value(verifyAttempt), + updateTime: Value(updateTime), + ); + } + + factory CloudAuthOtpCodesData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return CloudAuthOtpCodesData( + rowid: serializer.fromJson(json['rowid']), + sessionId: serializer.fromJson(json['sessionId']), + resendAttempt: serializer.fromJson(json['resendAttempt']), + verifyAttempt: serializer.fromJson(json['verifyAttempt']), + updateTime: serializer.fromJson(json['updateTime']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'rowid': serializer.toJson(rowid), + 'sessionId': serializer.toJson(sessionId), + 'resendAttempt': serializer.toJson(resendAttempt), + 'verifyAttempt': serializer.toJson(verifyAttempt), + 'updateTime': serializer.toJson(updateTime), + }; + } + + CloudAuthOtpCodesData copyWith({ + int? rowid, + String? sessionId, + int? resendAttempt, + int? verifyAttempt, + double? updateTime, + }) => CloudAuthOtpCodesData( + rowid: rowid ?? this.rowid, + sessionId: sessionId ?? this.sessionId, + resendAttempt: resendAttempt ?? this.resendAttempt, + verifyAttempt: verifyAttempt ?? this.verifyAttempt, + updateTime: updateTime ?? this.updateTime, + ); + CloudAuthOtpCodesData copyWithCompanion(CloudAuthOtpCodesCompanion data) { + return CloudAuthOtpCodesData( + rowid: data.rowid.present ? data.rowid.value : this.rowid, + sessionId: data.sessionId.present ? data.sessionId.value : this.sessionId, + resendAttempt: + data.resendAttempt.present + ? data.resendAttempt.value + : this.resendAttempt, + verifyAttempt: + data.verifyAttempt.present + ? data.verifyAttempt.value + : this.verifyAttempt, + updateTime: + data.updateTime.present ? data.updateTime.value : this.updateTime, + ); + } + + @override + String toString() { + return (StringBuffer('CloudAuthOtpCodesData(') + ..write('rowid: $rowid, ') + ..write('sessionId: $sessionId, ') + ..write('resendAttempt: $resendAttempt, ') + ..write('verifyAttempt: $verifyAttempt, ') + ..write('updateTime: $updateTime') + ..write(')')) + .toString(); + } + + @override + int get hashCode => + Object.hash(rowid, sessionId, resendAttempt, verifyAttempt, updateTime); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is CloudAuthOtpCodesData && + other.rowid == this.rowid && + other.sessionId == this.sessionId && + other.resendAttempt == this.resendAttempt && + other.verifyAttempt == this.verifyAttempt && + other.updateTime == this.updateTime); +} + +class CloudAuthOtpCodesCompanion + extends UpdateCompanion { + final Value rowid; + final Value sessionId; + final Value resendAttempt; + final Value verifyAttempt; + final Value updateTime; + const CloudAuthOtpCodesCompanion({ + this.rowid = const Value.absent(), + this.sessionId = const Value.absent(), + this.resendAttempt = const Value.absent(), + this.verifyAttempt = const Value.absent(), + this.updateTime = const Value.absent(), + }); + CloudAuthOtpCodesCompanion.insert({ + this.rowid = const Value.absent(), + required String sessionId, + this.resendAttempt = const Value.absent(), + this.verifyAttempt = const Value.absent(), + this.updateTime = const Value.absent(), + }) : sessionId = Value(sessionId); + static Insertable custom({ + Expression? rowid, + Expression? sessionId, + Expression? resendAttempt, + Expression? verifyAttempt, + Expression? updateTime, + }) { + return RawValuesInsertable({ + if (rowid != null) 'rowid': rowid, + if (sessionId != null) 'session_id': sessionId, + if (resendAttempt != null) 'resend_attempt': resendAttempt, + if (verifyAttempt != null) 'verify_attempt': verifyAttempt, + if (updateTime != null) 'update_time': updateTime, + }); + } + + CloudAuthOtpCodesCompanion copyWith({ + Value? rowid, + Value? sessionId, + Value? resendAttempt, + Value? verifyAttempt, + Value? updateTime, + }) { + return CloudAuthOtpCodesCompanion( + rowid: rowid ?? this.rowid, + sessionId: sessionId ?? this.sessionId, + resendAttempt: resendAttempt ?? this.resendAttempt, + verifyAttempt: verifyAttempt ?? this.verifyAttempt, + updateTime: updateTime ?? this.updateTime, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + if (sessionId.present) { + map['session_id'] = Variable(sessionId.value); + } + if (resendAttempt.present) { + map['resend_attempt'] = Variable(resendAttempt.value); + } + if (verifyAttempt.present) { + map['verify_attempt'] = Variable(verifyAttempt.value); + } + if (updateTime.present) { + map['update_time'] = Variable(updateTime.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('CloudAuthOtpCodesCompanion(') + ..write('rowid: $rowid, ') + ..write('sessionId: $sessionId, ') + ..write('resendAttempt: $resendAttempt, ') + ..write('verifyAttempt: $verifyAttempt, ') + ..write('updateTime: $updateTime') + ..write(')')) + .toString(); + } +} + +class CloudAuthCorks extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + CloudAuthCorks(this.attachedDatabase, [this._alias]); + late final GeneratedColumn corkId = GeneratedColumn( + 'cork_id', + aliasedName, + false, + type: DriftSqlType.blob, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); + late final GeneratedColumn cryptoKeyId = + GeneratedColumn( + 'crypto_key_id', + aliasedName, + false, + type: DriftSqlType.blob, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn bearerType = GeneratedColumn( + 'bearer_type', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn bearerId = GeneratedColumn( + 'bearer_id', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn audienceType = GeneratedColumn( + 'audience_type', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn audienceId = GeneratedColumn( + 'audience_id', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn issuerType = GeneratedColumn( + 'issuer_type', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn issuerId = GeneratedColumn( + 'issuer_id', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn createTime = GeneratedColumn( + 'create_time', + aliasedName, + false, + type: DriftSqlType.double, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT (unixepoch(\'now\', \'subsec\'))', + defaultValue: const CustomExpression('unixepoch(\'now\', \'subsec\')'), + ); + late final GeneratedColumn expireTime = GeneratedColumn( + 'expire_time', + aliasedName, + true, + type: DriftSqlType.double, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn lastUseTime = GeneratedColumn( + 'last_use_time', + aliasedName, + true, + type: DriftSqlType.double, + requiredDuringInsert: false, + $customConstraints: '', + ); + @override + List get $columns => [ + corkId, + cryptoKeyId, + bearerType, + bearerId, + audienceType, + audienceId, + issuerType, + issuerId, + createTime, + expireTime, + lastUseTime, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'cloud_auth_corks'; + @override + Set get $primaryKey => {corkId}; + @override + CloudAuthCorksData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return CloudAuthCorksData( + corkId: + attachedDatabase.typeMapping.read( + DriftSqlType.blob, + data['${effectivePrefix}cork_id'], + )!, + cryptoKeyId: + attachedDatabase.typeMapping.read( + DriftSqlType.blob, + data['${effectivePrefix}crypto_key_id'], + )!, + bearerType: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}bearer_type'], + ), + bearerId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}bearer_id'], + ), + audienceType: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}audience_type'], + ), + audienceId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}audience_id'], + ), + issuerType: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}issuer_type'], + ), + issuerId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}issuer_id'], + ), + createTime: + attachedDatabase.typeMapping.read( + DriftSqlType.double, + data['${effectivePrefix}create_time'], + )!, + expireTime: attachedDatabase.typeMapping.read( + DriftSqlType.double, + data['${effectivePrefix}expire_time'], + ), + lastUseTime: attachedDatabase.typeMapping.read( + DriftSqlType.double, + data['${effectivePrefix}last_use_time'], + ), + ); + } + + @override + CloudAuthCorks createAlias(String alias) { + return CloudAuthCorks(attachedDatabase, alias); + } + + @override + List get customConstraints => const [ + 'CONSTRAINT cloud_auth_corks_crypto_key_fk FOREIGN KEY(crypto_key_id)REFERENCES cloud_auth_crypto_keys(crypto_key_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED', + 'CONSTRAINT cloud_auth_corks_bearer_fk FOREIGN KEY(bearer_type, bearer_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED', + 'CONSTRAINT cloud_auth_corks_audience_fk FOREIGN KEY(audience_type, audience_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED', + 'CONSTRAINT cloud_auth_corks_issuer_fk FOREIGN KEY(issuer_type, issuer_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED', + ]; + @override + bool get dontWriteConstraints => true; +} + +class CloudAuthCorksData extends DataClass + implements Insertable { + final Uint8List corkId; + final Uint8List cryptoKeyId; + final String? bearerType; + final String? bearerId; + final String? audienceType; + final String? audienceId; + final String? issuerType; + final String? issuerId; + final double createTime; + final double? expireTime; + final double? lastUseTime; + const CloudAuthCorksData({ + required this.corkId, + required this.cryptoKeyId, + this.bearerType, + this.bearerId, + this.audienceType, + this.audienceId, + this.issuerType, + this.issuerId, + required this.createTime, + this.expireTime, + this.lastUseTime, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['cork_id'] = Variable(corkId); + map['crypto_key_id'] = Variable(cryptoKeyId); + if (!nullToAbsent || bearerType != null) { + map['bearer_type'] = Variable(bearerType); + } + if (!nullToAbsent || bearerId != null) { + map['bearer_id'] = Variable(bearerId); + } + if (!nullToAbsent || audienceType != null) { + map['audience_type'] = Variable(audienceType); + } + if (!nullToAbsent || audienceId != null) { + map['audience_id'] = Variable(audienceId); + } + if (!nullToAbsent || issuerType != null) { + map['issuer_type'] = Variable(issuerType); + } + if (!nullToAbsent || issuerId != null) { + map['issuer_id'] = Variable(issuerId); + } + map['create_time'] = Variable(createTime); + if (!nullToAbsent || expireTime != null) { + map['expire_time'] = Variable(expireTime); + } + if (!nullToAbsent || lastUseTime != null) { + map['last_use_time'] = Variable(lastUseTime); + } + return map; + } + + CloudAuthCorksCompanion toCompanion(bool nullToAbsent) { + return CloudAuthCorksCompanion( + corkId: Value(corkId), + cryptoKeyId: Value(cryptoKeyId), + bearerType: + bearerType == null && nullToAbsent + ? const Value.absent() + : Value(bearerType), + bearerId: + bearerId == null && nullToAbsent + ? const Value.absent() + : Value(bearerId), + audienceType: + audienceType == null && nullToAbsent + ? const Value.absent() + : Value(audienceType), + audienceId: + audienceId == null && nullToAbsent + ? const Value.absent() + : Value(audienceId), + issuerType: + issuerType == null && nullToAbsent + ? const Value.absent() + : Value(issuerType), + issuerId: + issuerId == null && nullToAbsent + ? const Value.absent() + : Value(issuerId), + createTime: Value(createTime), + expireTime: + expireTime == null && nullToAbsent + ? const Value.absent() + : Value(expireTime), + lastUseTime: + lastUseTime == null && nullToAbsent + ? const Value.absent() + : Value(lastUseTime), + ); + } + + factory CloudAuthCorksData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return CloudAuthCorksData( + corkId: serializer.fromJson(json['corkId']), + cryptoKeyId: serializer.fromJson(json['cryptoKeyId']), + bearerType: serializer.fromJson(json['bearerType']), + bearerId: serializer.fromJson(json['bearerId']), + audienceType: serializer.fromJson(json['audienceType']), + audienceId: serializer.fromJson(json['audienceId']), + issuerType: serializer.fromJson(json['issuerType']), + issuerId: serializer.fromJson(json['issuerId']), + createTime: serializer.fromJson(json['createTime']), + expireTime: serializer.fromJson(json['expireTime']), + lastUseTime: serializer.fromJson(json['lastUseTime']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'corkId': serializer.toJson(corkId), + 'cryptoKeyId': serializer.toJson(cryptoKeyId), + 'bearerType': serializer.toJson(bearerType), + 'bearerId': serializer.toJson(bearerId), + 'audienceType': serializer.toJson(audienceType), + 'audienceId': serializer.toJson(audienceId), + 'issuerType': serializer.toJson(issuerType), + 'issuerId': serializer.toJson(issuerId), + 'createTime': serializer.toJson(createTime), + 'expireTime': serializer.toJson(expireTime), + 'lastUseTime': serializer.toJson(lastUseTime), + }; + } + + CloudAuthCorksData copyWith({ + Uint8List? corkId, + Uint8List? cryptoKeyId, + Value bearerType = const Value.absent(), + Value bearerId = const Value.absent(), + Value audienceType = const Value.absent(), + Value audienceId = const Value.absent(), + Value issuerType = const Value.absent(), + Value issuerId = const Value.absent(), + double? createTime, + Value expireTime = const Value.absent(), + Value lastUseTime = const Value.absent(), + }) => CloudAuthCorksData( + corkId: corkId ?? this.corkId, + cryptoKeyId: cryptoKeyId ?? this.cryptoKeyId, + bearerType: bearerType.present ? bearerType.value : this.bearerType, + bearerId: bearerId.present ? bearerId.value : this.bearerId, + audienceType: audienceType.present ? audienceType.value : this.audienceType, + audienceId: audienceId.present ? audienceId.value : this.audienceId, + issuerType: issuerType.present ? issuerType.value : this.issuerType, + issuerId: issuerId.present ? issuerId.value : this.issuerId, + createTime: createTime ?? this.createTime, + expireTime: expireTime.present ? expireTime.value : this.expireTime, + lastUseTime: lastUseTime.present ? lastUseTime.value : this.lastUseTime, + ); + CloudAuthCorksData copyWithCompanion(CloudAuthCorksCompanion data) { + return CloudAuthCorksData( + corkId: data.corkId.present ? data.corkId.value : this.corkId, + cryptoKeyId: + data.cryptoKeyId.present ? data.cryptoKeyId.value : this.cryptoKeyId, + bearerType: + data.bearerType.present ? data.bearerType.value : this.bearerType, + bearerId: data.bearerId.present ? data.bearerId.value : this.bearerId, + audienceType: + data.audienceType.present + ? data.audienceType.value + : this.audienceType, + audienceId: + data.audienceId.present ? data.audienceId.value : this.audienceId, + issuerType: + data.issuerType.present ? data.issuerType.value : this.issuerType, + issuerId: data.issuerId.present ? data.issuerId.value : this.issuerId, + createTime: + data.createTime.present ? data.createTime.value : this.createTime, + expireTime: + data.expireTime.present ? data.expireTime.value : this.expireTime, + lastUseTime: + data.lastUseTime.present ? data.lastUseTime.value : this.lastUseTime, + ); + } + + @override + String toString() { + return (StringBuffer('CloudAuthCorksData(') + ..write('corkId: $corkId, ') + ..write('cryptoKeyId: $cryptoKeyId, ') + ..write('bearerType: $bearerType, ') + ..write('bearerId: $bearerId, ') + ..write('audienceType: $audienceType, ') + ..write('audienceId: $audienceId, ') + ..write('issuerType: $issuerType, ') + ..write('issuerId: $issuerId, ') + ..write('createTime: $createTime, ') + ..write('expireTime: $expireTime, ') + ..write('lastUseTime: $lastUseTime') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + $driftBlobEquality.hash(corkId), + $driftBlobEquality.hash(cryptoKeyId), + bearerType, + bearerId, + audienceType, + audienceId, + issuerType, + issuerId, + createTime, + expireTime, + lastUseTime, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is CloudAuthCorksData && + $driftBlobEquality.equals(other.corkId, this.corkId) && + $driftBlobEquality.equals(other.cryptoKeyId, this.cryptoKeyId) && + other.bearerType == this.bearerType && + other.bearerId == this.bearerId && + other.audienceType == this.audienceType && + other.audienceId == this.audienceId && + other.issuerType == this.issuerType && + other.issuerId == this.issuerId && + other.createTime == this.createTime && + other.expireTime == this.expireTime && + other.lastUseTime == this.lastUseTime); +} + +class CloudAuthCorksCompanion extends UpdateCompanion { + final Value corkId; + final Value cryptoKeyId; + final Value bearerType; + final Value bearerId; + final Value audienceType; + final Value audienceId; + final Value issuerType; + final Value issuerId; + final Value createTime; + final Value expireTime; + final Value lastUseTime; + final Value rowid; + const CloudAuthCorksCompanion({ + this.corkId = const Value.absent(), + this.cryptoKeyId = const Value.absent(), + this.bearerType = const Value.absent(), + this.bearerId = const Value.absent(), + this.audienceType = const Value.absent(), + this.audienceId = const Value.absent(), + this.issuerType = const Value.absent(), + this.issuerId = const Value.absent(), + this.createTime = const Value.absent(), + this.expireTime = const Value.absent(), + this.lastUseTime = const Value.absent(), + this.rowid = const Value.absent(), + }); + CloudAuthCorksCompanion.insert({ + required Uint8List corkId, + required Uint8List cryptoKeyId, + this.bearerType = const Value.absent(), + this.bearerId = const Value.absent(), + this.audienceType = const Value.absent(), + this.audienceId = const Value.absent(), + this.issuerType = const Value.absent(), + this.issuerId = const Value.absent(), + this.createTime = const Value.absent(), + this.expireTime = const Value.absent(), + this.lastUseTime = const Value.absent(), + this.rowid = const Value.absent(), + }) : corkId = Value(corkId), + cryptoKeyId = Value(cryptoKeyId); + static Insertable custom({ + Expression? corkId, + Expression? cryptoKeyId, + Expression? bearerType, + Expression? bearerId, + Expression? audienceType, + Expression? audienceId, + Expression? issuerType, + Expression? issuerId, + Expression? createTime, + Expression? expireTime, + Expression? lastUseTime, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (corkId != null) 'cork_id': corkId, + if (cryptoKeyId != null) 'crypto_key_id': cryptoKeyId, + if (bearerType != null) 'bearer_type': bearerType, + if (bearerId != null) 'bearer_id': bearerId, + if (audienceType != null) 'audience_type': audienceType, + if (audienceId != null) 'audience_id': audienceId, + if (issuerType != null) 'issuer_type': issuerType, + if (issuerId != null) 'issuer_id': issuerId, + if (createTime != null) 'create_time': createTime, + if (expireTime != null) 'expire_time': expireTime, + if (lastUseTime != null) 'last_use_time': lastUseTime, + if (rowid != null) 'rowid': rowid, + }); + } + + CloudAuthCorksCompanion copyWith({ + Value? corkId, + Value? cryptoKeyId, + Value? bearerType, + Value? bearerId, + Value? audienceType, + Value? audienceId, + Value? issuerType, + Value? issuerId, + Value? createTime, + Value? expireTime, + Value? lastUseTime, + Value? rowid, + }) { + return CloudAuthCorksCompanion( + corkId: corkId ?? this.corkId, + cryptoKeyId: cryptoKeyId ?? this.cryptoKeyId, + bearerType: bearerType ?? this.bearerType, + bearerId: bearerId ?? this.bearerId, + audienceType: audienceType ?? this.audienceType, + audienceId: audienceId ?? this.audienceId, + issuerType: issuerType ?? this.issuerType, + issuerId: issuerId ?? this.issuerId, + createTime: createTime ?? this.createTime, + expireTime: expireTime ?? this.expireTime, + lastUseTime: lastUseTime ?? this.lastUseTime, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (corkId.present) { + map['cork_id'] = Variable(corkId.value); + } + if (cryptoKeyId.present) { + map['crypto_key_id'] = Variable(cryptoKeyId.value); + } + if (bearerType.present) { + map['bearer_type'] = Variable(bearerType.value); + } + if (bearerId.present) { + map['bearer_id'] = Variable(bearerId.value); + } + if (audienceType.present) { + map['audience_type'] = Variable(audienceType.value); + } + if (audienceId.present) { + map['audience_id'] = Variable(audienceId.value); + } + if (issuerType.present) { + map['issuer_type'] = Variable(issuerType.value); + } + if (issuerId.present) { + map['issuer_id'] = Variable(issuerId.value); + } + if (createTime.present) { + map['create_time'] = Variable(createTime.value); + } + if (expireTime.present) { + map['expire_time'] = Variable(expireTime.value); + } + if (lastUseTime.present) { + map['last_use_time'] = Variable(lastUseTime.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('CloudAuthCorksCompanion(') + ..write('corkId: $corkId, ') + ..write('cryptoKeyId: $cryptoKeyId, ') + ..write('bearerType: $bearerType, ') + ..write('bearerId: $bearerId, ') + ..write('audienceType: $audienceType, ') + ..write('audienceId: $audienceId, ') + ..write('issuerType: $issuerType, ') + ..write('issuerId: $issuerId, ') + ..write('createTime: $createTime, ') + ..write('expireTime: $expireTime, ') + ..write('lastUseTime: $lastUseTime, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +class CedarPolicies extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + CedarPolicies(this.attachedDatabase, [this._alias]); + late final GeneratedColumn id = GeneratedColumn( + 'id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); + late final GeneratedColumn policyId = GeneratedColumn( + 'policy_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL UNIQUE', + ); + late final GeneratedColumn policy = GeneratedColumn( + 'policy', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn enforcementLevel = GeneratedColumn( + 'enforcement_level', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT 1', + defaultValue: const CustomExpression('1'), + ); + @override + List get $columns => [ + id, + policyId, + policy, + enforcementLevel, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'cedar_policies'; + @override + Set get $primaryKey => {id}; + @override + CedarPoliciesData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return CedarPoliciesData( + id: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}id'], + )!, + policyId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}policy_id'], + )!, + policy: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}policy'], + )!, + enforcementLevel: + attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}enforcement_level'], + )!, + ); + } + + @override + CedarPolicies createAlias(String alias) { + return CedarPolicies(attachedDatabase, alias); + } + + @override + List get customConstraints => const [ + 'CHECK(enforcement_level IN (0, 1))', + ]; + @override + bool get dontWriteConstraints => true; +} + +class CedarPoliciesData extends DataClass + implements Insertable { + final String id; + final String policyId; + final String policy; + final int enforcementLevel; + const CedarPoliciesData({ + required this.id, + required this.policyId, + required this.policy, + required this.enforcementLevel, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['policy_id'] = Variable(policyId); + map['policy'] = Variable(policy); + map['enforcement_level'] = Variable(enforcementLevel); + return map; + } + + CedarPoliciesCompanion toCompanion(bool nullToAbsent) { + return CedarPoliciesCompanion( + id: Value(id), + policyId: Value(policyId), + policy: Value(policy), + enforcementLevel: Value(enforcementLevel), + ); + } + + factory CedarPoliciesData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return CedarPoliciesData( + id: serializer.fromJson(json['id']), + policyId: serializer.fromJson(json['policyId']), + policy: serializer.fromJson(json['policy']), + enforcementLevel: serializer.fromJson(json['enforcementLevel']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'policyId': serializer.toJson(policyId), + 'policy': serializer.toJson(policy), + 'enforcementLevel': serializer.toJson(enforcementLevel), + }; + } + + CedarPoliciesData copyWith({ + String? id, + String? policyId, + String? policy, + int? enforcementLevel, + }) => CedarPoliciesData( + id: id ?? this.id, + policyId: policyId ?? this.policyId, + policy: policy ?? this.policy, + enforcementLevel: enforcementLevel ?? this.enforcementLevel, + ); + CedarPoliciesData copyWithCompanion(CedarPoliciesCompanion data) { + return CedarPoliciesData( + id: data.id.present ? data.id.value : this.id, + policyId: data.policyId.present ? data.policyId.value : this.policyId, + policy: data.policy.present ? data.policy.value : this.policy, + enforcementLevel: + data.enforcementLevel.present + ? data.enforcementLevel.value + : this.enforcementLevel, + ); + } + + @override + String toString() { + return (StringBuffer('CedarPoliciesData(') + ..write('id: $id, ') + ..write('policyId: $policyId, ') + ..write('policy: $policy, ') + ..write('enforcementLevel: $enforcementLevel') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(id, policyId, policy, enforcementLevel); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is CedarPoliciesData && + other.id == this.id && + other.policyId == this.policyId && + other.policy == this.policy && + other.enforcementLevel == this.enforcementLevel); +} + +class CedarPoliciesCompanion extends UpdateCompanion { + final Value id; + final Value policyId; + final Value policy; + final Value enforcementLevel; + final Value rowid; + const CedarPoliciesCompanion({ + this.id = const Value.absent(), + this.policyId = const Value.absent(), + this.policy = const Value.absent(), + this.enforcementLevel = const Value.absent(), + this.rowid = const Value.absent(), + }); + CedarPoliciesCompanion.insert({ + required String id, + required String policyId, + required String policy, + this.enforcementLevel = const Value.absent(), + this.rowid = const Value.absent(), + }) : id = Value(id), + policyId = Value(policyId), + policy = Value(policy); + static Insertable custom({ + Expression? id, + Expression? policyId, + Expression? policy, + Expression? enforcementLevel, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (policyId != null) 'policy_id': policyId, + if (policy != null) 'policy': policy, + if (enforcementLevel != null) 'enforcement_level': enforcementLevel, + if (rowid != null) 'rowid': rowid, + }); + } + + CedarPoliciesCompanion copyWith({ + Value? id, + Value? policyId, + Value? policy, + Value? enforcementLevel, + Value? rowid, + }) { + return CedarPoliciesCompanion( + id: id ?? this.id, + policyId: policyId ?? this.policyId, + policy: policy ?? this.policy, + enforcementLevel: enforcementLevel ?? this.enforcementLevel, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (policyId.present) { + map['policy_id'] = Variable(policyId.value); + } + if (policy.present) { + map['policy'] = Variable(policy.value); + } + if (enforcementLevel.present) { + map['enforcement_level'] = Variable(enforcementLevel.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('CedarPoliciesCompanion(') + ..write('id: $id, ') + ..write('policyId: $policyId, ') + ..write('policy: $policy, ') + ..write('enforcementLevel: $enforcementLevel, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +class CedarPolicyTemplates extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + CedarPolicyTemplates(this.attachedDatabase, [this._alias]); + late final GeneratedColumn id = GeneratedColumn( + 'id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); + late final GeneratedColumn templateId = GeneratedColumn( + 'template_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL UNIQUE', + ); + late final GeneratedColumn template = GeneratedColumn( + 'template', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + @override + List get $columns => [id, templateId, template]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'cedar_policy_templates'; + @override + Set get $primaryKey => {id}; + @override + CedarPolicyTemplatesData map( + Map data, { + String? tablePrefix, + }) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return CedarPolicyTemplatesData( + id: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}id'], + )!, + templateId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}template_id'], + )!, + template: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}template'], + )!, + ); + } + + @override + CedarPolicyTemplates createAlias(String alias) { + return CedarPolicyTemplates(attachedDatabase, alias); + } + + @override + List get customConstraints => const [ + 'CHECK(template IS NOT NULL OR template IS NOT NULL)', + ]; + @override + bool get dontWriteConstraints => true; +} + +class CedarPolicyTemplatesData extends DataClass + implements Insertable { + final String id; + final String templateId; + final String template; + const CedarPolicyTemplatesData({ + required this.id, + required this.templateId, + required this.template, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['template_id'] = Variable(templateId); + map['template'] = Variable(template); + return map; + } + + CedarPolicyTemplatesCompanion toCompanion(bool nullToAbsent) { + return CedarPolicyTemplatesCompanion( + id: Value(id), + templateId: Value(templateId), + template: Value(template), + ); + } + + factory CedarPolicyTemplatesData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return CedarPolicyTemplatesData( + id: serializer.fromJson(json['id']), + templateId: serializer.fromJson(json['templateId']), + template: serializer.fromJson(json['template']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'templateId': serializer.toJson(templateId), + 'template': serializer.toJson(template), + }; + } + + CedarPolicyTemplatesData copyWith({ + String? id, + String? templateId, + String? template, + }) => CedarPolicyTemplatesData( + id: id ?? this.id, + templateId: templateId ?? this.templateId, + template: template ?? this.template, + ); + CedarPolicyTemplatesData copyWithCompanion( + CedarPolicyTemplatesCompanion data, + ) { + return CedarPolicyTemplatesData( + id: data.id.present ? data.id.value : this.id, + templateId: + data.templateId.present ? data.templateId.value : this.templateId, + template: data.template.present ? data.template.value : this.template, + ); + } + + @override + String toString() { + return (StringBuffer('CedarPolicyTemplatesData(') + ..write('id: $id, ') + ..write('templateId: $templateId, ') + ..write('template: $template') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(id, templateId, template); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is CedarPolicyTemplatesData && + other.id == this.id && + other.templateId == this.templateId && + other.template == this.template); +} + +class CedarPolicyTemplatesCompanion + extends UpdateCompanion { + final Value id; + final Value templateId; + final Value template; + final Value rowid; + const CedarPolicyTemplatesCompanion({ + this.id = const Value.absent(), + this.templateId = const Value.absent(), + this.template = const Value.absent(), + this.rowid = const Value.absent(), + }); + CedarPolicyTemplatesCompanion.insert({ + required String id, + required String templateId, + required String template, + this.rowid = const Value.absent(), + }) : id = Value(id), + templateId = Value(templateId), + template = Value(template); + static Insertable custom({ + Expression? id, + Expression? templateId, + Expression? template, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (templateId != null) 'template_id': templateId, + if (template != null) 'template': template, + if (rowid != null) 'rowid': rowid, + }); + } + + CedarPolicyTemplatesCompanion copyWith({ + Value? id, + Value? templateId, + Value? template, + Value? rowid, + }) { + return CedarPolicyTemplatesCompanion( + id: id ?? this.id, + templateId: templateId ?? this.templateId, + template: template ?? this.template, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (templateId.present) { + map['template_id'] = Variable(templateId.value); + } + if (template.present) { + map['template'] = Variable(template.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('CedarPolicyTemplatesCompanion(') + ..write('id: $id, ') + ..write('templateId: $templateId, ') + ..write('template: $template, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +class CedarPolicyTemplateLinks extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + CedarPolicyTemplateLinks(this.attachedDatabase, [this._alias]); + late final GeneratedColumn id = GeneratedColumn( + 'id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); + late final GeneratedColumn policyId = GeneratedColumn( + 'policy_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL UNIQUE', + ); + late final GeneratedColumn templateId = GeneratedColumn( + 'template_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn principalType = GeneratedColumn( + 'principal_type', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn principalId = GeneratedColumn( + 'principal_id', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn resourceType = GeneratedColumn( + 'resource_type', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn resourceId = GeneratedColumn( + 'resource_id', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn enforcementLevel = GeneratedColumn( + 'enforcement_level', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT 1', + defaultValue: const CustomExpression('1'), + ); + @override + List get $columns => [ + id, + policyId, + templateId, + principalType, + principalId, + resourceType, + resourceId, + enforcementLevel, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'cedar_policy_template_links'; + @override + Set get $primaryKey => {id}; + @override + CedarPolicyTemplateLinksData map( + Map data, { + String? tablePrefix, + }) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return CedarPolicyTemplateLinksData( + id: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}id'], + )!, + policyId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}policy_id'], + )!, + templateId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}template_id'], + )!, + principalType: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}principal_type'], + ), + principalId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}principal_id'], + ), + resourceType: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}resource_type'], + ), + resourceId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}resource_id'], + ), + enforcementLevel: + attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}enforcement_level'], + )!, + ); + } + + @override + CedarPolicyTemplateLinks createAlias(String alias) { + return CedarPolicyTemplateLinks(attachedDatabase, alias); + } + + @override + List get customConstraints => const [ + 'CHECK(principal_type IS NOT NULL AND principal_id IS NOT NULL OR resource_type IS NOT NULL AND resource_id IS NOT NULL)', + 'CHECK(enforcement_level IN (0, 1))', + 'CONSTRAINT cedar_policy_template_links_fk_template_id FOREIGN KEY(template_id)REFERENCES cedar_policy_templates(template_id)ON UPDATE CASCADE ON DELETE CASCADE', + 'CONSTRAINT cedar_policy_template_links_fk_principal FOREIGN KEY(principal_type, principal_id)REFERENCES cedar_entities(entity_type, entity_id)ON DELETE CASCADE', + 'CONSTRAINT cedar_policy_template_links_fk_resource FOREIGN KEY(resource_type, resource_id)REFERENCES cedar_entities(entity_type, entity_id)ON DELETE CASCADE', + ]; + @override + bool get dontWriteConstraints => true; +} + +class CedarPolicyTemplateLinksData extends DataClass + implements Insertable { + final String id; + final String policyId; + final String templateId; + final String? principalType; + final String? principalId; + final String? resourceType; + final String? resourceId; + final int enforcementLevel; + const CedarPolicyTemplateLinksData({ + required this.id, + required this.policyId, + required this.templateId, + this.principalType, + this.principalId, + this.resourceType, + this.resourceId, + required this.enforcementLevel, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['policy_id'] = Variable(policyId); + map['template_id'] = Variable(templateId); + if (!nullToAbsent || principalType != null) { + map['principal_type'] = Variable(principalType); + } + if (!nullToAbsent || principalId != null) { + map['principal_id'] = Variable(principalId); + } + if (!nullToAbsent || resourceType != null) { + map['resource_type'] = Variable(resourceType); + } + if (!nullToAbsent || resourceId != null) { + map['resource_id'] = Variable(resourceId); + } + map['enforcement_level'] = Variable(enforcementLevel); + return map; + } + + CedarPolicyTemplateLinksCompanion toCompanion(bool nullToAbsent) { + return CedarPolicyTemplateLinksCompanion( + id: Value(id), + policyId: Value(policyId), + templateId: Value(templateId), + principalType: + principalType == null && nullToAbsent + ? const Value.absent() + : Value(principalType), + principalId: + principalId == null && nullToAbsent + ? const Value.absent() + : Value(principalId), + resourceType: + resourceType == null && nullToAbsent + ? const Value.absent() + : Value(resourceType), + resourceId: + resourceId == null && nullToAbsent + ? const Value.absent() + : Value(resourceId), + enforcementLevel: Value(enforcementLevel), + ); + } + + factory CedarPolicyTemplateLinksData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return CedarPolicyTemplateLinksData( + id: serializer.fromJson(json['id']), + policyId: serializer.fromJson(json['policyId']), + templateId: serializer.fromJson(json['templateId']), + principalType: serializer.fromJson(json['principalType']), + principalId: serializer.fromJson(json['principalId']), + resourceType: serializer.fromJson(json['resourceType']), + resourceId: serializer.fromJson(json['resourceId']), + enforcementLevel: serializer.fromJson(json['enforcementLevel']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'policyId': serializer.toJson(policyId), + 'templateId': serializer.toJson(templateId), + 'principalType': serializer.toJson(principalType), + 'principalId': serializer.toJson(principalId), + 'resourceType': serializer.toJson(resourceType), + 'resourceId': serializer.toJson(resourceId), + 'enforcementLevel': serializer.toJson(enforcementLevel), + }; + } + + CedarPolicyTemplateLinksData copyWith({ + String? id, + String? policyId, + String? templateId, + Value principalType = const Value.absent(), + Value principalId = const Value.absent(), + Value resourceType = const Value.absent(), + Value resourceId = const Value.absent(), + int? enforcementLevel, + }) => CedarPolicyTemplateLinksData( + id: id ?? this.id, + policyId: policyId ?? this.policyId, + templateId: templateId ?? this.templateId, + principalType: + principalType.present ? principalType.value : this.principalType, + principalId: principalId.present ? principalId.value : this.principalId, + resourceType: resourceType.present ? resourceType.value : this.resourceType, + resourceId: resourceId.present ? resourceId.value : this.resourceId, + enforcementLevel: enforcementLevel ?? this.enforcementLevel, + ); + CedarPolicyTemplateLinksData copyWithCompanion( + CedarPolicyTemplateLinksCompanion data, + ) { + return CedarPolicyTemplateLinksData( + id: data.id.present ? data.id.value : this.id, + policyId: data.policyId.present ? data.policyId.value : this.policyId, + templateId: + data.templateId.present ? data.templateId.value : this.templateId, + principalType: + data.principalType.present + ? data.principalType.value + : this.principalType, + principalId: + data.principalId.present ? data.principalId.value : this.principalId, + resourceType: + data.resourceType.present + ? data.resourceType.value + : this.resourceType, + resourceId: + data.resourceId.present ? data.resourceId.value : this.resourceId, + enforcementLevel: + data.enforcementLevel.present + ? data.enforcementLevel.value + : this.enforcementLevel, + ); + } + + @override + String toString() { + return (StringBuffer('CedarPolicyTemplateLinksData(') + ..write('id: $id, ') + ..write('policyId: $policyId, ') + ..write('templateId: $templateId, ') + ..write('principalType: $principalType, ') + ..write('principalId: $principalId, ') + ..write('resourceType: $resourceType, ') + ..write('resourceId: $resourceId, ') + ..write('enforcementLevel: $enforcementLevel') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + id, + policyId, + templateId, + principalType, + principalId, + resourceType, + resourceId, + enforcementLevel, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is CedarPolicyTemplateLinksData && + other.id == this.id && + other.policyId == this.policyId && + other.templateId == this.templateId && + other.principalType == this.principalType && + other.principalId == this.principalId && + other.resourceType == this.resourceType && + other.resourceId == this.resourceId && + other.enforcementLevel == this.enforcementLevel); +} + +class CedarPolicyTemplateLinksCompanion + extends UpdateCompanion { + final Value id; + final Value policyId; + final Value templateId; + final Value principalType; + final Value principalId; + final Value resourceType; + final Value resourceId; + final Value enforcementLevel; + final Value rowid; + const CedarPolicyTemplateLinksCompanion({ + this.id = const Value.absent(), + this.policyId = const Value.absent(), + this.templateId = const Value.absent(), + this.principalType = const Value.absent(), + this.principalId = const Value.absent(), + this.resourceType = const Value.absent(), + this.resourceId = const Value.absent(), + this.enforcementLevel = const Value.absent(), + this.rowid = const Value.absent(), + }); + CedarPolicyTemplateLinksCompanion.insert({ + required String id, + required String policyId, + required String templateId, + this.principalType = const Value.absent(), + this.principalId = const Value.absent(), + this.resourceType = const Value.absent(), + this.resourceId = const Value.absent(), + this.enforcementLevel = const Value.absent(), + this.rowid = const Value.absent(), + }) : id = Value(id), + policyId = Value(policyId), + templateId = Value(templateId); + static Insertable custom({ + Expression? id, + Expression? policyId, + Expression? templateId, + Expression? principalType, + Expression? principalId, + Expression? resourceType, + Expression? resourceId, + Expression? enforcementLevel, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (policyId != null) 'policy_id': policyId, + if (templateId != null) 'template_id': templateId, + if (principalType != null) 'principal_type': principalType, + if (principalId != null) 'principal_id': principalId, + if (resourceType != null) 'resource_type': resourceType, + if (resourceId != null) 'resource_id': resourceId, + if (enforcementLevel != null) 'enforcement_level': enforcementLevel, + if (rowid != null) 'rowid': rowid, + }); + } + + CedarPolicyTemplateLinksCompanion copyWith({ + Value? id, + Value? policyId, + Value? templateId, + Value? principalType, + Value? principalId, + Value? resourceType, + Value? resourceId, + Value? enforcementLevel, + Value? rowid, + }) { + return CedarPolicyTemplateLinksCompanion( + id: id ?? this.id, + policyId: policyId ?? this.policyId, + templateId: templateId ?? this.templateId, + principalType: principalType ?? this.principalType, + principalId: principalId ?? this.principalId, + resourceType: resourceType ?? this.resourceType, + resourceId: resourceId ?? this.resourceId, + enforcementLevel: enforcementLevel ?? this.enforcementLevel, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (policyId.present) { + map['policy_id'] = Variable(policyId.value); + } + if (templateId.present) { + map['template_id'] = Variable(templateId.value); + } + if (principalType.present) { + map['principal_type'] = Variable(principalType.value); + } + if (principalId.present) { + map['principal_id'] = Variable(principalId.value); + } + if (resourceType.present) { + map['resource_type'] = Variable(resourceType.value); + } + if (resourceId.present) { + map['resource_id'] = Variable(resourceId.value); + } + if (enforcementLevel.present) { + map['enforcement_level'] = Variable(enforcementLevel.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('CedarPolicyTemplateLinksCompanion(') + ..write('id: $id, ') + ..write('policyId: $policyId, ') + ..write('templateId: $templateId, ') + ..write('principalType: $principalType, ') + ..write('principalId: $principalId, ') + ..write('resourceType: $resourceType, ') + ..write('resourceId: $resourceId, ') + ..write('enforcementLevel: $enforcementLevel, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +class CedarAuthorizationLogs extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + CedarAuthorizationLogs(this.attachedDatabase, [this._alias]); + late final GeneratedColumn rowid = GeneratedColumn( + 'rowid', + aliasedName, + false, + hasAutoIncrement: true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'PRIMARY KEY AUTOINCREMENT', + ); + late final GeneratedColumn createTime = GeneratedColumn( + 'create_time', + aliasedName, + false, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT (unixepoch(\'now\', \'subsec\'))', + defaultValue: const CustomExpression('unixepoch(\'now\', \'subsec\')'), + ); + late final GeneratedColumn expireTime = GeneratedColumn( + 'expire_time', + aliasedName, + true, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn principalType = GeneratedColumn( + 'principal_type', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn principalId = GeneratedColumn( + 'principal_id', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn actionType = GeneratedColumn( + 'action_type', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn actionId = GeneratedColumn( + 'action_id', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn resourceType = GeneratedColumn( + 'resource_type', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn resourceId = GeneratedColumn( + 'resource_id', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn contextJson = GeneratedColumn( + 'context_json', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT \'{}\'', + defaultValue: const CustomExpression('\'{}\''), + ); + late final GeneratedColumn decision = GeneratedColumn( + 'decision', + aliasedName, + false, + type: DriftSqlType.bool, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn reasonsJson = GeneratedColumn( + 'reasons_json', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT \'[]\'', + defaultValue: const CustomExpression('\'[]\''), + ); + late final GeneratedColumn errorsJson = GeneratedColumn( + 'errors_json', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT \'[]\'', + defaultValue: const CustomExpression('\'[]\''), + ); + @override + List get $columns => [ + rowid, + createTime, + expireTime, + principalType, + principalId, + actionType, + actionId, + resourceType, + resourceId, + contextJson, + decision, + reasonsJson, + errorsJson, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'cedar_authorization_logs'; + @override + Set get $primaryKey => {rowid}; + @override + CedarAuthorizationLogsData map( + Map data, { + String? tablePrefix, + }) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return CedarAuthorizationLogsData( + rowid: + attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}rowid'], + )!, + createTime: + attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}create_time'], + )!, + expireTime: attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}expire_time'], + ), + principalType: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}principal_type'], + ), + principalId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}principal_id'], + ), + actionType: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}action_type'], + ), + actionId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}action_id'], + ), + resourceType: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}resource_type'], + ), + resourceId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}resource_id'], + ), + contextJson: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}context_json'], + )!, + decision: + attachedDatabase.typeMapping.read( + DriftSqlType.bool, + data['${effectivePrefix}decision'], + )!, + reasonsJson: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}reasons_json'], + )!, + errorsJson: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}errors_json'], + )!, + ); + } + + @override + CedarAuthorizationLogs createAlias(String alias) { + return CedarAuthorizationLogs(attachedDatabase, alias); + } + + @override + bool get dontWriteConstraints => true; +} + +class CedarAuthorizationLogsData extends DataClass + implements Insertable { + final int rowid; + final DateTime createTime; + final DateTime? expireTime; + final String? principalType; + final String? principalId; + final String? actionType; + final String? actionId; + final String? resourceType; + final String? resourceId; + final String contextJson; + final bool decision; + final String reasonsJson; + final String errorsJson; + const CedarAuthorizationLogsData({ + required this.rowid, + required this.createTime, + this.expireTime, + this.principalType, + this.principalId, + this.actionType, + this.actionId, + this.resourceType, + this.resourceId, + required this.contextJson, + required this.decision, + required this.reasonsJson, + required this.errorsJson, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['rowid'] = Variable(rowid); + map['create_time'] = Variable(createTime); + if (!nullToAbsent || expireTime != null) { + map['expire_time'] = Variable(expireTime); + } + if (!nullToAbsent || principalType != null) { + map['principal_type'] = Variable(principalType); + } + if (!nullToAbsent || principalId != null) { + map['principal_id'] = Variable(principalId); + } + if (!nullToAbsent || actionType != null) { + map['action_type'] = Variable(actionType); + } + if (!nullToAbsent || actionId != null) { + map['action_id'] = Variable(actionId); + } + if (!nullToAbsent || resourceType != null) { + map['resource_type'] = Variable(resourceType); + } + if (!nullToAbsent || resourceId != null) { + map['resource_id'] = Variable(resourceId); + } + map['context_json'] = Variable(contextJson); + map['decision'] = Variable(decision); + map['reasons_json'] = Variable(reasonsJson); + map['errors_json'] = Variable(errorsJson); + return map; + } + + CedarAuthorizationLogsCompanion toCompanion(bool nullToAbsent) { + return CedarAuthorizationLogsCompanion( + rowid: Value(rowid), + createTime: Value(createTime), + expireTime: + expireTime == null && nullToAbsent + ? const Value.absent() + : Value(expireTime), + principalType: + principalType == null && nullToAbsent + ? const Value.absent() + : Value(principalType), + principalId: + principalId == null && nullToAbsent + ? const Value.absent() + : Value(principalId), + actionType: + actionType == null && nullToAbsent + ? const Value.absent() + : Value(actionType), + actionId: + actionId == null && nullToAbsent + ? const Value.absent() + : Value(actionId), + resourceType: + resourceType == null && nullToAbsent + ? const Value.absent() + : Value(resourceType), + resourceId: + resourceId == null && nullToAbsent + ? const Value.absent() + : Value(resourceId), + contextJson: Value(contextJson), + decision: Value(decision), + reasonsJson: Value(reasonsJson), + errorsJson: Value(errorsJson), + ); + } + + factory CedarAuthorizationLogsData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return CedarAuthorizationLogsData( + rowid: serializer.fromJson(json['rowid']), + createTime: serializer.fromJson(json['createTime']), + expireTime: serializer.fromJson(json['expireTime']), + principalType: serializer.fromJson(json['principalType']), + principalId: serializer.fromJson(json['principalId']), + actionType: serializer.fromJson(json['actionType']), + actionId: serializer.fromJson(json['actionId']), + resourceType: serializer.fromJson(json['resourceType']), + resourceId: serializer.fromJson(json['resourceId']), + contextJson: serializer.fromJson(json['contextJson']), + decision: serializer.fromJson(json['decision']), + reasonsJson: serializer.fromJson(json['reasonsJson']), + errorsJson: serializer.fromJson(json['errorsJson']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'rowid': serializer.toJson(rowid), + 'createTime': serializer.toJson(createTime), + 'expireTime': serializer.toJson(expireTime), + 'principalType': serializer.toJson(principalType), + 'principalId': serializer.toJson(principalId), + 'actionType': serializer.toJson(actionType), + 'actionId': serializer.toJson(actionId), + 'resourceType': serializer.toJson(resourceType), + 'resourceId': serializer.toJson(resourceId), + 'contextJson': serializer.toJson(contextJson), + 'decision': serializer.toJson(decision), + 'reasonsJson': serializer.toJson(reasonsJson), + 'errorsJson': serializer.toJson(errorsJson), + }; + } + + CedarAuthorizationLogsData copyWith({ + int? rowid, + DateTime? createTime, + Value expireTime = const Value.absent(), + Value principalType = const Value.absent(), + Value principalId = const Value.absent(), + Value actionType = const Value.absent(), + Value actionId = const Value.absent(), + Value resourceType = const Value.absent(), + Value resourceId = const Value.absent(), + String? contextJson, + bool? decision, + String? reasonsJson, + String? errorsJson, + }) => CedarAuthorizationLogsData( + rowid: rowid ?? this.rowid, + createTime: createTime ?? this.createTime, + expireTime: expireTime.present ? expireTime.value : this.expireTime, + principalType: + principalType.present ? principalType.value : this.principalType, + principalId: principalId.present ? principalId.value : this.principalId, + actionType: actionType.present ? actionType.value : this.actionType, + actionId: actionId.present ? actionId.value : this.actionId, + resourceType: resourceType.present ? resourceType.value : this.resourceType, + resourceId: resourceId.present ? resourceId.value : this.resourceId, + contextJson: contextJson ?? this.contextJson, + decision: decision ?? this.decision, + reasonsJson: reasonsJson ?? this.reasonsJson, + errorsJson: errorsJson ?? this.errorsJson, + ); + CedarAuthorizationLogsData copyWithCompanion( + CedarAuthorizationLogsCompanion data, + ) { + return CedarAuthorizationLogsData( + rowid: data.rowid.present ? data.rowid.value : this.rowid, + createTime: + data.createTime.present ? data.createTime.value : this.createTime, + expireTime: + data.expireTime.present ? data.expireTime.value : this.expireTime, + principalType: + data.principalType.present + ? data.principalType.value + : this.principalType, + principalId: + data.principalId.present ? data.principalId.value : this.principalId, + actionType: + data.actionType.present ? data.actionType.value : this.actionType, + actionId: data.actionId.present ? data.actionId.value : this.actionId, + resourceType: + data.resourceType.present + ? data.resourceType.value + : this.resourceType, + resourceId: + data.resourceId.present ? data.resourceId.value : this.resourceId, + contextJson: + data.contextJson.present ? data.contextJson.value : this.contextJson, + decision: data.decision.present ? data.decision.value : this.decision, + reasonsJson: + data.reasonsJson.present ? data.reasonsJson.value : this.reasonsJson, + errorsJson: + data.errorsJson.present ? data.errorsJson.value : this.errorsJson, + ); + } + + @override + String toString() { + return (StringBuffer('CedarAuthorizationLogsData(') + ..write('rowid: $rowid, ') + ..write('createTime: $createTime, ') + ..write('expireTime: $expireTime, ') + ..write('principalType: $principalType, ') + ..write('principalId: $principalId, ') + ..write('actionType: $actionType, ') + ..write('actionId: $actionId, ') + ..write('resourceType: $resourceType, ') + ..write('resourceId: $resourceId, ') + ..write('contextJson: $contextJson, ') + ..write('decision: $decision, ') + ..write('reasonsJson: $reasonsJson, ') + ..write('errorsJson: $errorsJson') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + rowid, + createTime, + expireTime, + principalType, + principalId, + actionType, + actionId, + resourceType, + resourceId, + contextJson, + decision, + reasonsJson, + errorsJson, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is CedarAuthorizationLogsData && + other.rowid == this.rowid && + other.createTime == this.createTime && + other.expireTime == this.expireTime && + other.principalType == this.principalType && + other.principalId == this.principalId && + other.actionType == this.actionType && + other.actionId == this.actionId && + other.resourceType == this.resourceType && + other.resourceId == this.resourceId && + other.contextJson == this.contextJson && + other.decision == this.decision && + other.reasonsJson == this.reasonsJson && + other.errorsJson == this.errorsJson); +} + +class CedarAuthorizationLogsCompanion + extends UpdateCompanion { + final Value rowid; + final Value createTime; + final Value expireTime; + final Value principalType; + final Value principalId; + final Value actionType; + final Value actionId; + final Value resourceType; + final Value resourceId; + final Value contextJson; + final Value decision; + final Value reasonsJson; + final Value errorsJson; + const CedarAuthorizationLogsCompanion({ + this.rowid = const Value.absent(), + this.createTime = const Value.absent(), + this.expireTime = const Value.absent(), + this.principalType = const Value.absent(), + this.principalId = const Value.absent(), + this.actionType = const Value.absent(), + this.actionId = const Value.absent(), + this.resourceType = const Value.absent(), + this.resourceId = const Value.absent(), + this.contextJson = const Value.absent(), + this.decision = const Value.absent(), + this.reasonsJson = const Value.absent(), + this.errorsJson = const Value.absent(), + }); + CedarAuthorizationLogsCompanion.insert({ + this.rowid = const Value.absent(), + this.createTime = const Value.absent(), + this.expireTime = const Value.absent(), + this.principalType = const Value.absent(), + this.principalId = const Value.absent(), + this.actionType = const Value.absent(), + this.actionId = const Value.absent(), + this.resourceType = const Value.absent(), + this.resourceId = const Value.absent(), + this.contextJson = const Value.absent(), + required bool decision, + this.reasonsJson = const Value.absent(), + this.errorsJson = const Value.absent(), + }) : decision = Value(decision); + static Insertable custom({ + Expression? rowid, + Expression? createTime, + Expression? expireTime, + Expression? principalType, + Expression? principalId, + Expression? actionType, + Expression? actionId, + Expression? resourceType, + Expression? resourceId, + Expression? contextJson, + Expression? decision, + Expression? reasonsJson, + Expression? errorsJson, + }) { + return RawValuesInsertable({ + if (rowid != null) 'rowid': rowid, + if (createTime != null) 'create_time': createTime, + if (expireTime != null) 'expire_time': expireTime, + if (principalType != null) 'principal_type': principalType, + if (principalId != null) 'principal_id': principalId, + if (actionType != null) 'action_type': actionType, + if (actionId != null) 'action_id': actionId, + if (resourceType != null) 'resource_type': resourceType, + if (resourceId != null) 'resource_id': resourceId, + if (contextJson != null) 'context_json': contextJson, + if (decision != null) 'decision': decision, + if (reasonsJson != null) 'reasons_json': reasonsJson, + if (errorsJson != null) 'errors_json': errorsJson, + }); + } + + CedarAuthorizationLogsCompanion copyWith({ + Value? rowid, + Value? createTime, + Value? expireTime, + Value? principalType, + Value? principalId, + Value? actionType, + Value? actionId, + Value? resourceType, + Value? resourceId, + Value? contextJson, + Value? decision, + Value? reasonsJson, + Value? errorsJson, + }) { + return CedarAuthorizationLogsCompanion( + rowid: rowid ?? this.rowid, + createTime: createTime ?? this.createTime, + expireTime: expireTime ?? this.expireTime, + principalType: principalType ?? this.principalType, + principalId: principalId ?? this.principalId, + actionType: actionType ?? this.actionType, + actionId: actionId ?? this.actionId, + resourceType: resourceType ?? this.resourceType, + resourceId: resourceId ?? this.resourceId, + contextJson: contextJson ?? this.contextJson, + decision: decision ?? this.decision, + reasonsJson: reasonsJson ?? this.reasonsJson, + errorsJson: errorsJson ?? this.errorsJson, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + if (createTime.present) { + map['create_time'] = Variable(createTime.value); + } + if (expireTime.present) { + map['expire_time'] = Variable(expireTime.value); + } + if (principalType.present) { + map['principal_type'] = Variable(principalType.value); + } + if (principalId.present) { + map['principal_id'] = Variable(principalId.value); + } + if (actionType.present) { + map['action_type'] = Variable(actionType.value); + } + if (actionId.present) { + map['action_id'] = Variable(actionId.value); + } + if (resourceType.present) { + map['resource_type'] = Variable(resourceType.value); + } + if (resourceId.present) { + map['resource_id'] = Variable(resourceId.value); + } + if (contextJson.present) { + map['context_json'] = Variable(contextJson.value); + } + if (decision.present) { + map['decision'] = Variable(decision.value); + } + if (reasonsJson.present) { + map['reasons_json'] = Variable(reasonsJson.value); + } + if (errorsJson.present) { + map['errors_json'] = Variable(errorsJson.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('CedarAuthorizationLogsCompanion(') + ..write('rowid: $rowid, ') + ..write('createTime: $createTime, ') + ..write('expireTime: $expireTime, ') + ..write('principalType: $principalType, ') + ..write('principalId: $principalId, ') + ..write('actionType: $actionType, ') + ..write('actionId: $actionId, ') + ..write('resourceType: $resourceType, ') + ..write('resourceId: $resourceId, ') + ..write('contextJson: $contextJson, ') + ..write('decision: $decision, ') + ..write('reasonsJson: $reasonsJson, ') + ..write('errorsJson: $errorsJson') + ..write(')')) + .toString(); + } +} + +class UserMemberships extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + UserMemberships(this.attachedDatabase, [this._alias]); + late final GeneratedColumn membershipId = GeneratedColumn( + 'membership_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); + late final GeneratedColumn userId = GeneratedColumn( + 'user_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn parentType = GeneratedColumn( + 'parent_type', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn parentId = GeneratedColumn( + 'parent_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn role = GeneratedColumn( + 'role', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn createTime = GeneratedColumn( + 'create_time', + aliasedName, + false, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT (unixepoch(\'now\', \'subsec\'))', + defaultValue: const CustomExpression('unixepoch(\'now\', \'subsec\')'), + ); + late final GeneratedColumn updateTime = GeneratedColumn( + 'update_time', + aliasedName, + false, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT (unixepoch(\'now\', \'subsec\'))', + defaultValue: const CustomExpression('unixepoch(\'now\', \'subsec\')'), + ); + @override + List get $columns => [ + membershipId, + userId, + parentType, + parentId, + role, + createTime, + updateTime, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'user_memberships'; + @override + Set get $primaryKey => {membershipId}; + @override + UserMembershipsData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return UserMembershipsData( + membershipId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}membership_id'], + )!, + userId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}user_id'], + )!, + parentType: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}parent_type'], + )!, + parentId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}parent_id'], + )!, + role: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}role'], + )!, + createTime: + attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}create_time'], + )!, + updateTime: + attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}update_time'], + )!, + ); + } + + @override + UserMemberships createAlias(String alias) { + return UserMemberships(attachedDatabase, alias); + } + + @override + List get customConstraints => const [ + 'CHECK(parent_type = \'Celest::Organization\' OR parent_type = \'Celest::Project\' OR parent_type = \'Celest::Project::Environment\')', + 'CONSTRAINT user_memberships_parent_fk FOREIGN KEY(parent_type, parent_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED', + ]; + @override + bool get dontWriteConstraints => true; +} + +class UserMembershipsData extends DataClass + implements Insertable { + final String membershipId; + final String userId; + final String parentType; + final String parentId; + final String role; + final DateTime createTime; + final DateTime updateTime; + const UserMembershipsData({ + required this.membershipId, + required this.userId, + required this.parentType, + required this.parentId, + required this.role, + required this.createTime, + required this.updateTime, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['membership_id'] = Variable(membershipId); + map['user_id'] = Variable(userId); + map['parent_type'] = Variable(parentType); + map['parent_id'] = Variable(parentId); + map['role'] = Variable(role); + map['create_time'] = Variable(createTime); + map['update_time'] = Variable(updateTime); + return map; + } + + UserMembershipsCompanion toCompanion(bool nullToAbsent) { + return UserMembershipsCompanion( + membershipId: Value(membershipId), + userId: Value(userId), + parentType: Value(parentType), + parentId: Value(parentId), + role: Value(role), + createTime: Value(createTime), + updateTime: Value(updateTime), + ); + } + + factory UserMembershipsData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return UserMembershipsData( + membershipId: serializer.fromJson(json['membershipId']), + userId: serializer.fromJson(json['userId']), + parentType: serializer.fromJson(json['parentType']), + parentId: serializer.fromJson(json['parentId']), + role: serializer.fromJson(json['role']), + createTime: serializer.fromJson(json['createTime']), + updateTime: serializer.fromJson(json['updateTime']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'membershipId': serializer.toJson(membershipId), + 'userId': serializer.toJson(userId), + 'parentType': serializer.toJson(parentType), + 'parentId': serializer.toJson(parentId), + 'role': serializer.toJson(role), + 'createTime': serializer.toJson(createTime), + 'updateTime': serializer.toJson(updateTime), + }; + } + + UserMembershipsData copyWith({ + String? membershipId, + String? userId, + String? parentType, + String? parentId, + String? role, + DateTime? createTime, + DateTime? updateTime, + }) => UserMembershipsData( + membershipId: membershipId ?? this.membershipId, + userId: userId ?? this.userId, + parentType: parentType ?? this.parentType, + parentId: parentId ?? this.parentId, + role: role ?? this.role, + createTime: createTime ?? this.createTime, + updateTime: updateTime ?? this.updateTime, + ); + UserMembershipsData copyWithCompanion(UserMembershipsCompanion data) { + return UserMembershipsData( + membershipId: + data.membershipId.present + ? data.membershipId.value + : this.membershipId, + userId: data.userId.present ? data.userId.value : this.userId, + parentType: + data.parentType.present ? data.parentType.value : this.parentType, + parentId: data.parentId.present ? data.parentId.value : this.parentId, + role: data.role.present ? data.role.value : this.role, + createTime: + data.createTime.present ? data.createTime.value : this.createTime, + updateTime: + data.updateTime.present ? data.updateTime.value : this.updateTime, + ); + } + + @override + String toString() { + return (StringBuffer('UserMembershipsData(') + ..write('membershipId: $membershipId, ') + ..write('userId: $userId, ') + ..write('parentType: $parentType, ') + ..write('parentId: $parentId, ') + ..write('role: $role, ') + ..write('createTime: $createTime, ') + ..write('updateTime: $updateTime') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + membershipId, + userId, + parentType, + parentId, + role, + createTime, + updateTime, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is UserMembershipsData && + other.membershipId == this.membershipId && + other.userId == this.userId && + other.parentType == this.parentType && + other.parentId == this.parentId && + other.role == this.role && + other.createTime == this.createTime && + other.updateTime == this.updateTime); +} + +class UserMembershipsCompanion extends UpdateCompanion { + final Value membershipId; + final Value userId; + final Value parentType; + final Value parentId; + final Value role; + final Value createTime; + final Value updateTime; + final Value rowid; + const UserMembershipsCompanion({ + this.membershipId = const Value.absent(), + this.userId = const Value.absent(), + this.parentType = const Value.absent(), + this.parentId = const Value.absent(), + this.role = const Value.absent(), + this.createTime = const Value.absent(), + this.updateTime = const Value.absent(), + this.rowid = const Value.absent(), + }); + UserMembershipsCompanion.insert({ + required String membershipId, + required String userId, + required String parentType, + required String parentId, + required String role, + this.createTime = const Value.absent(), + this.updateTime = const Value.absent(), + this.rowid = const Value.absent(), + }) : membershipId = Value(membershipId), + userId = Value(userId), + parentType = Value(parentType), + parentId = Value(parentId), + role = Value(role); + static Insertable custom({ + Expression? membershipId, + Expression? userId, + Expression? parentType, + Expression? parentId, + Expression? role, + Expression? createTime, + Expression? updateTime, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (membershipId != null) 'membership_id': membershipId, + if (userId != null) 'user_id': userId, + if (parentType != null) 'parent_type': parentType, + if (parentId != null) 'parent_id': parentId, + if (role != null) 'role': role, + if (createTime != null) 'create_time': createTime, + if (updateTime != null) 'update_time': updateTime, + if (rowid != null) 'rowid': rowid, + }); + } + + UserMembershipsCompanion copyWith({ + Value? membershipId, + Value? userId, + Value? parentType, + Value? parentId, + Value? role, + Value? createTime, + Value? updateTime, + Value? rowid, + }) { + return UserMembershipsCompanion( + membershipId: membershipId ?? this.membershipId, + userId: userId ?? this.userId, + parentType: parentType ?? this.parentType, + parentId: parentId ?? this.parentId, + role: role ?? this.role, + createTime: createTime ?? this.createTime, + updateTime: updateTime ?? this.updateTime, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (membershipId.present) { + map['membership_id'] = Variable(membershipId.value); + } + if (userId.present) { + map['user_id'] = Variable(userId.value); + } + if (parentType.present) { + map['parent_type'] = Variable(parentType.value); + } + if (parentId.present) { + map['parent_id'] = Variable(parentId.value); + } + if (role.present) { + map['role'] = Variable(role.value); + } + if (createTime.present) { + map['create_time'] = Variable(createTime.value); + } + if (updateTime.present) { + map['update_time'] = Variable(updateTime.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('UserMembershipsCompanion(') + ..write('membershipId: $membershipId, ') + ..write('userId: $userId, ') + ..write('parentType: $parentType, ') + ..write('parentId: $parentId, ') + ..write('role: $role, ') + ..write('createTime: $createTime, ') + ..write('updateTime: $updateTime, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +class Organizations extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + Organizations(this.attachedDatabase, [this._alias]); + late final GeneratedColumn id = GeneratedColumn( + 'id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); + late final GeneratedColumn parentType = GeneratedColumn( + 'parent_type', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn parentId = GeneratedColumn( + 'parent_id', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn organizationId = GeneratedColumn( + 'organization_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL UNIQUE', + ); + late final GeneratedColumn state = GeneratedColumn( + 'state', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT \'CREATING\'', + defaultValue: const CustomExpression('\'CREATING\''), + ); + late final GeneratedColumn displayName = GeneratedColumn( + 'display_name', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn createTime = GeneratedColumn( + 'create_time', + aliasedName, + false, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT (unixepoch(\'now\', \'subsec\'))', + defaultValue: const CustomExpression('unixepoch(\'now\', \'subsec\')'), + ); + late final GeneratedColumn updateTime = GeneratedColumn( + 'update_time', + aliasedName, + false, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT (unixepoch(\'now\', \'subsec\'))', + defaultValue: const CustomExpression('unixepoch(\'now\', \'subsec\')'), + ); + late final GeneratedColumn deleteTime = GeneratedColumn( + 'delete_time', + aliasedName, + true, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn purgeTime = GeneratedColumn( + 'purge_time', + aliasedName, + true, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn annotations = GeneratedColumn( + 'annotations', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn primaryRegion = GeneratedColumn( + 'primary_region', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn reconciling = GeneratedColumn( + 'reconciling', + aliasedName, + false, + type: DriftSqlType.bool, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT FALSE', + defaultValue: const CustomExpression('FALSE'), + ); + late final GeneratedColumn etag = GeneratedColumn( + 'etag', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: + 'NOT NULL GENERATED ALWAYS AS (hex(md5(json_array(id, parent_type, parent_id, organization_id, state, display_name, create_time, update_time, delete_time, purge_time, annotations, primary_region, reconciling)))) STORED', + ); + @override + List get $columns => [ + id, + parentType, + parentId, + organizationId, + state, + displayName, + createTime, + updateTime, + deleteTime, + purgeTime, + annotations, + primaryRegion, + reconciling, + etag, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'organizations'; + @override + Set get $primaryKey => {id}; + @override + OrganizationsData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return OrganizationsData( + id: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}id'], + )!, + parentType: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}parent_type'], + ), + parentId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}parent_id'], + ), + organizationId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}organization_id'], + )!, + state: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}state'], + )!, + displayName: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}display_name'], + )!, + createTime: + attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}create_time'], + )!, + updateTime: + attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}update_time'], + )!, + deleteTime: attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}delete_time'], + ), + purgeTime: attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}purge_time'], + ), + annotations: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}annotations'], + ), + primaryRegion: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}primary_region'], + ), + reconciling: + attachedDatabase.typeMapping.read( + DriftSqlType.bool, + data['${effectivePrefix}reconciling'], + )!, + etag: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}etag'], + )!, + ); + } + + @override + Organizations createAlias(String alias) { + return Organizations(attachedDatabase, alias); + } + + @override + List get customConstraints => const [ + 'CONSTRAINT organizations_parent_fk FOREIGN KEY(parent_type, parent_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE SET NULL', + ]; + @override + bool get dontWriteConstraints => true; +} + +class OrganizationsData extends DataClass + implements Insertable { + final String id; + final String? parentType; + final String? parentId; + final String organizationId; + final String state; + final String displayName; + final DateTime createTime; + final DateTime updateTime; + final DateTime? deleteTime; + final DateTime? purgeTime; + final String? annotations; + final String? primaryRegion; + final bool reconciling; + final String etag; + const OrganizationsData({ + required this.id, + this.parentType, + this.parentId, + required this.organizationId, + required this.state, + required this.displayName, + required this.createTime, + required this.updateTime, + this.deleteTime, + this.purgeTime, + this.annotations, + this.primaryRegion, + required this.reconciling, + required this.etag, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + if (!nullToAbsent || parentType != null) { + map['parent_type'] = Variable(parentType); + } + if (!nullToAbsent || parentId != null) { + map['parent_id'] = Variable(parentId); + } + map['organization_id'] = Variable(organizationId); + map['state'] = Variable(state); + map['display_name'] = Variable(displayName); + map['create_time'] = Variable(createTime); + map['update_time'] = Variable(updateTime); + if (!nullToAbsent || deleteTime != null) { + map['delete_time'] = Variable(deleteTime); + } + if (!nullToAbsent || purgeTime != null) { + map['purge_time'] = Variable(purgeTime); + } + if (!nullToAbsent || annotations != null) { + map['annotations'] = Variable(annotations); + } + if (!nullToAbsent || primaryRegion != null) { + map['primary_region'] = Variable(primaryRegion); + } + map['reconciling'] = Variable(reconciling); + map['etag'] = Variable(etag); + return map; + } + + OrganizationsCompanion toCompanion(bool nullToAbsent) { + return OrganizationsCompanion( + id: Value(id), + parentType: + parentType == null && nullToAbsent + ? const Value.absent() + : Value(parentType), + parentId: + parentId == null && nullToAbsent + ? const Value.absent() + : Value(parentId), + organizationId: Value(organizationId), + state: Value(state), + displayName: Value(displayName), + createTime: Value(createTime), + updateTime: Value(updateTime), + deleteTime: + deleteTime == null && nullToAbsent + ? const Value.absent() + : Value(deleteTime), + purgeTime: + purgeTime == null && nullToAbsent + ? const Value.absent() + : Value(purgeTime), + annotations: + annotations == null && nullToAbsent + ? const Value.absent() + : Value(annotations), + primaryRegion: + primaryRegion == null && nullToAbsent + ? const Value.absent() + : Value(primaryRegion), + reconciling: Value(reconciling), + etag: Value(etag), + ); + } + + factory OrganizationsData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return OrganizationsData( + id: serializer.fromJson(json['id']), + parentType: serializer.fromJson(json['parentType']), + parentId: serializer.fromJson(json['parentId']), + organizationId: serializer.fromJson(json['organizationId']), + state: serializer.fromJson(json['state']), + displayName: serializer.fromJson(json['displayName']), + createTime: serializer.fromJson(json['createTime']), + updateTime: serializer.fromJson(json['updateTime']), + deleteTime: serializer.fromJson(json['deleteTime']), + purgeTime: serializer.fromJson(json['purgeTime']), + annotations: serializer.fromJson(json['annotations']), + primaryRegion: serializer.fromJson(json['primaryRegion']), + reconciling: serializer.fromJson(json['reconciling']), + etag: serializer.fromJson(json['etag']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'parentType': serializer.toJson(parentType), + 'parentId': serializer.toJson(parentId), + 'organizationId': serializer.toJson(organizationId), + 'state': serializer.toJson(state), + 'displayName': serializer.toJson(displayName), + 'createTime': serializer.toJson(createTime), + 'updateTime': serializer.toJson(updateTime), + 'deleteTime': serializer.toJson(deleteTime), + 'purgeTime': serializer.toJson(purgeTime), + 'annotations': serializer.toJson(annotations), + 'primaryRegion': serializer.toJson(primaryRegion), + 'reconciling': serializer.toJson(reconciling), + 'etag': serializer.toJson(etag), + }; + } + + OrganizationsData copyWith({ + String? id, + Value parentType = const Value.absent(), + Value parentId = const Value.absent(), + String? organizationId, + String? state, + String? displayName, + DateTime? createTime, + DateTime? updateTime, + Value deleteTime = const Value.absent(), + Value purgeTime = const Value.absent(), + Value annotations = const Value.absent(), + Value primaryRegion = const Value.absent(), + bool? reconciling, + String? etag, + }) => OrganizationsData( + id: id ?? this.id, + parentType: parentType.present ? parentType.value : this.parentType, + parentId: parentId.present ? parentId.value : this.parentId, + organizationId: organizationId ?? this.organizationId, + state: state ?? this.state, + displayName: displayName ?? this.displayName, + createTime: createTime ?? this.createTime, + updateTime: updateTime ?? this.updateTime, + deleteTime: deleteTime.present ? deleteTime.value : this.deleteTime, + purgeTime: purgeTime.present ? purgeTime.value : this.purgeTime, + annotations: annotations.present ? annotations.value : this.annotations, + primaryRegion: + primaryRegion.present ? primaryRegion.value : this.primaryRegion, + reconciling: reconciling ?? this.reconciling, + etag: etag ?? this.etag, + ); + OrganizationsData copyWithCompanion(OrganizationsCompanion data) { + return OrganizationsData( + id: data.id.present ? data.id.value : this.id, + parentType: + data.parentType.present ? data.parentType.value : this.parentType, + parentId: data.parentId.present ? data.parentId.value : this.parentId, + organizationId: + data.organizationId.present + ? data.organizationId.value + : this.organizationId, + state: data.state.present ? data.state.value : this.state, + displayName: + data.displayName.present ? data.displayName.value : this.displayName, + createTime: + data.createTime.present ? data.createTime.value : this.createTime, + updateTime: + data.updateTime.present ? data.updateTime.value : this.updateTime, + deleteTime: + data.deleteTime.present ? data.deleteTime.value : this.deleteTime, + purgeTime: data.purgeTime.present ? data.purgeTime.value : this.purgeTime, + annotations: + data.annotations.present ? data.annotations.value : this.annotations, + primaryRegion: + data.primaryRegion.present + ? data.primaryRegion.value + : this.primaryRegion, + reconciling: + data.reconciling.present ? data.reconciling.value : this.reconciling, + etag: data.etag.present ? data.etag.value : this.etag, + ); + } + + @override + String toString() { + return (StringBuffer('OrganizationsData(') + ..write('id: $id, ') + ..write('parentType: $parentType, ') + ..write('parentId: $parentId, ') + ..write('organizationId: $organizationId, ') + ..write('state: $state, ') + ..write('displayName: $displayName, ') + ..write('createTime: $createTime, ') + ..write('updateTime: $updateTime, ') + ..write('deleteTime: $deleteTime, ') + ..write('purgeTime: $purgeTime, ') + ..write('annotations: $annotations, ') + ..write('primaryRegion: $primaryRegion, ') + ..write('reconciling: $reconciling, ') + ..write('etag: $etag') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + id, + parentType, + parentId, + organizationId, + state, + displayName, + createTime, + updateTime, + deleteTime, + purgeTime, + annotations, + primaryRegion, + reconciling, + etag, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is OrganizationsData && + other.id == this.id && + other.parentType == this.parentType && + other.parentId == this.parentId && + other.organizationId == this.organizationId && + other.state == this.state && + other.displayName == this.displayName && + other.createTime == this.createTime && + other.updateTime == this.updateTime && + other.deleteTime == this.deleteTime && + other.purgeTime == this.purgeTime && + other.annotations == this.annotations && + other.primaryRegion == this.primaryRegion && + other.reconciling == this.reconciling && + other.etag == this.etag); +} + +class OrganizationsCompanion extends UpdateCompanion { + final Value id; + final Value parentType; + final Value parentId; + final Value organizationId; + final Value state; + final Value displayName; + final Value createTime; + final Value updateTime; + final Value deleteTime; + final Value purgeTime; + final Value annotations; + final Value primaryRegion; + final Value reconciling; + final Value etag; + final Value rowid; + const OrganizationsCompanion({ + this.id = const Value.absent(), + this.parentType = const Value.absent(), + this.parentId = const Value.absent(), + this.organizationId = const Value.absent(), + this.state = const Value.absent(), + this.displayName = const Value.absent(), + this.createTime = const Value.absent(), + this.updateTime = const Value.absent(), + this.deleteTime = const Value.absent(), + this.purgeTime = const Value.absent(), + this.annotations = const Value.absent(), + this.primaryRegion = const Value.absent(), + this.reconciling = const Value.absent(), + this.etag = const Value.absent(), + this.rowid = const Value.absent(), + }); + OrganizationsCompanion.insert({ + required String id, + this.parentType = const Value.absent(), + this.parentId = const Value.absent(), + required String organizationId, + this.state = const Value.absent(), + required String displayName, + this.createTime = const Value.absent(), + this.updateTime = const Value.absent(), + this.deleteTime = const Value.absent(), + this.purgeTime = const Value.absent(), + this.annotations = const Value.absent(), + this.primaryRegion = const Value.absent(), + this.reconciling = const Value.absent(), + required String etag, + this.rowid = const Value.absent(), + }) : id = Value(id), + organizationId = Value(organizationId), + displayName = Value(displayName), + etag = Value(etag); + static Insertable custom({ + Expression? id, + Expression? parentType, + Expression? parentId, + Expression? organizationId, + Expression? state, + Expression? displayName, + Expression? createTime, + Expression? updateTime, + Expression? deleteTime, + Expression? purgeTime, + Expression? annotations, + Expression? primaryRegion, + Expression? reconciling, + Expression? etag, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (parentType != null) 'parent_type': parentType, + if (parentId != null) 'parent_id': parentId, + if (organizationId != null) 'organization_id': organizationId, + if (state != null) 'state': state, + if (displayName != null) 'display_name': displayName, + if (createTime != null) 'create_time': createTime, + if (updateTime != null) 'update_time': updateTime, + if (deleteTime != null) 'delete_time': deleteTime, + if (purgeTime != null) 'purge_time': purgeTime, + if (annotations != null) 'annotations': annotations, + if (primaryRegion != null) 'primary_region': primaryRegion, + if (reconciling != null) 'reconciling': reconciling, + if (etag != null) 'etag': etag, + if (rowid != null) 'rowid': rowid, + }); + } + + OrganizationsCompanion copyWith({ + Value? id, + Value? parentType, + Value? parentId, + Value? organizationId, + Value? state, + Value? displayName, + Value? createTime, + Value? updateTime, + Value? deleteTime, + Value? purgeTime, + Value? annotations, + Value? primaryRegion, + Value? reconciling, + Value? etag, + Value? rowid, + }) { + return OrganizationsCompanion( + id: id ?? this.id, + parentType: parentType ?? this.parentType, + parentId: parentId ?? this.parentId, + organizationId: organizationId ?? this.organizationId, + state: state ?? this.state, + displayName: displayName ?? this.displayName, + createTime: createTime ?? this.createTime, + updateTime: updateTime ?? this.updateTime, + deleteTime: deleteTime ?? this.deleteTime, + purgeTime: purgeTime ?? this.purgeTime, + annotations: annotations ?? this.annotations, + primaryRegion: primaryRegion ?? this.primaryRegion, + reconciling: reconciling ?? this.reconciling, + etag: etag ?? this.etag, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (parentType.present) { + map['parent_type'] = Variable(parentType.value); + } + if (parentId.present) { + map['parent_id'] = Variable(parentId.value); + } + if (organizationId.present) { + map['organization_id'] = Variable(organizationId.value); + } + if (state.present) { + map['state'] = Variable(state.value); + } + if (displayName.present) { + map['display_name'] = Variable(displayName.value); + } + if (createTime.present) { + map['create_time'] = Variable(createTime.value); + } + if (updateTime.present) { + map['update_time'] = Variable(updateTime.value); + } + if (deleteTime.present) { + map['delete_time'] = Variable(deleteTime.value); + } + if (purgeTime.present) { + map['purge_time'] = Variable(purgeTime.value); + } + if (annotations.present) { + map['annotations'] = Variable(annotations.value); + } + if (primaryRegion.present) { + map['primary_region'] = Variable(primaryRegion.value); + } + if (reconciling.present) { + map['reconciling'] = Variable(reconciling.value); + } + if (etag.present) { + map['etag'] = Variable(etag.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('OrganizationsCompanion(') + ..write('id: $id, ') + ..write('parentType: $parentType, ') + ..write('parentId: $parentId, ') + ..write('organizationId: $organizationId, ') + ..write('state: $state, ') + ..write('displayName: $displayName, ') + ..write('createTime: $createTime, ') + ..write('updateTime: $updateTime, ') + ..write('deleteTime: $deleteTime, ') + ..write('purgeTime: $purgeTime, ') + ..write('annotations: $annotations, ') + ..write('primaryRegion: $primaryRegion, ') + ..write('reconciling: $reconciling, ') + ..write('etag: $etag, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +class Projects extends Table with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + Projects(this.attachedDatabase, [this._alias]); + late final GeneratedColumn id = GeneratedColumn( + 'id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); + late final GeneratedColumn parentType = GeneratedColumn( + 'parent_type', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn parentId = GeneratedColumn( + 'parent_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn projectId = GeneratedColumn( + 'project_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn state = GeneratedColumn( + 'state', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT \'CREATING\'', + defaultValue: const CustomExpression('\'CREATING\''), + ); + late final GeneratedColumn displayName = GeneratedColumn( + 'display_name', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn createTime = GeneratedColumn( + 'create_time', + aliasedName, + false, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT (unixepoch(\'now\', \'subsec\'))', + defaultValue: const CustomExpression('unixepoch(\'now\', \'subsec\')'), + ); + late final GeneratedColumn updateTime = GeneratedColumn( + 'update_time', + aliasedName, + false, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT (unixepoch(\'now\', \'subsec\'))', + defaultValue: const CustomExpression('unixepoch(\'now\', \'subsec\')'), + ); + late final GeneratedColumn deleteTime = GeneratedColumn( + 'delete_time', + aliasedName, + true, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn purgeTime = GeneratedColumn( + 'purge_time', + aliasedName, + true, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn annotations = GeneratedColumn( + 'annotations', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn regions = GeneratedColumn( + 'regions', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn reconciling = GeneratedColumn( + 'reconciling', + aliasedName, + false, + type: DriftSqlType.bool, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT FALSE', + defaultValue: const CustomExpression('FALSE'), + ); + late final GeneratedColumn etag = GeneratedColumn( + 'etag', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: + 'NOT NULL GENERATED ALWAYS AS (hex(md5(json_array(id, parent_type, parent_id, project_id, state, display_name, create_time, update_time, delete_time, purge_time, annotations, regions, reconciling)))) STORED', + ); + @override + List get $columns => [ + id, + parentType, + parentId, + projectId, + state, + displayName, + createTime, + updateTime, + deleteTime, + purgeTime, + annotations, + regions, + reconciling, + etag, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'projects'; + @override + Set get $primaryKey => {id}; + @override + List> get uniqueKeys => [ + {projectId, parentId}, + ]; + @override + ProjectsData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return ProjectsData( + id: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}id'], + )!, + parentType: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}parent_type'], + )!, + parentId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}parent_id'], + )!, + projectId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}project_id'], + )!, + state: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}state'], + )!, + displayName: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}display_name'], + ), + createTime: + attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}create_time'], + )!, + updateTime: + attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}update_time'], + )!, + deleteTime: attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}delete_time'], + ), + purgeTime: attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}purge_time'], + ), + annotations: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}annotations'], + ), + regions: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}regions'], + )!, + reconciling: + attachedDatabase.typeMapping.read( + DriftSqlType.bool, + data['${effectivePrefix}reconciling'], + )!, + etag: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}etag'], + )!, + ); + } + + @override + Projects createAlias(String alias) { + return Projects(attachedDatabase, alias); + } + + @override + List get customConstraints => const [ + 'CHECK(parent_type = \'Celest::Organization\')', + 'CONSTRAINT projects_fk_parent FOREIGN KEY(parent_type, parent_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE CASCADE', + 'CONSTRAINT projects_fk_organization FOREIGN KEY(parent_id)REFERENCES organizations(id)ON UPDATE CASCADE ON DELETE CASCADE', + 'CONSTRAINT projects_uq_project_id UNIQUE(project_id, parent_id)', + ]; + @override + bool get dontWriteConstraints => true; +} + +class ProjectsData extends DataClass implements Insertable { + final String id; + final String parentType; + final String parentId; + final String projectId; + final String state; + final String? displayName; + final DateTime createTime; + final DateTime updateTime; + final DateTime? deleteTime; + final DateTime? purgeTime; + final String? annotations; + final String regions; + final bool reconciling; + final String etag; + const ProjectsData({ + required this.id, + required this.parentType, + required this.parentId, + required this.projectId, + required this.state, + this.displayName, + required this.createTime, + required this.updateTime, + this.deleteTime, + this.purgeTime, + this.annotations, + required this.regions, + required this.reconciling, + required this.etag, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['parent_type'] = Variable(parentType); + map['parent_id'] = Variable(parentId); + map['project_id'] = Variable(projectId); + map['state'] = Variable(state); + if (!nullToAbsent || displayName != null) { + map['display_name'] = Variable(displayName); + } + map['create_time'] = Variable(createTime); + map['update_time'] = Variable(updateTime); + if (!nullToAbsent || deleteTime != null) { + map['delete_time'] = Variable(deleteTime); + } + if (!nullToAbsent || purgeTime != null) { + map['purge_time'] = Variable(purgeTime); + } + if (!nullToAbsent || annotations != null) { + map['annotations'] = Variable(annotations); + } + map['regions'] = Variable(regions); + map['reconciling'] = Variable(reconciling); + map['etag'] = Variable(etag); + return map; + } + + ProjectsCompanion toCompanion(bool nullToAbsent) { + return ProjectsCompanion( + id: Value(id), + parentType: Value(parentType), + parentId: Value(parentId), + projectId: Value(projectId), + state: Value(state), + displayName: + displayName == null && nullToAbsent + ? const Value.absent() + : Value(displayName), + createTime: Value(createTime), + updateTime: Value(updateTime), + deleteTime: + deleteTime == null && nullToAbsent + ? const Value.absent() + : Value(deleteTime), + purgeTime: + purgeTime == null && nullToAbsent + ? const Value.absent() + : Value(purgeTime), + annotations: + annotations == null && nullToAbsent + ? const Value.absent() + : Value(annotations), + regions: Value(regions), + reconciling: Value(reconciling), + etag: Value(etag), + ); + } + + factory ProjectsData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return ProjectsData( + id: serializer.fromJson(json['id']), + parentType: serializer.fromJson(json['parentType']), + parentId: serializer.fromJson(json['parentId']), + projectId: serializer.fromJson(json['projectId']), + state: serializer.fromJson(json['state']), + displayName: serializer.fromJson(json['displayName']), + createTime: serializer.fromJson(json['createTime']), + updateTime: serializer.fromJson(json['updateTime']), + deleteTime: serializer.fromJson(json['deleteTime']), + purgeTime: serializer.fromJson(json['purgeTime']), + annotations: serializer.fromJson(json['annotations']), + regions: serializer.fromJson(json['regions']), + reconciling: serializer.fromJson(json['reconciling']), + etag: serializer.fromJson(json['etag']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'parentType': serializer.toJson(parentType), + 'parentId': serializer.toJson(parentId), + 'projectId': serializer.toJson(projectId), + 'state': serializer.toJson(state), + 'displayName': serializer.toJson(displayName), + 'createTime': serializer.toJson(createTime), + 'updateTime': serializer.toJson(updateTime), + 'deleteTime': serializer.toJson(deleteTime), + 'purgeTime': serializer.toJson(purgeTime), + 'annotations': serializer.toJson(annotations), + 'regions': serializer.toJson(regions), + 'reconciling': serializer.toJson(reconciling), + 'etag': serializer.toJson(etag), + }; + } + + ProjectsData copyWith({ + String? id, + String? parentType, + String? parentId, + String? projectId, + String? state, + Value displayName = const Value.absent(), + DateTime? createTime, + DateTime? updateTime, + Value deleteTime = const Value.absent(), + Value purgeTime = const Value.absent(), + Value annotations = const Value.absent(), + String? regions, + bool? reconciling, + String? etag, + }) => ProjectsData( + id: id ?? this.id, + parentType: parentType ?? this.parentType, + parentId: parentId ?? this.parentId, + projectId: projectId ?? this.projectId, + state: state ?? this.state, + displayName: displayName.present ? displayName.value : this.displayName, + createTime: createTime ?? this.createTime, + updateTime: updateTime ?? this.updateTime, + deleteTime: deleteTime.present ? deleteTime.value : this.deleteTime, + purgeTime: purgeTime.present ? purgeTime.value : this.purgeTime, + annotations: annotations.present ? annotations.value : this.annotations, + regions: regions ?? this.regions, + reconciling: reconciling ?? this.reconciling, + etag: etag ?? this.etag, + ); + ProjectsData copyWithCompanion(ProjectsCompanion data) { + return ProjectsData( + id: data.id.present ? data.id.value : this.id, + parentType: + data.parentType.present ? data.parentType.value : this.parentType, + parentId: data.parentId.present ? data.parentId.value : this.parentId, + projectId: data.projectId.present ? data.projectId.value : this.projectId, + state: data.state.present ? data.state.value : this.state, + displayName: + data.displayName.present ? data.displayName.value : this.displayName, + createTime: + data.createTime.present ? data.createTime.value : this.createTime, + updateTime: + data.updateTime.present ? data.updateTime.value : this.updateTime, + deleteTime: + data.deleteTime.present ? data.deleteTime.value : this.deleteTime, + purgeTime: data.purgeTime.present ? data.purgeTime.value : this.purgeTime, + annotations: + data.annotations.present ? data.annotations.value : this.annotations, + regions: data.regions.present ? data.regions.value : this.regions, + reconciling: + data.reconciling.present ? data.reconciling.value : this.reconciling, + etag: data.etag.present ? data.etag.value : this.etag, + ); + } + + @override + String toString() { + return (StringBuffer('ProjectsData(') + ..write('id: $id, ') + ..write('parentType: $parentType, ') + ..write('parentId: $parentId, ') + ..write('projectId: $projectId, ') + ..write('state: $state, ') + ..write('displayName: $displayName, ') + ..write('createTime: $createTime, ') + ..write('updateTime: $updateTime, ') + ..write('deleteTime: $deleteTime, ') + ..write('purgeTime: $purgeTime, ') + ..write('annotations: $annotations, ') + ..write('regions: $regions, ') + ..write('reconciling: $reconciling, ') + ..write('etag: $etag') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + id, + parentType, + parentId, + projectId, + state, + displayName, + createTime, + updateTime, + deleteTime, + purgeTime, + annotations, + regions, + reconciling, + etag, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is ProjectsData && + other.id == this.id && + other.parentType == this.parentType && + other.parentId == this.parentId && + other.projectId == this.projectId && + other.state == this.state && + other.displayName == this.displayName && + other.createTime == this.createTime && + other.updateTime == this.updateTime && + other.deleteTime == this.deleteTime && + other.purgeTime == this.purgeTime && + other.annotations == this.annotations && + other.regions == this.regions && + other.reconciling == this.reconciling && + other.etag == this.etag); +} + +class ProjectsCompanion extends UpdateCompanion { + final Value id; + final Value parentType; + final Value parentId; + final Value projectId; + final Value state; + final Value displayName; + final Value createTime; + final Value updateTime; + final Value deleteTime; + final Value purgeTime; + final Value annotations; + final Value regions; + final Value reconciling; + final Value etag; + final Value rowid; + const ProjectsCompanion({ + this.id = const Value.absent(), + this.parentType = const Value.absent(), + this.parentId = const Value.absent(), + this.projectId = const Value.absent(), + this.state = const Value.absent(), + this.displayName = const Value.absent(), + this.createTime = const Value.absent(), + this.updateTime = const Value.absent(), + this.deleteTime = const Value.absent(), + this.purgeTime = const Value.absent(), + this.annotations = const Value.absent(), + this.regions = const Value.absent(), + this.reconciling = const Value.absent(), + this.etag = const Value.absent(), + this.rowid = const Value.absent(), + }); + ProjectsCompanion.insert({ + required String id, + required String parentType, + required String parentId, + required String projectId, + this.state = const Value.absent(), + this.displayName = const Value.absent(), + this.createTime = const Value.absent(), + this.updateTime = const Value.absent(), + this.deleteTime = const Value.absent(), + this.purgeTime = const Value.absent(), + this.annotations = const Value.absent(), + required String regions, + this.reconciling = const Value.absent(), + required String etag, + this.rowid = const Value.absent(), + }) : id = Value(id), + parentType = Value(parentType), + parentId = Value(parentId), + projectId = Value(projectId), + regions = Value(regions), + etag = Value(etag); + static Insertable custom({ + Expression? id, + Expression? parentType, + Expression? parentId, + Expression? projectId, + Expression? state, + Expression? displayName, + Expression? createTime, + Expression? updateTime, + Expression? deleteTime, + Expression? purgeTime, + Expression? annotations, + Expression? regions, + Expression? reconciling, + Expression? etag, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (parentType != null) 'parent_type': parentType, + if (parentId != null) 'parent_id': parentId, + if (projectId != null) 'project_id': projectId, + if (state != null) 'state': state, + if (displayName != null) 'display_name': displayName, + if (createTime != null) 'create_time': createTime, + if (updateTime != null) 'update_time': updateTime, + if (deleteTime != null) 'delete_time': deleteTime, + if (purgeTime != null) 'purge_time': purgeTime, + if (annotations != null) 'annotations': annotations, + if (regions != null) 'regions': regions, + if (reconciling != null) 'reconciling': reconciling, + if (etag != null) 'etag': etag, + if (rowid != null) 'rowid': rowid, + }); + } + + ProjectsCompanion copyWith({ + Value? id, + Value? parentType, + Value? parentId, + Value? projectId, + Value? state, + Value? displayName, + Value? createTime, + Value? updateTime, + Value? deleteTime, + Value? purgeTime, + Value? annotations, + Value? regions, + Value? reconciling, + Value? etag, + Value? rowid, + }) { + return ProjectsCompanion( + id: id ?? this.id, + parentType: parentType ?? this.parentType, + parentId: parentId ?? this.parentId, + projectId: projectId ?? this.projectId, + state: state ?? this.state, + displayName: displayName ?? this.displayName, + createTime: createTime ?? this.createTime, + updateTime: updateTime ?? this.updateTime, + deleteTime: deleteTime ?? this.deleteTime, + purgeTime: purgeTime ?? this.purgeTime, + annotations: annotations ?? this.annotations, + regions: regions ?? this.regions, + reconciling: reconciling ?? this.reconciling, + etag: etag ?? this.etag, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (parentType.present) { + map['parent_type'] = Variable(parentType.value); + } + if (parentId.present) { + map['parent_id'] = Variable(parentId.value); + } + if (projectId.present) { + map['project_id'] = Variable(projectId.value); + } + if (state.present) { + map['state'] = Variable(state.value); + } + if (displayName.present) { + map['display_name'] = Variable(displayName.value); + } + if (createTime.present) { + map['create_time'] = Variable(createTime.value); + } + if (updateTime.present) { + map['update_time'] = Variable(updateTime.value); + } + if (deleteTime.present) { + map['delete_time'] = Variable(deleteTime.value); + } + if (purgeTime.present) { + map['purge_time'] = Variable(purgeTime.value); + } + if (annotations.present) { + map['annotations'] = Variable(annotations.value); + } + if (regions.present) { + map['regions'] = Variable(regions.value); + } + if (reconciling.present) { + map['reconciling'] = Variable(reconciling.value); + } + if (etag.present) { + map['etag'] = Variable(etag.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('ProjectsCompanion(') + ..write('id: $id, ') + ..write('parentType: $parentType, ') + ..write('parentId: $parentId, ') + ..write('projectId: $projectId, ') + ..write('state: $state, ') + ..write('displayName: $displayName, ') + ..write('createTime: $createTime, ') + ..write('updateTime: $updateTime, ') + ..write('deleteTime: $deleteTime, ') + ..write('purgeTime: $purgeTime, ') + ..write('annotations: $annotations, ') + ..write('regions: $regions, ') + ..write('reconciling: $reconciling, ') + ..write('etag: $etag, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +class ProjectEnvironments extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + ProjectEnvironments(this.attachedDatabase, [this._alias]); + late final GeneratedColumn id = GeneratedColumn( + 'id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); + late final GeneratedColumn parentType = GeneratedColumn( + 'parent_type', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn parentId = GeneratedColumn( + 'parent_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn projectEnvironmentId = + GeneratedColumn( + 'project_environment_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn state = GeneratedColumn( + 'state', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT \'CREATING\'', + defaultValue: const CustomExpression('\'CREATING\''), + ); + late final GeneratedColumn displayName = GeneratedColumn( + 'display_name', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn createTime = GeneratedColumn( + 'create_time', + aliasedName, + false, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT (unixepoch(\'now\', \'subsec\'))', + defaultValue: const CustomExpression('unixepoch(\'now\', \'subsec\')'), + ); + late final GeneratedColumn updateTime = GeneratedColumn( + 'update_time', + aliasedName, + false, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT (unixepoch(\'now\', \'subsec\'))', + defaultValue: const CustomExpression('unixepoch(\'now\', \'subsec\')'), + ); + late final GeneratedColumn deleteTime = GeneratedColumn( + 'delete_time', + aliasedName, + true, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn annotations = GeneratedColumn( + 'annotations', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn reconciling = GeneratedColumn( + 'reconciling', + aliasedName, + false, + type: DriftSqlType.bool, + requiredDuringInsert: true, + $customConstraints: + 'NOT NULL GENERATED ALWAYS AS (state IN (\'CREATING\', \'UPDATING\', \'DELETING\')) VIRTUAL', + ); + late final GeneratedColumn etag = GeneratedColumn( + 'etag', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: + 'NOT NULL GENERATED ALWAYS AS (hex(md5(json_array(id, parent_type, parent_id, project_environment_id, state, display_name, create_time, update_time, delete_time, annotations, reconciling)))) STORED', + ); + @override + List get $columns => [ + id, + parentType, + parentId, + projectEnvironmentId, + state, + displayName, + createTime, + updateTime, + deleteTime, + annotations, + reconciling, + etag, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'project_environments'; + @override + Set get $primaryKey => {id}; + @override + List> get uniqueKeys => [ + {projectEnvironmentId, parentId}, + ]; + @override + ProjectEnvironmentsData map( + Map data, { + String? tablePrefix, + }) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return ProjectEnvironmentsData( + id: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}id'], + )!, + parentType: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}parent_type'], + )!, + parentId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}parent_id'], + )!, + projectEnvironmentId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}project_environment_id'], + )!, + state: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}state'], + )!, + displayName: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}display_name'], + ), + createTime: + attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}create_time'], + )!, + updateTime: + attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}update_time'], + )!, + deleteTime: attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}delete_time'], + ), + annotations: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}annotations'], + ), + reconciling: + attachedDatabase.typeMapping.read( + DriftSqlType.bool, + data['${effectivePrefix}reconciling'], + )!, + etag: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}etag'], + )!, + ); + } + + @override + ProjectEnvironments createAlias(String alias) { + return ProjectEnvironments(attachedDatabase, alias); + } + + @override + List get customConstraints => const [ + 'CHECK(parent_type = \'Celest::Project\')', + 'CONSTRAINT project_environments_parent_fk FOREIGN KEY(parent_type, parent_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE CASCADE', + 'CONSTRAINT project_environments_organization_fk FOREIGN KEY(parent_id)REFERENCES projects(id)ON UPDATE CASCADE ON DELETE CASCADE', + 'CONSTRAINT project_environments_project_environment_id_unique_idx UNIQUE(project_environment_id, parent_id)', + ]; + @override + bool get dontWriteConstraints => true; +} + +class ProjectEnvironmentsData extends DataClass + implements Insertable { + final String id; + final String parentType; + final String parentId; + final String projectEnvironmentId; + final String state; + final String? displayName; + final DateTime createTime; + final DateTime updateTime; + final DateTime? deleteTime; + final String? annotations; + final bool reconciling; + final String etag; + const ProjectEnvironmentsData({ + required this.id, + required this.parentType, + required this.parentId, + required this.projectEnvironmentId, + required this.state, + this.displayName, + required this.createTime, + required this.updateTime, + this.deleteTime, + this.annotations, + required this.reconciling, + required this.etag, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['parent_type'] = Variable(parentType); + map['parent_id'] = Variable(parentId); + map['project_environment_id'] = Variable(projectEnvironmentId); + map['state'] = Variable(state); + if (!nullToAbsent || displayName != null) { + map['display_name'] = Variable(displayName); + } + map['create_time'] = Variable(createTime); + map['update_time'] = Variable(updateTime); + if (!nullToAbsent || deleteTime != null) { + map['delete_time'] = Variable(deleteTime); + } + if (!nullToAbsent || annotations != null) { + map['annotations'] = Variable(annotations); + } + map['reconciling'] = Variable(reconciling); + map['etag'] = Variable(etag); + return map; + } + + ProjectEnvironmentsCompanion toCompanion(bool nullToAbsent) { + return ProjectEnvironmentsCompanion( + id: Value(id), + parentType: Value(parentType), + parentId: Value(parentId), + projectEnvironmentId: Value(projectEnvironmentId), + state: Value(state), + displayName: + displayName == null && nullToAbsent + ? const Value.absent() + : Value(displayName), + createTime: Value(createTime), + updateTime: Value(updateTime), + deleteTime: + deleteTime == null && nullToAbsent + ? const Value.absent() + : Value(deleteTime), + annotations: + annotations == null && nullToAbsent + ? const Value.absent() + : Value(annotations), + reconciling: Value(reconciling), + etag: Value(etag), + ); + } + + factory ProjectEnvironmentsData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return ProjectEnvironmentsData( + id: serializer.fromJson(json['id']), + parentType: serializer.fromJson(json['parentType']), + parentId: serializer.fromJson(json['parentId']), + projectEnvironmentId: serializer.fromJson( + json['projectEnvironmentId'], + ), + state: serializer.fromJson(json['state']), + displayName: serializer.fromJson(json['displayName']), + createTime: serializer.fromJson(json['createTime']), + updateTime: serializer.fromJson(json['updateTime']), + deleteTime: serializer.fromJson(json['deleteTime']), + annotations: serializer.fromJson(json['annotations']), + reconciling: serializer.fromJson(json['reconciling']), + etag: serializer.fromJson(json['etag']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'parentType': serializer.toJson(parentType), + 'parentId': serializer.toJson(parentId), + 'projectEnvironmentId': serializer.toJson(projectEnvironmentId), + 'state': serializer.toJson(state), + 'displayName': serializer.toJson(displayName), + 'createTime': serializer.toJson(createTime), + 'updateTime': serializer.toJson(updateTime), + 'deleteTime': serializer.toJson(deleteTime), + 'annotations': serializer.toJson(annotations), + 'reconciling': serializer.toJson(reconciling), + 'etag': serializer.toJson(etag), + }; + } + + ProjectEnvironmentsData copyWith({ + String? id, + String? parentType, + String? parentId, + String? projectEnvironmentId, + String? state, + Value displayName = const Value.absent(), + DateTime? createTime, + DateTime? updateTime, + Value deleteTime = const Value.absent(), + Value annotations = const Value.absent(), + bool? reconciling, + String? etag, + }) => ProjectEnvironmentsData( + id: id ?? this.id, + parentType: parentType ?? this.parentType, + parentId: parentId ?? this.parentId, + projectEnvironmentId: projectEnvironmentId ?? this.projectEnvironmentId, + state: state ?? this.state, + displayName: displayName.present ? displayName.value : this.displayName, + createTime: createTime ?? this.createTime, + updateTime: updateTime ?? this.updateTime, + deleteTime: deleteTime.present ? deleteTime.value : this.deleteTime, + annotations: annotations.present ? annotations.value : this.annotations, + reconciling: reconciling ?? this.reconciling, + etag: etag ?? this.etag, + ); + ProjectEnvironmentsData copyWithCompanion(ProjectEnvironmentsCompanion data) { + return ProjectEnvironmentsData( + id: data.id.present ? data.id.value : this.id, + parentType: + data.parentType.present ? data.parentType.value : this.parentType, + parentId: data.parentId.present ? data.parentId.value : this.parentId, + projectEnvironmentId: + data.projectEnvironmentId.present + ? data.projectEnvironmentId.value + : this.projectEnvironmentId, + state: data.state.present ? data.state.value : this.state, + displayName: + data.displayName.present ? data.displayName.value : this.displayName, + createTime: + data.createTime.present ? data.createTime.value : this.createTime, + updateTime: + data.updateTime.present ? data.updateTime.value : this.updateTime, + deleteTime: + data.deleteTime.present ? data.deleteTime.value : this.deleteTime, + annotations: + data.annotations.present ? data.annotations.value : this.annotations, + reconciling: + data.reconciling.present ? data.reconciling.value : this.reconciling, + etag: data.etag.present ? data.etag.value : this.etag, + ); + } + + @override + String toString() { + return (StringBuffer('ProjectEnvironmentsData(') + ..write('id: $id, ') + ..write('parentType: $parentType, ') + ..write('parentId: $parentId, ') + ..write('projectEnvironmentId: $projectEnvironmentId, ') + ..write('state: $state, ') + ..write('displayName: $displayName, ') + ..write('createTime: $createTime, ') + ..write('updateTime: $updateTime, ') + ..write('deleteTime: $deleteTime, ') + ..write('annotations: $annotations, ') + ..write('reconciling: $reconciling, ') + ..write('etag: $etag') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + id, + parentType, + parentId, + projectEnvironmentId, + state, + displayName, + createTime, + updateTime, + deleteTime, + annotations, + reconciling, + etag, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is ProjectEnvironmentsData && + other.id == this.id && + other.parentType == this.parentType && + other.parentId == this.parentId && + other.projectEnvironmentId == this.projectEnvironmentId && + other.state == this.state && + other.displayName == this.displayName && + other.createTime == this.createTime && + other.updateTime == this.updateTime && + other.deleteTime == this.deleteTime && + other.annotations == this.annotations && + other.reconciling == this.reconciling && + other.etag == this.etag); +} + +class ProjectEnvironmentsCompanion + extends UpdateCompanion { + final Value id; + final Value parentType; + final Value parentId; + final Value projectEnvironmentId; + final Value state; + final Value displayName; + final Value createTime; + final Value updateTime; + final Value deleteTime; + final Value annotations; + final Value reconciling; + final Value etag; + final Value rowid; + const ProjectEnvironmentsCompanion({ + this.id = const Value.absent(), + this.parentType = const Value.absent(), + this.parentId = const Value.absent(), + this.projectEnvironmentId = const Value.absent(), + this.state = const Value.absent(), + this.displayName = const Value.absent(), + this.createTime = const Value.absent(), + this.updateTime = const Value.absent(), + this.deleteTime = const Value.absent(), + this.annotations = const Value.absent(), + this.reconciling = const Value.absent(), + this.etag = const Value.absent(), + this.rowid = const Value.absent(), + }); + ProjectEnvironmentsCompanion.insert({ + required String id, + required String parentType, + required String parentId, + required String projectEnvironmentId, + this.state = const Value.absent(), + this.displayName = const Value.absent(), + this.createTime = const Value.absent(), + this.updateTime = const Value.absent(), + this.deleteTime = const Value.absent(), + this.annotations = const Value.absent(), + required bool reconciling, + required String etag, + this.rowid = const Value.absent(), + }) : id = Value(id), + parentType = Value(parentType), + parentId = Value(parentId), + projectEnvironmentId = Value(projectEnvironmentId), + reconciling = Value(reconciling), + etag = Value(etag); + static Insertable custom({ + Expression? id, + Expression? parentType, + Expression? parentId, + Expression? projectEnvironmentId, + Expression? state, + Expression? displayName, + Expression? createTime, + Expression? updateTime, + Expression? deleteTime, + Expression? annotations, + Expression? reconciling, + Expression? etag, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (parentType != null) 'parent_type': parentType, + if (parentId != null) 'parent_id': parentId, + if (projectEnvironmentId != null) + 'project_environment_id': projectEnvironmentId, + if (state != null) 'state': state, + if (displayName != null) 'display_name': displayName, + if (createTime != null) 'create_time': createTime, + if (updateTime != null) 'update_time': updateTime, + if (deleteTime != null) 'delete_time': deleteTime, + if (annotations != null) 'annotations': annotations, + if (reconciling != null) 'reconciling': reconciling, + if (etag != null) 'etag': etag, + if (rowid != null) 'rowid': rowid, + }); + } + + ProjectEnvironmentsCompanion copyWith({ + Value? id, + Value? parentType, + Value? parentId, + Value? projectEnvironmentId, + Value? state, + Value? displayName, + Value? createTime, + Value? updateTime, + Value? deleteTime, + Value? annotations, + Value? reconciling, + Value? etag, + Value? rowid, + }) { + return ProjectEnvironmentsCompanion( + id: id ?? this.id, + parentType: parentType ?? this.parentType, + parentId: parentId ?? this.parentId, + projectEnvironmentId: projectEnvironmentId ?? this.projectEnvironmentId, + state: state ?? this.state, + displayName: displayName ?? this.displayName, + createTime: createTime ?? this.createTime, + updateTime: updateTime ?? this.updateTime, + deleteTime: deleteTime ?? this.deleteTime, + annotations: annotations ?? this.annotations, + reconciling: reconciling ?? this.reconciling, + etag: etag ?? this.etag, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (parentType.present) { + map['parent_type'] = Variable(parentType.value); + } + if (parentId.present) { + map['parent_id'] = Variable(parentId.value); + } + if (projectEnvironmentId.present) { + map['project_environment_id'] = Variable( + projectEnvironmentId.value, + ); + } + if (state.present) { + map['state'] = Variable(state.value); + } + if (displayName.present) { + map['display_name'] = Variable(displayName.value); + } + if (createTime.present) { + map['create_time'] = Variable(createTime.value); + } + if (updateTime.present) { + map['update_time'] = Variable(updateTime.value); + } + if (deleteTime.present) { + map['delete_time'] = Variable(deleteTime.value); + } + if (annotations.present) { + map['annotations'] = Variable(annotations.value); + } + if (reconciling.present) { + map['reconciling'] = Variable(reconciling.value); + } + if (etag.present) { + map['etag'] = Variable(etag.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('ProjectEnvironmentsCompanion(') + ..write('id: $id, ') + ..write('parentType: $parentType, ') + ..write('parentId: $parentId, ') + ..write('projectEnvironmentId: $projectEnvironmentId, ') + ..write('state: $state, ') + ..write('displayName: $displayName, ') + ..write('createTime: $createTime, ') + ..write('updateTime: $updateTime, ') + ..write('deleteTime: $deleteTime, ') + ..write('annotations: $annotations, ') + ..write('reconciling: $reconciling, ') + ..write('etag: $etag, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +class ProjectEnvironmentAsts extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + ProjectEnvironmentAsts(this.attachedDatabase, [this._alias]); + late final GeneratedColumn projectEnvironmentId = + GeneratedColumn( + 'project_environment_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); + late final GeneratedColumn ast = GeneratedColumn( + 'ast', + aliasedName, + false, + type: DriftSqlType.blob, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn version = GeneratedColumn( + 'version', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn digest = GeneratedColumn( + 'digest', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL GENERATED ALWAYS AS (hex(md5(ast))) STORED', + ); + @override + List get $columns => [ + projectEnvironmentId, + ast, + version, + digest, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'project_environment_asts'; + @override + Set get $primaryKey => {projectEnvironmentId}; + @override + ProjectEnvironmentAstsData map( + Map data, { + String? tablePrefix, + }) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return ProjectEnvironmentAstsData( + projectEnvironmentId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}project_environment_id'], + )!, + ast: + attachedDatabase.typeMapping.read( + DriftSqlType.blob, + data['${effectivePrefix}ast'], + )!, + version: + attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}version'], + )!, + digest: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}digest'], + )!, + ); + } + + @override + ProjectEnvironmentAsts createAlias(String alias) { + return ProjectEnvironmentAsts(attachedDatabase, alias); + } + + @override + bool get withoutRowId => true; + @override + List get customConstraints => const [ + 'CONSTRAINT fk_environment_metadata_project_environment_id FOREIGN KEY(project_environment_id)REFERENCES project_environments(id)ON UPDATE CASCADE ON DELETE CASCADE', + ]; + @override + bool get dontWriteConstraints => true; +} + +class ProjectEnvironmentAstsData extends DataClass + implements Insertable { + final String projectEnvironmentId; + final Uint8List ast; + final int version; + final String digest; + const ProjectEnvironmentAstsData({ + required this.projectEnvironmentId, + required this.ast, + required this.version, + required this.digest, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['project_environment_id'] = Variable(projectEnvironmentId); + map['ast'] = Variable(ast); + map['version'] = Variable(version); + map['digest'] = Variable(digest); + return map; + } + + ProjectEnvironmentAstsCompanion toCompanion(bool nullToAbsent) { + return ProjectEnvironmentAstsCompanion( + projectEnvironmentId: Value(projectEnvironmentId), + ast: Value(ast), + version: Value(version), + digest: Value(digest), + ); + } + + factory ProjectEnvironmentAstsData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return ProjectEnvironmentAstsData( + projectEnvironmentId: serializer.fromJson( + json['projectEnvironmentId'], + ), + ast: serializer.fromJson(json['ast']), + version: serializer.fromJson(json['version']), + digest: serializer.fromJson(json['digest']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'projectEnvironmentId': serializer.toJson(projectEnvironmentId), + 'ast': serializer.toJson(ast), + 'version': serializer.toJson(version), + 'digest': serializer.toJson(digest), + }; + } + + ProjectEnvironmentAstsData copyWith({ + String? projectEnvironmentId, + Uint8List? ast, + int? version, + String? digest, + }) => ProjectEnvironmentAstsData( + projectEnvironmentId: projectEnvironmentId ?? this.projectEnvironmentId, + ast: ast ?? this.ast, + version: version ?? this.version, + digest: digest ?? this.digest, + ); + ProjectEnvironmentAstsData copyWithCompanion( + ProjectEnvironmentAstsCompanion data, + ) { + return ProjectEnvironmentAstsData( + projectEnvironmentId: + data.projectEnvironmentId.present + ? data.projectEnvironmentId.value + : this.projectEnvironmentId, + ast: data.ast.present ? data.ast.value : this.ast, + version: data.version.present ? data.version.value : this.version, + digest: data.digest.present ? data.digest.value : this.digest, + ); + } + + @override + String toString() { + return (StringBuffer('ProjectEnvironmentAstsData(') + ..write('projectEnvironmentId: $projectEnvironmentId, ') + ..write('ast: $ast, ') + ..write('version: $version, ') + ..write('digest: $digest') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + projectEnvironmentId, + $driftBlobEquality.hash(ast), + version, + digest, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is ProjectEnvironmentAstsData && + other.projectEnvironmentId == this.projectEnvironmentId && + $driftBlobEquality.equals(other.ast, this.ast) && + other.version == this.version && + other.digest == this.digest); +} + +class ProjectEnvironmentAstsCompanion + extends UpdateCompanion { + final Value projectEnvironmentId; + final Value ast; + final Value version; + final Value digest; + const ProjectEnvironmentAstsCompanion({ + this.projectEnvironmentId = const Value.absent(), + this.ast = const Value.absent(), + this.version = const Value.absent(), + this.digest = const Value.absent(), + }); + ProjectEnvironmentAstsCompanion.insert({ + required String projectEnvironmentId, + required Uint8List ast, + required int version, + required String digest, + }) : projectEnvironmentId = Value(projectEnvironmentId), + ast = Value(ast), + version = Value(version), + digest = Value(digest); + static Insertable custom({ + Expression? projectEnvironmentId, + Expression? ast, + Expression? version, + Expression? digest, + }) { + return RawValuesInsertable({ + if (projectEnvironmentId != null) + 'project_environment_id': projectEnvironmentId, + if (ast != null) 'ast': ast, + if (version != null) 'version': version, + if (digest != null) 'digest': digest, + }); + } + + ProjectEnvironmentAstsCompanion copyWith({ + Value? projectEnvironmentId, + Value? ast, + Value? version, + Value? digest, + }) { + return ProjectEnvironmentAstsCompanion( + projectEnvironmentId: projectEnvironmentId ?? this.projectEnvironmentId, + ast: ast ?? this.ast, + version: version ?? this.version, + digest: digest ?? this.digest, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (projectEnvironmentId.present) { + map['project_environment_id'] = Variable( + projectEnvironmentId.value, + ); + } + if (ast.present) { + map['ast'] = Variable(ast.value); + } + if (version.present) { + map['version'] = Variable(version.value); + } + if (digest.present) { + map['digest'] = Variable(digest.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('ProjectEnvironmentAstsCompanion(') + ..write('projectEnvironmentId: $projectEnvironmentId, ') + ..write('ast: $ast, ') + ..write('version: $version, ') + ..write('digest: $digest') + ..write(')')) + .toString(); + } +} + +class ProjectEnvironmentAssets extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + ProjectEnvironmentAssets(this.attachedDatabase, [this._alias]); + late final GeneratedColumn projectEnvironmentId = + GeneratedColumn( + 'project_environment_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn type = GeneratedColumn( + 'type', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn bucket = GeneratedColumn( + 'bucket', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn name = GeneratedColumn( + 'name', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn etag = GeneratedColumn( + 'etag', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + @override + List get $columns => [ + projectEnvironmentId, + type, + bucket, + name, + etag, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'project_environment_assets'; + @override + Set get $primaryKey => {projectEnvironmentId, name}; + @override + ProjectEnvironmentAssetsData map( + Map data, { + String? tablePrefix, + }) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return ProjectEnvironmentAssetsData( + projectEnvironmentId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}project_environment_id'], + )!, + type: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}type'], + )!, + bucket: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}bucket'], + )!, + name: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}name'], + )!, + etag: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}etag'], + )!, + ); + } + + @override + ProjectEnvironmentAssets createAlias(String alias) { + return ProjectEnvironmentAssets(attachedDatabase, alias); + } + + @override + bool get withoutRowId => true; + @override + List get customConstraints => const [ + 'PRIMARY KEY(project_environment_id, name)', + 'CONSTRAINT fk_environment_assets_project_environment_id FOREIGN KEY(project_environment_id)REFERENCES project_environments(id)ON UPDATE CASCADE ON DELETE CASCADE', + ]; + @override + bool get dontWriteConstraints => true; +} + +class ProjectEnvironmentAssetsData extends DataClass + implements Insertable { + final String projectEnvironmentId; + final String type; + final String bucket; + final String name; + final String etag; + const ProjectEnvironmentAssetsData({ + required this.projectEnvironmentId, + required this.type, + required this.bucket, + required this.name, + required this.etag, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['project_environment_id'] = Variable(projectEnvironmentId); + map['type'] = Variable(type); + map['bucket'] = Variable(bucket); + map['name'] = Variable(name); + map['etag'] = Variable(etag); + return map; + } + + ProjectEnvironmentAssetsCompanion toCompanion(bool nullToAbsent) { + return ProjectEnvironmentAssetsCompanion( + projectEnvironmentId: Value(projectEnvironmentId), + type: Value(type), + bucket: Value(bucket), + name: Value(name), + etag: Value(etag), + ); + } + + factory ProjectEnvironmentAssetsData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return ProjectEnvironmentAssetsData( + projectEnvironmentId: serializer.fromJson( + json['projectEnvironmentId'], + ), + type: serializer.fromJson(json['type']), + bucket: serializer.fromJson(json['bucket']), + name: serializer.fromJson(json['name']), + etag: serializer.fromJson(json['etag']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'projectEnvironmentId': serializer.toJson(projectEnvironmentId), + 'type': serializer.toJson(type), + 'bucket': serializer.toJson(bucket), + 'name': serializer.toJson(name), + 'etag': serializer.toJson(etag), + }; + } + + ProjectEnvironmentAssetsData copyWith({ + String? projectEnvironmentId, + String? type, + String? bucket, + String? name, + String? etag, + }) => ProjectEnvironmentAssetsData( + projectEnvironmentId: projectEnvironmentId ?? this.projectEnvironmentId, + type: type ?? this.type, + bucket: bucket ?? this.bucket, + name: name ?? this.name, + etag: etag ?? this.etag, + ); + ProjectEnvironmentAssetsData copyWithCompanion( + ProjectEnvironmentAssetsCompanion data, + ) { + return ProjectEnvironmentAssetsData( + projectEnvironmentId: + data.projectEnvironmentId.present + ? data.projectEnvironmentId.value + : this.projectEnvironmentId, + type: data.type.present ? data.type.value : this.type, + bucket: data.bucket.present ? data.bucket.value : this.bucket, + name: data.name.present ? data.name.value : this.name, + etag: data.etag.present ? data.etag.value : this.etag, + ); + } + + @override + String toString() { + return (StringBuffer('ProjectEnvironmentAssetsData(') + ..write('projectEnvironmentId: $projectEnvironmentId, ') + ..write('type: $type, ') + ..write('bucket: $bucket, ') + ..write('name: $name, ') + ..write('etag: $etag') + ..write(')')) + .toString(); + } + + @override + int get hashCode => + Object.hash(projectEnvironmentId, type, bucket, name, etag); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is ProjectEnvironmentAssetsData && + other.projectEnvironmentId == this.projectEnvironmentId && + other.type == this.type && + other.bucket == this.bucket && + other.name == this.name && + other.etag == this.etag); +} + +class ProjectEnvironmentAssetsCompanion + extends UpdateCompanion { + final Value projectEnvironmentId; + final Value type; + final Value bucket; + final Value name; + final Value etag; + const ProjectEnvironmentAssetsCompanion({ + this.projectEnvironmentId = const Value.absent(), + this.type = const Value.absent(), + this.bucket = const Value.absent(), + this.name = const Value.absent(), + this.etag = const Value.absent(), + }); + ProjectEnvironmentAssetsCompanion.insert({ + required String projectEnvironmentId, + required String type, + required String bucket, + required String name, + required String etag, + }) : projectEnvironmentId = Value(projectEnvironmentId), + type = Value(type), + bucket = Value(bucket), + name = Value(name), + etag = Value(etag); + static Insertable custom({ + Expression? projectEnvironmentId, + Expression? type, + Expression? bucket, + Expression? name, + Expression? etag, + }) { + return RawValuesInsertable({ + if (projectEnvironmentId != null) + 'project_environment_id': projectEnvironmentId, + if (type != null) 'type': type, + if (bucket != null) 'bucket': bucket, + if (name != null) 'name': name, + if (etag != null) 'etag': etag, + }); + } + + ProjectEnvironmentAssetsCompanion copyWith({ + Value? projectEnvironmentId, + Value? type, + Value? bucket, + Value? name, + Value? etag, + }) { + return ProjectEnvironmentAssetsCompanion( + projectEnvironmentId: projectEnvironmentId ?? this.projectEnvironmentId, + type: type ?? this.type, + bucket: bucket ?? this.bucket, + name: name ?? this.name, + etag: etag ?? this.etag, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (projectEnvironmentId.present) { + map['project_environment_id'] = Variable( + projectEnvironmentId.value, + ); + } + if (type.present) { + map['type'] = Variable(type.value); + } + if (bucket.present) { + map['bucket'] = Variable(bucket.value); + } + if (name.present) { + map['name'] = Variable(name.value); + } + if (etag.present) { + map['etag'] = Variable(etag.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('ProjectEnvironmentAssetsCompanion(') + ..write('projectEnvironmentId: $projectEnvironmentId, ') + ..write('type: $type, ') + ..write('bucket: $bucket, ') + ..write('name: $name, ') + ..write('etag: $etag') + ..write(')')) + .toString(); + } +} + +class ProjectEnvironmentStates extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + ProjectEnvironmentStates(this.attachedDatabase, [this._alias]); + late final GeneratedColumn projectEnvironmentId = + GeneratedColumn( + 'project_environment_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); + late final GeneratedColumn flyAppName = GeneratedColumn( + 'fly_app_name', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn flyVolumeName = GeneratedColumn( + 'fly_volume_name', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn domainName = GeneratedColumn( + 'domain_name', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + @override + List get $columns => [ + projectEnvironmentId, + flyAppName, + flyVolumeName, + domainName, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'project_environment_states'; + @override + Set get $primaryKey => {projectEnvironmentId}; + @override + ProjectEnvironmentStatesData map( + Map data, { + String? tablePrefix, + }) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return ProjectEnvironmentStatesData( + projectEnvironmentId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}project_environment_id'], + )!, + flyAppName: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}fly_app_name'], + ), + flyVolumeName: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}fly_volume_name'], + ), + domainName: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}domain_name'], + ), + ); + } + + @override + ProjectEnvironmentStates createAlias(String alias) { + return ProjectEnvironmentStates(attachedDatabase, alias); + } + + @override + bool get withoutRowId => true; + @override + List get customConstraints => const [ + 'CONSTRAINT fk_project_environment_state_project_environment_id FOREIGN KEY(project_environment_id)REFERENCES project_environments(id)ON UPDATE CASCADE ON DELETE CASCADE', + ]; + @override + bool get dontWriteConstraints => true; +} + +class ProjectEnvironmentStatesData extends DataClass + implements Insertable { + final String projectEnvironmentId; + final String? flyAppName; + final String? flyVolumeName; + final String? domainName; + const ProjectEnvironmentStatesData({ + required this.projectEnvironmentId, + this.flyAppName, + this.flyVolumeName, + this.domainName, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['project_environment_id'] = Variable(projectEnvironmentId); + if (!nullToAbsent || flyAppName != null) { + map['fly_app_name'] = Variable(flyAppName); + } + if (!nullToAbsent || flyVolumeName != null) { + map['fly_volume_name'] = Variable(flyVolumeName); + } + if (!nullToAbsent || domainName != null) { + map['domain_name'] = Variable(domainName); + } + return map; + } + + ProjectEnvironmentStatesCompanion toCompanion(bool nullToAbsent) { + return ProjectEnvironmentStatesCompanion( + projectEnvironmentId: Value(projectEnvironmentId), + flyAppName: + flyAppName == null && nullToAbsent + ? const Value.absent() + : Value(flyAppName), + flyVolumeName: + flyVolumeName == null && nullToAbsent + ? const Value.absent() + : Value(flyVolumeName), + domainName: + domainName == null && nullToAbsent + ? const Value.absent() + : Value(domainName), + ); + } + + factory ProjectEnvironmentStatesData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return ProjectEnvironmentStatesData( + projectEnvironmentId: serializer.fromJson( + json['projectEnvironmentId'], + ), + flyAppName: serializer.fromJson(json['flyAppName']), + flyVolumeName: serializer.fromJson(json['flyVolumeName']), + domainName: serializer.fromJson(json['domainName']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'projectEnvironmentId': serializer.toJson(projectEnvironmentId), + 'flyAppName': serializer.toJson(flyAppName), + 'flyVolumeName': serializer.toJson(flyVolumeName), + 'domainName': serializer.toJson(domainName), + }; + } + + ProjectEnvironmentStatesData copyWith({ + String? projectEnvironmentId, + Value flyAppName = const Value.absent(), + Value flyVolumeName = const Value.absent(), + Value domainName = const Value.absent(), + }) => ProjectEnvironmentStatesData( + projectEnvironmentId: projectEnvironmentId ?? this.projectEnvironmentId, + flyAppName: flyAppName.present ? flyAppName.value : this.flyAppName, + flyVolumeName: + flyVolumeName.present ? flyVolumeName.value : this.flyVolumeName, + domainName: domainName.present ? domainName.value : this.domainName, + ); + ProjectEnvironmentStatesData copyWithCompanion( + ProjectEnvironmentStatesCompanion data, + ) { + return ProjectEnvironmentStatesData( + projectEnvironmentId: + data.projectEnvironmentId.present + ? data.projectEnvironmentId.value + : this.projectEnvironmentId, + flyAppName: + data.flyAppName.present ? data.flyAppName.value : this.flyAppName, + flyVolumeName: + data.flyVolumeName.present + ? data.flyVolumeName.value + : this.flyVolumeName, + domainName: + data.domainName.present ? data.domainName.value : this.domainName, + ); + } + + @override + String toString() { + return (StringBuffer('ProjectEnvironmentStatesData(') + ..write('projectEnvironmentId: $projectEnvironmentId, ') + ..write('flyAppName: $flyAppName, ') + ..write('flyVolumeName: $flyVolumeName, ') + ..write('domainName: $domainName') + ..write(')')) + .toString(); + } + + @override + int get hashCode => + Object.hash(projectEnvironmentId, flyAppName, flyVolumeName, domainName); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is ProjectEnvironmentStatesData && + other.projectEnvironmentId == this.projectEnvironmentId && + other.flyAppName == this.flyAppName && + other.flyVolumeName == this.flyVolumeName && + other.domainName == this.domainName); +} + +class ProjectEnvironmentStatesCompanion + extends UpdateCompanion { + final Value projectEnvironmentId; + final Value flyAppName; + final Value flyVolumeName; + final Value domainName; + const ProjectEnvironmentStatesCompanion({ + this.projectEnvironmentId = const Value.absent(), + this.flyAppName = const Value.absent(), + this.flyVolumeName = const Value.absent(), + this.domainName = const Value.absent(), + }); + ProjectEnvironmentStatesCompanion.insert({ + required String projectEnvironmentId, + this.flyAppName = const Value.absent(), + this.flyVolumeName = const Value.absent(), + this.domainName = const Value.absent(), + }) : projectEnvironmentId = Value(projectEnvironmentId); + static Insertable custom({ + Expression? projectEnvironmentId, + Expression? flyAppName, + Expression? flyVolumeName, + Expression? domainName, + }) { + return RawValuesInsertable({ + if (projectEnvironmentId != null) + 'project_environment_id': projectEnvironmentId, + if (flyAppName != null) 'fly_app_name': flyAppName, + if (flyVolumeName != null) 'fly_volume_name': flyVolumeName, + if (domainName != null) 'domain_name': domainName, + }); + } + + ProjectEnvironmentStatesCompanion copyWith({ + Value? projectEnvironmentId, + Value? flyAppName, + Value? flyVolumeName, + Value? domainName, + }) { + return ProjectEnvironmentStatesCompanion( + projectEnvironmentId: projectEnvironmentId ?? this.projectEnvironmentId, + flyAppName: flyAppName ?? this.flyAppName, + flyVolumeName: flyVolumeName ?? this.flyVolumeName, + domainName: domainName ?? this.domainName, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (projectEnvironmentId.present) { + map['project_environment_id'] = Variable( + projectEnvironmentId.value, + ); + } + if (flyAppName.present) { + map['fly_app_name'] = Variable(flyAppName.value); + } + if (flyVolumeName.present) { + map['fly_volume_name'] = Variable(flyVolumeName.value); + } + if (domainName.present) { + map['domain_name'] = Variable(domainName.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('ProjectEnvironmentStatesCompanion(') + ..write('projectEnvironmentId: $projectEnvironmentId, ') + ..write('flyAppName: $flyAppName, ') + ..write('flyVolumeName: $flyVolumeName, ') + ..write('domainName: $domainName') + ..write(')')) + .toString(); + } +} + +class Operations extends Table with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + Operations(this.attachedDatabase, [this._alias]); + late final GeneratedColumn id = GeneratedColumn( + 'id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); + late final GeneratedColumn metadata = GeneratedColumn( + 'metadata', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn response = GeneratedColumn( + 'response', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn error = GeneratedColumn( + 'error', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn done = GeneratedColumn( + 'done', + aliasedName, + false, + type: DriftSqlType.bool, + requiredDuringInsert: true, + $customConstraints: + 'NOT NULL GENERATED ALWAYS AS (response IS NOT NULL OR error IS NOT NULL) VIRTUAL', + ); + late final GeneratedColumn createTime = GeneratedColumn( + 'create_time', + aliasedName, + false, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT (unixepoch(\'now\', \'subsec\'))', + defaultValue: const CustomExpression('unixepoch(\'now\', \'subsec\')'), + ); + late final GeneratedColumn fullResourceName = GeneratedColumn( + 'full_resource_name', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn ownerType = GeneratedColumn( + 'owner_type', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn ownerId = GeneratedColumn( + 'owner_id', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn resourceType = GeneratedColumn( + 'resource_type', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn resourceId = GeneratedColumn( + 'resource_id', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + @override + List get $columns => [ + id, + metadata, + response, + error, + done, + createTime, + fullResourceName, + ownerType, + ownerId, + resourceType, + resourceId, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'operations'; + @override + Set get $primaryKey => {id}; + @override + OperationsData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return OperationsData( + id: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}id'], + )!, + metadata: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}metadata'], + ), + response: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}response'], + ), + error: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}error'], + ), + done: + attachedDatabase.typeMapping.read( + DriftSqlType.bool, + data['${effectivePrefix}done'], + )!, + createTime: + attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}create_time'], + )!, + fullResourceName: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}full_resource_name'], + ), + ownerType: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}owner_type'], + ), + ownerId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}owner_id'], + ), + resourceType: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}resource_type'], + ), + resourceId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}resource_id'], + ), + ); + } + + @override + Operations createAlias(String alias) { + return Operations(attachedDatabase, alias); + } + + @override + bool get dontWriteConstraints => true; +} + +class OperationsData extends DataClass implements Insertable { + final String id; + final String? metadata; + final String? response; + final String? error; + final bool done; + final DateTime createTime; + final String? fullResourceName; + final String? ownerType; + final String? ownerId; + final String? resourceType; + final String? resourceId; + const OperationsData({ + required this.id, + this.metadata, + this.response, + this.error, + required this.done, + required this.createTime, + this.fullResourceName, + this.ownerType, + this.ownerId, + this.resourceType, + this.resourceId, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + if (!nullToAbsent || metadata != null) { + map['metadata'] = Variable(metadata); + } + if (!nullToAbsent || response != null) { + map['response'] = Variable(response); + } + if (!nullToAbsent || error != null) { + map['error'] = Variable(error); + } + map['done'] = Variable(done); + map['create_time'] = Variable(createTime); + if (!nullToAbsent || fullResourceName != null) { + map['full_resource_name'] = Variable(fullResourceName); + } + if (!nullToAbsent || ownerType != null) { + map['owner_type'] = Variable(ownerType); + } + if (!nullToAbsent || ownerId != null) { + map['owner_id'] = Variable(ownerId); + } + if (!nullToAbsent || resourceType != null) { + map['resource_type'] = Variable(resourceType); + } + if (!nullToAbsent || resourceId != null) { + map['resource_id'] = Variable(resourceId); + } + return map; + } + + OperationsCompanion toCompanion(bool nullToAbsent) { + return OperationsCompanion( + id: Value(id), + metadata: + metadata == null && nullToAbsent + ? const Value.absent() + : Value(metadata), + response: + response == null && nullToAbsent + ? const Value.absent() + : Value(response), + error: + error == null && nullToAbsent ? const Value.absent() : Value(error), + done: Value(done), + createTime: Value(createTime), + fullResourceName: + fullResourceName == null && nullToAbsent + ? const Value.absent() + : Value(fullResourceName), + ownerType: + ownerType == null && nullToAbsent + ? const Value.absent() + : Value(ownerType), + ownerId: + ownerId == null && nullToAbsent + ? const Value.absent() + : Value(ownerId), + resourceType: + resourceType == null && nullToAbsent + ? const Value.absent() + : Value(resourceType), + resourceId: + resourceId == null && nullToAbsent + ? const Value.absent() + : Value(resourceId), + ); + } + + factory OperationsData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return OperationsData( + id: serializer.fromJson(json['id']), + metadata: serializer.fromJson(json['metadata']), + response: serializer.fromJson(json['response']), + error: serializer.fromJson(json['error']), + done: serializer.fromJson(json['done']), + createTime: serializer.fromJson(json['createTime']), + fullResourceName: serializer.fromJson(json['fullResourceName']), + ownerType: serializer.fromJson(json['ownerType']), + ownerId: serializer.fromJson(json['ownerId']), + resourceType: serializer.fromJson(json['resourceType']), + resourceId: serializer.fromJson(json['resourceId']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'metadata': serializer.toJson(metadata), + 'response': serializer.toJson(response), + 'error': serializer.toJson(error), + 'done': serializer.toJson(done), + 'createTime': serializer.toJson(createTime), + 'fullResourceName': serializer.toJson(fullResourceName), + 'ownerType': serializer.toJson(ownerType), + 'ownerId': serializer.toJson(ownerId), + 'resourceType': serializer.toJson(resourceType), + 'resourceId': serializer.toJson(resourceId), + }; + } + + OperationsData copyWith({ + String? id, + Value metadata = const Value.absent(), + Value response = const Value.absent(), + Value error = const Value.absent(), + bool? done, + DateTime? createTime, + Value fullResourceName = const Value.absent(), + Value ownerType = const Value.absent(), + Value ownerId = const Value.absent(), + Value resourceType = const Value.absent(), + Value resourceId = const Value.absent(), + }) => OperationsData( + id: id ?? this.id, + metadata: metadata.present ? metadata.value : this.metadata, + response: response.present ? response.value : this.response, + error: error.present ? error.value : this.error, + done: done ?? this.done, + createTime: createTime ?? this.createTime, + fullResourceName: + fullResourceName.present + ? fullResourceName.value + : this.fullResourceName, + ownerType: ownerType.present ? ownerType.value : this.ownerType, + ownerId: ownerId.present ? ownerId.value : this.ownerId, + resourceType: resourceType.present ? resourceType.value : this.resourceType, + resourceId: resourceId.present ? resourceId.value : this.resourceId, + ); + OperationsData copyWithCompanion(OperationsCompanion data) { + return OperationsData( + id: data.id.present ? data.id.value : this.id, + metadata: data.metadata.present ? data.metadata.value : this.metadata, + response: data.response.present ? data.response.value : this.response, + error: data.error.present ? data.error.value : this.error, + done: data.done.present ? data.done.value : this.done, + createTime: + data.createTime.present ? data.createTime.value : this.createTime, + fullResourceName: + data.fullResourceName.present + ? data.fullResourceName.value + : this.fullResourceName, + ownerType: data.ownerType.present ? data.ownerType.value : this.ownerType, + ownerId: data.ownerId.present ? data.ownerId.value : this.ownerId, + resourceType: + data.resourceType.present + ? data.resourceType.value + : this.resourceType, + resourceId: + data.resourceId.present ? data.resourceId.value : this.resourceId, + ); + } + + @override + String toString() { + return (StringBuffer('OperationsData(') + ..write('id: $id, ') + ..write('metadata: $metadata, ') + ..write('response: $response, ') + ..write('error: $error, ') + ..write('done: $done, ') + ..write('createTime: $createTime, ') + ..write('fullResourceName: $fullResourceName, ') + ..write('ownerType: $ownerType, ') + ..write('ownerId: $ownerId, ') + ..write('resourceType: $resourceType, ') + ..write('resourceId: $resourceId') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + id, + metadata, + response, + error, + done, + createTime, + fullResourceName, + ownerType, + ownerId, + resourceType, + resourceId, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is OperationsData && + other.id == this.id && + other.metadata == this.metadata && + other.response == this.response && + other.error == this.error && + other.done == this.done && + other.createTime == this.createTime && + other.fullResourceName == this.fullResourceName && + other.ownerType == this.ownerType && + other.ownerId == this.ownerId && + other.resourceType == this.resourceType && + other.resourceId == this.resourceId); +} + +class OperationsCompanion extends UpdateCompanion { + final Value id; + final Value metadata; + final Value response; + final Value error; + final Value done; + final Value createTime; + final Value fullResourceName; + final Value ownerType; + final Value ownerId; + final Value resourceType; + final Value resourceId; + final Value rowid; + const OperationsCompanion({ + this.id = const Value.absent(), + this.metadata = const Value.absent(), + this.response = const Value.absent(), + this.error = const Value.absent(), + this.done = const Value.absent(), + this.createTime = const Value.absent(), + this.fullResourceName = const Value.absent(), + this.ownerType = const Value.absent(), + this.ownerId = const Value.absent(), + this.resourceType = const Value.absent(), + this.resourceId = const Value.absent(), + this.rowid = const Value.absent(), + }); + OperationsCompanion.insert({ + required String id, + this.metadata = const Value.absent(), + this.response = const Value.absent(), + this.error = const Value.absent(), + required bool done, + this.createTime = const Value.absent(), + this.fullResourceName = const Value.absent(), + this.ownerType = const Value.absent(), + this.ownerId = const Value.absent(), + this.resourceType = const Value.absent(), + this.resourceId = const Value.absent(), + this.rowid = const Value.absent(), + }) : id = Value(id), + done = Value(done); + static Insertable custom({ + Expression? id, + Expression? metadata, + Expression? response, + Expression? error, + Expression? done, + Expression? createTime, + Expression? fullResourceName, + Expression? ownerType, + Expression? ownerId, + Expression? resourceType, + Expression? resourceId, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (metadata != null) 'metadata': metadata, + if (response != null) 'response': response, + if (error != null) 'error': error, + if (done != null) 'done': done, + if (createTime != null) 'create_time': createTime, + if (fullResourceName != null) 'full_resource_name': fullResourceName, + if (ownerType != null) 'owner_type': ownerType, + if (ownerId != null) 'owner_id': ownerId, + if (resourceType != null) 'resource_type': resourceType, + if (resourceId != null) 'resource_id': resourceId, + if (rowid != null) 'rowid': rowid, + }); + } + + OperationsCompanion copyWith({ + Value? id, + Value? metadata, + Value? response, + Value? error, + Value? done, + Value? createTime, + Value? fullResourceName, + Value? ownerType, + Value? ownerId, + Value? resourceType, + Value? resourceId, + Value? rowid, + }) { + return OperationsCompanion( + id: id ?? this.id, + metadata: metadata ?? this.metadata, + response: response ?? this.response, + error: error ?? this.error, + done: done ?? this.done, + createTime: createTime ?? this.createTime, + fullResourceName: fullResourceName ?? this.fullResourceName, + ownerType: ownerType ?? this.ownerType, + ownerId: ownerId ?? this.ownerId, + resourceType: resourceType ?? this.resourceType, + resourceId: resourceId ?? this.resourceId, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (metadata.present) { + map['metadata'] = Variable(metadata.value); + } + if (response.present) { + map['response'] = Variable(response.value); + } + if (error.present) { + map['error'] = Variable(error.value); + } + if (done.present) { + map['done'] = Variable(done.value); + } + if (createTime.present) { + map['create_time'] = Variable(createTime.value); + } + if (fullResourceName.present) { + map['full_resource_name'] = Variable(fullResourceName.value); + } + if (ownerType.present) { + map['owner_type'] = Variable(ownerType.value); + } + if (ownerId.present) { + map['owner_id'] = Variable(ownerId.value); + } + if (resourceType.present) { + map['resource_type'] = Variable(resourceType.value); + } + if (resourceId.present) { + map['resource_id'] = Variable(resourceId.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('OperationsCompanion(') + ..write('id: $id, ') + ..write('metadata: $metadata, ') + ..write('response: $response, ') + ..write('error: $error, ') + ..write('done: $done, ') + ..write('createTime: $createTime, ') + ..write('fullResourceName: $fullResourceName, ') + ..write('ownerType: $ownerType, ') + ..write('ownerId: $ownerId, ') + ..write('resourceType: $resourceType, ') + ..write('resourceId: $resourceId, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +class DatabaseAtV1 extends GeneratedDatabase { + DatabaseAtV1(QueryExecutor e) : super(e); + late final CloudAuthUsers cloudAuthUsers = CloudAuthUsers(this); + late final CedarTypes cedarTypes = CedarTypes(this); + late final CedarEntities cedarEntities = CedarEntities(this); + late final Trigger cloudAuthUsersCreateTrg = Trigger( + 'CREATE TRIGGER IF NOT EXISTS cloud_auth_users_create_trg BEFORE INSERT ON cloud_auth_users BEGIN INSERT INTO cedar_entities (entity_type, entity_id) VALUES (\'Celest::User\', NEW.user_id);END', + 'cloud_auth_users_create_trg', + ); + late final CedarRelationships cedarRelationships = CedarRelationships(this); + late final Trigger cloudAuthUsersDeleteTrg = Trigger( + 'CREATE TRIGGER IF NOT EXISTS cloud_auth_users_delete_trg AFTER DELETE ON cloud_auth_users BEGIN DELETE FROM cedar_relationships WHERE(entity_type = \'Celest::User\' AND entity_id = OLD.user_id)OR(parent_type = \'Celest::User\' AND parent_id = OLD.user_id);DELETE FROM cedar_entities WHERE entity_id = OLD.user_id AND entity_type = \'Celest::User\';END', + 'cloud_auth_users_delete_trg', + ); + late final CloudAuthUserEmails cloudAuthUserEmails = CloudAuthUserEmails( + this, + ); + late final CloudAuthUserPhoneNumbers cloudAuthUserPhoneNumbers = + CloudAuthUserPhoneNumbers(this); + late final CloudAuthProjects cloudAuthProjects = CloudAuthProjects(this); + late final CloudAuthApis cloudAuthApis = CloudAuthApis(this); + late final Index cloudAuthApisProjectIdx = Index( + 'cloud_auth_apis_project_idx', + 'CREATE INDEX IF NOT EXISTS cloud_auth_apis_project_idx ON cloud_auth_apis (project_id)', + ); + late final Trigger cloudAuthApisCreateTrg = Trigger( + 'CREATE TRIGGER IF NOT EXISTS cloud_auth_apis_create_trg BEFORE INSERT ON cloud_auth_apis BEGIN INSERT INTO cedar_entities (entity_type, entity_id) VALUES (\'Celest::Api\', NEW.api_id);END', + 'cloud_auth_apis_create_trg', + ); + late final Trigger cloudAuthApisDeleteTrg = Trigger( + 'CREATE TRIGGER IF NOT EXISTS cloud_auth_apis_delete_trg AFTER DELETE ON cloud_auth_apis BEGIN DELETE FROM cedar_relationships WHERE entity_type = \'Celest::Api\' AND entity_id = OLD.api_id;DELETE FROM cedar_relationships WHERE parent_type = \'Celest::Api\' AND parent_id = OLD.api_id;DELETE FROM cedar_entities WHERE entity_type = \'Celest::Api\' AND entity_id = OLD.api_id;END', + 'cloud_auth_apis_delete_trg', + ); + late final CloudAuthFunctions cloudAuthFunctions = CloudAuthFunctions(this); + late final Index cloudAuthFunctionsApiIdx = Index( + 'cloud_auth_functions_api_idx', + 'CREATE INDEX IF NOT EXISTS cloud_auth_functions_api_idx ON cloud_auth_functions (api_id)', + ); + late final Trigger cloudAuthFunctionsCreateTrg = Trigger( + 'CREATE TRIGGER IF NOT EXISTS cloud_auth_functions_create_trg BEFORE INSERT ON cloud_auth_functions BEGIN INSERT INTO cedar_entities (entity_type, entity_id) VALUES (\'Celest::Function\', NEW.function_id);INSERT INTO cedar_relationships (entity_type, entity_id, parent_type, parent_id) VALUES (\'Celest::Function\', NEW.function_id, \'Celest::Api\', NEW.api_id);END', + 'cloud_auth_functions_create_trg', + ); + late final Trigger cloudAuthFunctionsDeleteTrg = Trigger( + 'CREATE TRIGGER IF NOT EXISTS cloud_auth_functions_delete_trg AFTER DELETE ON cloud_auth_functions BEGIN DELETE FROM cedar_relationships WHERE entity_type = \'Celest::Function\' AND entity_id = OLD.function_id;DELETE FROM cedar_relationships WHERE parent_type = \'Celest::Function\' AND parent_id = OLD.function_id;DELETE FROM cedar_entities WHERE entity_type = \'Celest::Function\' AND entity_id = OLD.function_id;END', + 'cloud_auth_functions_delete_trg', + ); + late final CloudAuthMeta cloudAuthMeta = CloudAuthMeta(this); + late final CloudAuthCryptoKeys cloudAuthCryptoKeys = CloudAuthCryptoKeys( + this, + ); + late final Index cloudAuthCryptoKeysExternalCryptoKeyIdIdx = Index( + 'cloud_auth_crypto_keys_external_crypto_key_id_idx', + 'CREATE INDEX IF NOT EXISTS cloud_auth_crypto_keys_external_crypto_key_id_idx ON cloud_auth_crypto_keys (external_crypto_key_id)', + ); + late final CloudAuthSessions cloudAuthSessions = CloudAuthSessions(this); + late final Index cloudAuthSessionsUserIdx = Index( + 'cloud_auth_sessions_user_idx', + 'CREATE INDEX IF NOT EXISTS cloud_auth_sessions_user_idx ON cloud_auth_sessions (user_id)', + ); + late final Index cloudAuthSessionsCryptoKeyIdx = Index( + 'cloud_auth_sessions_crypto_key_idx', + 'CREATE INDEX IF NOT EXISTS cloud_auth_sessions_crypto_key_idx ON cloud_auth_sessions (crypto_key_id)', + ); + late final Index cloudAuthSessionsExternalSessionIdIdx = Index( + 'cloud_auth_sessions_external_session_id_idx', + 'CREATE INDEX IF NOT EXISTS cloud_auth_sessions_external_session_id_idx ON cloud_auth_sessions (external_session_id)', + ); + late final Trigger cloudAuthSessionsUpdateTimeTrg = Trigger( + 'CREATE TRIGGER IF NOT EXISTS cloud_auth_sessions_update_time_trg AFTER UPDATE ON cloud_auth_sessions BEGIN UPDATE cloud_auth_sessions SET update_time = unixepoch(\'now\', \'subsec\') WHERE "rowid" = OLD."rowid";END', + 'cloud_auth_sessions_update_time_trg', + ); + late final CloudAuthOtpCodes cloudAuthOtpCodes = CloudAuthOtpCodes(this); + late final Index cloudAuthOtpCodesSessionIdIdx = Index( + 'cloud_auth_otp_codes_session_id_idx', + 'CREATE INDEX IF NOT EXISTS cloud_auth_otp_codes_session_id_idx ON cloud_auth_otp_codes (session_id)', + ); + late final CloudAuthCorks cloudAuthCorks = CloudAuthCorks(this); + late final Index cloudAuthCorksCryptoKeyIdx = Index( + 'cloud_auth_corks_crypto_key_idx', + 'CREATE INDEX IF NOT EXISTS cloud_auth_corks_crypto_key_idx ON cloud_auth_corks (crypto_key_id)', + ); + late final Index cloudAuthCorksBearerIdx = Index( + 'cloud_auth_corks_bearer_idx', + 'CREATE INDEX IF NOT EXISTS cloud_auth_corks_bearer_idx ON cloud_auth_corks (bearer_type, bearer_id)', + ); + late final Index cloudAuthCorksAudienceIdx = Index( + 'cloud_auth_corks_audience_idx', + 'CREATE INDEX IF NOT EXISTS cloud_auth_corks_audience_idx ON cloud_auth_corks (audience_type, audience_id)', + ); + late final Index cloudAuthCorksIssuerIdx = Index( + 'cloud_auth_corks_issuer_idx', + 'CREATE INDEX IF NOT EXISTS cloud_auth_corks_issuer_idx ON cloud_auth_corks (issuer_type, issuer_id)', + ); + late final Index cedarRelationshipsFkEntityIdx = Index( + 'cedar_relationships_fk_entity_idx', + 'CREATE INDEX IF NOT EXISTS cedar_relationships_fk_entity_idx ON cedar_relationships (entity_type, entity_id)', + ); + late final Index cedarRelationshipsFkParentIdx = Index( + 'cedar_relationships_fk_parent_idx', + 'CREATE INDEX IF NOT EXISTS cedar_relationships_fk_parent_idx ON cedar_relationships (parent_type, parent_id)', + ); + late final CedarPolicies cedarPolicies = CedarPolicies(this); + late final CedarPolicyTemplates cedarPolicyTemplates = CedarPolicyTemplates( + this, + ); + late final CedarPolicyTemplateLinks cedarPolicyTemplateLinks = + CedarPolicyTemplateLinks(this); + late final Index cedarPolicyTemplateLinksFkTemplateIdIdx = Index( + 'cedar_policy_template_links_fk_template_id_idx', + 'CREATE INDEX IF NOT EXISTS cedar_policy_template_links_fk_template_id_idx ON cedar_policy_template_links (template_id)', + ); + late final Index cedarPolicyTemplateLinksFkPrincipalIdx = Index( + 'cedar_policy_template_links_fk_principal_idx', + 'CREATE INDEX IF NOT EXISTS cedar_policy_template_links_fk_principal_idx ON cedar_policy_template_links (principal_type, principal_id)', + ); + late final Index cedarPolicyTemplateLinksFkResourceIdx = Index( + 'cedar_policy_template_links_fk_resource_idx', + 'CREATE INDEX IF NOT EXISTS cedar_policy_template_links_fk_resource_idx ON cedar_policy_template_links (resource_type, resource_id)', + ); + late final CedarAuthorizationLogs cedarAuthorizationLogs = + CedarAuthorizationLogs(this); + late final UserMemberships userMemberships = UserMemberships(this); + late final Index userMembershipsParentIdx = Index( + 'user_memberships_parent_idx', + 'CREATE INDEX IF NOT EXISTS user_memberships_parent_idx ON user_memberships (parent_type, parent_id)', + ); + late final Trigger userMembershipsCreateTrg = Trigger( + 'CREATE TRIGGER IF NOT EXISTS user_memberships_create_trg BEFORE INSERT ON user_memberships BEGIN INSERT INTO cedar_entities (entity_type, entity_id, attribute_json) VALUES (NEW.parent_type || \'::Member\', NEW.membership_id, json_object(\'role\', json_object(\'type\', \'Celest::Role\', \'id\', NEW.role), \'parent\', json_object(\'type\', NEW.parent_type, \'id\', NEW.parent_id)));INSERT INTO cedar_relationships (entity_type, entity_id, parent_type, parent_id) VALUES (\'Celest::User\', NEW.user_id, NEW.parent_type || \'::Member\', NEW.membership_id);END', + 'user_memberships_create_trg', + ); + late final Trigger userMembershipsUpdateTrg = Trigger( + 'CREATE TRIGGER IF NOT EXISTS user_memberships_update_trg AFTER UPDATE ON user_memberships BEGIN UPDATE cedar_entities SET attribute_json = json_object(\'role\', json_object(\'type\', \'Celest::Role\', \'id\', NEW.role), \'parent\', json_object(\'type\', OLD.parent_type, \'id\', OLD.parent_id)) WHERE entity_id = OLD.membership_id AND entity_type = OLD.parent_type || \'::Member\';UPDATE cedar_relationships SET parent_id = NEW.role WHERE entity_id = OLD.membership_id AND entity_type = OLD.parent_type || \'::Member\' AND parent_type = \'Celest::Role\';END', + 'user_memberships_update_trg', + ); + late final Trigger userMembershipsDeleteTrg = Trigger( + 'CREATE TRIGGER IF NOT EXISTS user_memberships_delete_trg AFTER DELETE ON user_memberships BEGIN DELETE FROM cedar_relationships WHERE entity_id = OLD.membership_id AND entity_type = OLD.parent_type || \'::Member\';DELETE FROM cedar_relationships WHERE parent_id = OLD.membership_id AND parent_type = OLD.parent_type || \'::Member\';DELETE FROM cedar_entities WHERE entity_id = OLD.membership_id AND entity_type = OLD.parent_type || \'::Member\';END', + 'user_memberships_delete_trg', + ); + late final Organizations organizations = Organizations(this); + late final Trigger organizationsDeleteUserMembershipsTrg = Trigger( + 'CREATE TRIGGER IF NOT EXISTS organizations_delete_user_memberships_trg AFTER DELETE ON organizations BEGIN DELETE FROM user_memberships WHERE parent_type = \'Celest::Organization\' AND parent_id = OLD.id;END', + 'organizations_delete_user_memberships_trg', + ); + late final Projects projects = Projects(this); + late final Trigger projectsDeleteUserMembershipsTrg = Trigger( + 'CREATE TRIGGER IF NOT EXISTS projects_delete_user_memberships_trg AFTER DELETE ON projects BEGIN DELETE FROM user_memberships WHERE parent_type = \'Celest::Project\' AND parent_id = OLD.id;END', + 'projects_delete_user_memberships_trg', + ); + late final ProjectEnvironments projectEnvironments = ProjectEnvironments( + this, + ); + late final Trigger projectEnvironmentsDeleteUserMembershipsTrg = Trigger( + 'CREATE TRIGGER IF NOT EXISTS project_environments_delete_user_memberships_trg AFTER DELETE ON project_environments BEGIN DELETE FROM user_memberships WHERE parent_type = \'Celest::Project::Environment\' AND parent_id = OLD.id;END', + 'project_environments_delete_user_memberships_trg', + ); + late final Index projectEnvironmentsParentIdx = Index( + 'project_environments_parent_idx', + 'CREATE INDEX IF NOT EXISTS project_environments_parent_idx ON project_environments (parent_type, parent_id)', + ); + late final Trigger projectEnvironmentsUpdateTimeTrg = Trigger( + 'CREATE TRIGGER IF NOT EXISTS project_environments_update_time_trg AFTER UPDATE ON project_environments BEGIN UPDATE project_environments SET update_time = unixepoch(\'now\', \'subsec\') WHERE id = OLD.id;END', + 'project_environments_update_time_trg', + ); + late final Trigger projectEnvironmentsCreateTrg = Trigger( + 'CREATE TRIGGER IF NOT EXISTS project_environments_create_trg BEFORE INSERT ON project_environments BEGIN INSERT INTO cedar_entities (entity_type, entity_id) VALUES (\'Celest::Project::Environment\', NEW.id);INSERT INTO cedar_relationships (entity_type, entity_id, parent_type, parent_id) VALUES (\'Celest::Project::Environment\', NEW.id, NEW.parent_type, NEW.parent_id);END', + 'project_environments_create_trg', + ); + late final Trigger projectEnvironmentsSetParentTrg = Trigger( + 'CREATE TRIGGER IF NOT EXISTS project_environments_set_parent_trg AFTER UPDATE OF parent_type, parent_id ON project_environments WHEN OLD.parent_type != NEW.parent_type OR OLD.parent_id != NEW.parent_id BEGIN UPDATE cedar_relationships SET parent_type = NEW.parent_type, parent_id = NEW.parent_id WHERE entity_id = OLD.id AND entity_type = \'Celest::Project::Environment\';END', + 'project_environments_set_parent_trg', + ); + late final Trigger projectEnvironmentsDeleteTrg = Trigger( + 'CREATE TRIGGER IF NOT EXISTS project_environments_delete_trg AFTER DELETE ON project_environments BEGIN DELETE FROM cedar_relationships WHERE entity_id = OLD.id AND entity_type = \'Celest::Project::Environment\';DELETE FROM cedar_entities WHERE entity_id = OLD.id AND entity_type = \'Celest::Project::Environment\';END', + 'project_environments_delete_trg', + ); + late final ProjectEnvironmentAsts projectEnvironmentAsts = + ProjectEnvironmentAsts(this); + late final ProjectEnvironmentAssets projectEnvironmentAssets = + ProjectEnvironmentAssets(this); + late final ProjectEnvironmentStates projectEnvironmentStates = + ProjectEnvironmentStates(this); + late final Index projectsFkParentIdx = Index( + 'projects_fk_parent_idx', + 'CREATE INDEX IF NOT EXISTS projects_fk_parent_idx ON projects (parent_type, parent_id)', + ); + late final Trigger projectsUpdateTimeTrg = Trigger( + 'CREATE TRIGGER IF NOT EXISTS projects_update_time_trg AFTER UPDATE ON projects BEGIN UPDATE projects SET update_time = unixepoch(\'now\', \'subsec\') WHERE id = OLD.id;END', + 'projects_update_time_trg', + ); + late final Trigger projectsCreateTrg = Trigger( + 'CREATE TRIGGER IF NOT EXISTS projects_create_trg BEFORE INSERT ON projects BEGIN INSERT INTO cedar_entities (entity_type, entity_id) VALUES (\'Celest::Project\', NEW.id);INSERT INTO cedar_relationships (entity_type, entity_id, parent_type, parent_id) VALUES (\'Celest::Project\', NEW.id, NEW.parent_type, NEW.parent_id);END', + 'projects_create_trg', + ); + late final Trigger projectsSetParentTrg = Trigger( + 'CREATE TRIGGER IF NOT EXISTS projects_set_parent_trg AFTER UPDATE OF parent_type, parent_id ON projects WHEN OLD.parent_type != NEW.parent_type OR OLD.parent_id != NEW.parent_id BEGIN UPDATE cedar_relationships SET parent_type = NEW.parent_type, parent_id = NEW.parent_id WHERE entity_id = OLD.id AND entity_type = \'Celest::Project\';END', + 'projects_set_parent_trg', + ); + late final Trigger projectsDeleteTrg = Trigger( + 'CREATE TRIGGER IF NOT EXISTS projects_delete_trg AFTER DELETE ON projects BEGIN DELETE FROM cedar_relationships WHERE entity_type = \'Celest::Project\' AND entity_id = OLD.id;DELETE FROM cedar_relationships WHERE parent_type = \'Celest::Project\' AND parent_id = OLD.id;DELETE FROM cedar_entities WHERE entity_id = OLD.id AND entity_type = \'Celest::Project\';END', + 'projects_delete_trg', + ); + late final Index organizationsParentIdx = Index( + 'organizations_parent_idx', + 'CREATE INDEX IF NOT EXISTS organizations_parent_idx ON organizations (parent_type, parent_id)', + ); + late final Trigger organizationsUpdateTime = Trigger( + 'CREATE TRIGGER IF NOT EXISTS organizations_update_time AFTER UPDATE ON organizations BEGIN UPDATE organizations SET update_time = unixepoch(\'now\', \'subsec\') WHERE id = OLD.id;END', + 'organizations_update_time', + ); + late final Trigger organizationsCreate = Trigger( + 'CREATE TRIGGER IF NOT EXISTS organizations_create BEFORE INSERT ON organizations BEGIN INSERT INTO cedar_entities (entity_type, entity_id) VALUES (\'Celest::Organization\', NEW.id);END', + 'organizations_create', + ); + late final Trigger organizationsCreateParent = Trigger( + 'CREATE TRIGGER IF NOT EXISTS organizations_create_parent AFTER INSERT ON organizations WHEN NEW.parent_id IS NOT NULL BEGIN INSERT INTO cedar_relationships (entity_type, entity_id, parent_type, parent_id) VALUES (\'Celest::Organization\', NEW.id, NEW.parent_type, NEW.parent_id);END', + 'organizations_create_parent', + ); + late final Trigger organizationsAddParent = Trigger( + 'CREATE TRIGGER IF NOT EXISTS organizations_add_parent AFTER UPDATE OF parent_id ON organizations WHEN OLD.parent_id IS NULL AND NEW.parent_id IS NOT NULL BEGIN INSERT INTO cedar_relationships (entity_type, entity_id, parent_type, parent_id) VALUES (\'Celest::Organization\', NEW.id, NEW.parent_type, NEW.parent_id);END', + 'organizations_add_parent', + ); + late final Trigger organizationsSetParent = Trigger( + 'CREATE TRIGGER IF NOT EXISTS organizations_set_parent AFTER UPDATE OF parent_type, parent_id ON organizations WHEN(OLD.parent_type != NEW.parent_type OR OLD.parent_id != NEW.parent_id)AND NEW.parent_id IS NOT NULL BEGIN UPDATE cedar_relationships SET parent_type = NEW.parent_type, parent_id = NEW.parent_id WHERE entity_id = OLD.id AND entity_type = \'Celest::Organization\';END', + 'organizations_set_parent', + ); + late final Trigger organizationsRemoveParent = Trigger( + 'CREATE TRIGGER IF NOT EXISTS organizations_remove_parent AFTER UPDATE OF parent_id ON organizations WHEN OLD.parent_id IS NOT NULL AND NEW.parent_id IS NULL BEGIN DELETE FROM cedar_relationships WHERE entity_id = OLD.id AND entity_type = \'Celest::Organization\' AND parent_id = OLD.parent_id AND parent_type = OLD.parent_type;END', + 'organizations_remove_parent', + ); + late final Trigger organizationsDelete = Trigger( + 'CREATE TRIGGER IF NOT EXISTS organizations_delete AFTER DELETE ON organizations BEGIN DELETE FROM cedar_relationships WHERE entity_type = \'Celest::Organization\' AND entity_id = OLD.id;DELETE FROM cedar_relationships WHERE parent_type = \'Celest::Organization\' AND parent_id = OLD.id;DELETE FROM cedar_entities WHERE entity_type = \'Celest::Organization\' AND entity_id = OLD.id;END', + 'organizations_delete', + ); + late final Operations operations = Operations(this); + late final Index operationsFkOwnerIdx = Index( + 'operations_fk_owner_idx', + 'CREATE INDEX IF NOT EXISTS operations_fk_owner_idx ON operations (owner_type, owner_id)', + ); + late final Index operationsFkResourceIdx = Index( + 'operations_fk_resource_idx', + 'CREATE INDEX IF NOT EXISTS operations_fk_resource_idx ON operations (resource_type, resource_id)', + ); + late final Trigger operationsTriggerCreate = Trigger( + 'CREATE TRIGGER IF NOT EXISTS operations_trigger_create BEFORE INSERT ON operations BEGIN INSERT INTO cedar_entities (entity_type, entity_id) VALUES (\'Celest::Operation\', NEW.id);END', + 'operations_trigger_create', + ); + late final Trigger operationsTriggerCreateOwner = Trigger( + 'CREATE TRIGGER IF NOT EXISTS operations_trigger_create_owner AFTER INSERT ON operations WHEN NEW.owner_id IS NOT NULL BEGIN INSERT INTO cedar_relationships (entity_type, entity_id, parent_type, parent_id) VALUES (\'Celest::Operation\', NEW.id, NEW.owner_type, NEW.owner_id);END', + 'operations_trigger_create_owner', + ); + late final Trigger operationsTriggerCreateResource = Trigger( + 'CREATE TRIGGER IF NOT EXISTS operations_trigger_create_resource AFTER INSERT ON operations WHEN NEW.resource_id IS NOT NULL BEGIN INSERT INTO cedar_relationships (entity_type, entity_id, parent_type, parent_id) VALUES (\'Celest::Operation\', NEW.id, NEW.resource_type, NEW.resource_id);END', + 'operations_trigger_create_resource', + ); + late final Trigger operationsTriggerAddOwner = Trigger( + 'CREATE TRIGGER IF NOT EXISTS operations_trigger_add_owner AFTER UPDATE OF owner_id ON operations WHEN OLD.owner_id IS NULL AND NEW.owner_id IS NOT NULL BEGIN INSERT INTO cedar_relationships (entity_type, entity_id, parent_type, parent_id) VALUES (\'Celest::Operation\', NEW.id, NEW.owner_type, NEW.owner_id);END', + 'operations_trigger_add_owner', + ); + late final Trigger operationsTriggerAddResource = Trigger( + 'CREATE TRIGGER IF NOT EXISTS operations_trigger_add_resource AFTER UPDATE OF resource_id ON operations WHEN OLD.resource_id IS NULL AND NEW.resource_id IS NOT NULL BEGIN INSERT INTO cedar_relationships (entity_type, entity_id, parent_type, parent_id) VALUES (\'Celest::Operation\', NEW.id, NEW.resource_type, NEW.resource_id);END', + 'operations_trigger_add_resource', + ); + late final Trigger operationsTriggerSetOwner = Trigger( + 'CREATE TRIGGER IF NOT EXISTS operations_trigger_set_owner AFTER UPDATE OF owner_type, owner_id ON operations WHEN(OLD.owner_type != NEW.owner_type OR OLD.owner_id != NEW.owner_id)AND OLD.owner_id IS NOT NULL AND NEW.owner_id IS NOT NULL BEGIN UPDATE cedar_relationships SET parent_type = NEW.owner_type, parent_id = NEW.owner_id WHERE entity_id = OLD.id AND entity_type = \'Celest::Operation\' AND parent_type = OLD.owner_type AND parent_id = OLD.owner_id;END', + 'operations_trigger_set_owner', + ); + late final Trigger operationsTriggerSetResource = Trigger( + 'CREATE TRIGGER IF NOT EXISTS operations_trigger_set_resource AFTER UPDATE OF resource_type, resource_id ON operations WHEN(OLD.resource_type != NEW.resource_type OR OLD.resource_id != NEW.resource_id)AND OLD.resource_id IS NOT NULL AND NEW.resource_id IS NOT NULL BEGIN UPDATE cedar_relationships SET parent_type = NEW.resource_type, parent_id = NEW.resource_id WHERE entity_id = OLD.id AND entity_type = \'Celest::Operation\' AND parent_type = OLD.resource_type AND parent_id = OLD.resource_id;END', + 'operations_trigger_set_resource', + ); + late final Trigger operationsTriggerDelete = Trigger( + 'CREATE TRIGGER IF NOT EXISTS operations_trigger_delete AFTER DELETE ON operations BEGIN DELETE FROM cedar_relationships WHERE entity_id = OLD.id AND entity_type = \'Celest::Operation\';DELETE FROM cedar_entities WHERE entity_id = OLD.id AND entity_type = \'Celest::Operation\';END', + 'operations_trigger_delete', + ); + @override + Iterable> get allTables => + allSchemaEntities.whereType>(); + @override + List get allSchemaEntities => [ + cloudAuthUsers, + cedarTypes, + cedarEntities, + cloudAuthUsersCreateTrg, + cedarRelationships, + cloudAuthUsersDeleteTrg, + cloudAuthUserEmails, + cloudAuthUserPhoneNumbers, + cloudAuthProjects, + cloudAuthApis, + cloudAuthApisProjectIdx, + cloudAuthApisCreateTrg, + cloudAuthApisDeleteTrg, + cloudAuthFunctions, + cloudAuthFunctionsApiIdx, + cloudAuthFunctionsCreateTrg, + cloudAuthFunctionsDeleteTrg, + cloudAuthMeta, + cloudAuthCryptoKeys, + cloudAuthCryptoKeysExternalCryptoKeyIdIdx, + cloudAuthSessions, + cloudAuthSessionsUserIdx, + cloudAuthSessionsCryptoKeyIdx, + cloudAuthSessionsExternalSessionIdIdx, + cloudAuthSessionsUpdateTimeTrg, + cloudAuthOtpCodes, + cloudAuthOtpCodesSessionIdIdx, + cloudAuthCorks, + cloudAuthCorksCryptoKeyIdx, + cloudAuthCorksBearerIdx, + cloudAuthCorksAudienceIdx, + cloudAuthCorksIssuerIdx, + cedarRelationshipsFkEntityIdx, + cedarRelationshipsFkParentIdx, + cedarPolicies, + cedarPolicyTemplates, + cedarPolicyTemplateLinks, + cedarPolicyTemplateLinksFkTemplateIdIdx, + cedarPolicyTemplateLinksFkPrincipalIdx, + cedarPolicyTemplateLinksFkResourceIdx, + cedarAuthorizationLogs, + userMemberships, + userMembershipsParentIdx, + userMembershipsCreateTrg, + userMembershipsUpdateTrg, + userMembershipsDeleteTrg, + organizations, + organizationsDeleteUserMembershipsTrg, + projects, + projectsDeleteUserMembershipsTrg, + projectEnvironments, + projectEnvironmentsDeleteUserMembershipsTrg, + projectEnvironmentsParentIdx, + projectEnvironmentsUpdateTimeTrg, + projectEnvironmentsCreateTrg, + projectEnvironmentsSetParentTrg, + projectEnvironmentsDeleteTrg, + projectEnvironmentAsts, + projectEnvironmentAssets, + projectEnvironmentStates, + projectsFkParentIdx, + projectsUpdateTimeTrg, + projectsCreateTrg, + projectsSetParentTrg, + projectsDeleteTrg, + organizationsParentIdx, + organizationsUpdateTime, + organizationsCreate, + organizationsCreateParent, + organizationsAddParent, + organizationsSetParent, + organizationsRemoveParent, + organizationsDelete, + operations, + operationsFkOwnerIdx, + operationsFkResourceIdx, + operationsTriggerCreate, + operationsTriggerCreateOwner, + operationsTriggerCreateResource, + operationsTriggerAddOwner, + operationsTriggerAddResource, + operationsTriggerSetOwner, + operationsTriggerSetResource, + operationsTriggerDelete, + ]; + @override + StreamQueryUpdateRules get streamUpdateRules => const StreamQueryUpdateRules([ + WritePropagation( + on: TableUpdateQuery.onTableName( + 'cloud_auth_users', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'cloud_auth_users', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'cloud_auth_apis', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'cloud_auth_apis', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'cloud_auth_functions', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'cloud_auth_functions', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'cloud_auth_sessions', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'user_memberships', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'user_memberships', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'user_memberships', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'organizations', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'projects', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'project_environments', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'project_environments', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'project_environments', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'project_environments', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'project_environments', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'projects', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'projects', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'projects', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'projects', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'organizations', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'organizations', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'organizations', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'organizations', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'organizations', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'organizations', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'organizations', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'operations', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'operations', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'operations', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'operations', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'operations', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'operations', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'operations', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'operations', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + ]); + @override + int get schemaVersion => 1; +} diff --git a/services/celest_cloud_hub/test/database/cloud_hub_database/generated/schema_v2.dart b/services/celest_cloud_hub/test/database/cloud_hub_database/generated/schema_v2.dart new file mode 100644 index 000000000..8a391234b --- /dev/null +++ b/services/celest_cloud_hub/test/database/cloud_hub_database/generated/schema_v2.dart @@ -0,0 +1,10811 @@ +// dart format width=80 +// GENERATED CODE, DO NOT EDIT BY HAND. +// ignore_for_file: type=lint +import 'package:drift/drift.dart'; + +class CloudAuthUsers extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + CloudAuthUsers(this.attachedDatabase, [this._alias]); + late final GeneratedColumn userId = GeneratedColumn( + 'user_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); + late final GeneratedColumn givenName = GeneratedColumn( + 'given_name', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn familyName = GeneratedColumn( + 'family_name', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn timeZone = GeneratedColumn( + 'time_zone', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn languageCode = GeneratedColumn( + 'language_code', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn createTime = GeneratedColumn( + 'create_time', + aliasedName, + false, + type: DriftSqlType.double, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT (unixepoch(\'now\', \'subsec\'))', + defaultValue: const CustomExpression('unixepoch(\'now\', \'subsec\')'), + ); + late final GeneratedColumn updateTime = GeneratedColumn( + 'update_time', + aliasedName, + true, + type: DriftSqlType.double, + requiredDuringInsert: false, + $customConstraints: '', + ); + @override + List get $columns => [ + userId, + givenName, + familyName, + timeZone, + languageCode, + createTime, + updateTime, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'cloud_auth_users'; + @override + Set get $primaryKey => {userId}; + @override + CloudAuthUsersData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return CloudAuthUsersData( + userId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}user_id'], + )!, + givenName: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}given_name'], + ), + familyName: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}family_name'], + ), + timeZone: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}time_zone'], + ), + languageCode: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}language_code'], + ), + createTime: + attachedDatabase.typeMapping.read( + DriftSqlType.double, + data['${effectivePrefix}create_time'], + )!, + updateTime: attachedDatabase.typeMapping.read( + DriftSqlType.double, + data['${effectivePrefix}update_time'], + ), + ); + } + + @override + CloudAuthUsers createAlias(String alias) { + return CloudAuthUsers(attachedDatabase, alias); + } + + @override + bool get dontWriteConstraints => true; +} + +class CloudAuthUsersData extends DataClass + implements Insertable { + final String userId; + final String? givenName; + final String? familyName; + final String? timeZone; + final String? languageCode; + final double createTime; + final double? updateTime; + const CloudAuthUsersData({ + required this.userId, + this.givenName, + this.familyName, + this.timeZone, + this.languageCode, + required this.createTime, + this.updateTime, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['user_id'] = Variable(userId); + if (!nullToAbsent || givenName != null) { + map['given_name'] = Variable(givenName); + } + if (!nullToAbsent || familyName != null) { + map['family_name'] = Variable(familyName); + } + if (!nullToAbsent || timeZone != null) { + map['time_zone'] = Variable(timeZone); + } + if (!nullToAbsent || languageCode != null) { + map['language_code'] = Variable(languageCode); + } + map['create_time'] = Variable(createTime); + if (!nullToAbsent || updateTime != null) { + map['update_time'] = Variable(updateTime); + } + return map; + } + + CloudAuthUsersCompanion toCompanion(bool nullToAbsent) { + return CloudAuthUsersCompanion( + userId: Value(userId), + givenName: + givenName == null && nullToAbsent + ? const Value.absent() + : Value(givenName), + familyName: + familyName == null && nullToAbsent + ? const Value.absent() + : Value(familyName), + timeZone: + timeZone == null && nullToAbsent + ? const Value.absent() + : Value(timeZone), + languageCode: + languageCode == null && nullToAbsent + ? const Value.absent() + : Value(languageCode), + createTime: Value(createTime), + updateTime: + updateTime == null && nullToAbsent + ? const Value.absent() + : Value(updateTime), + ); + } + + factory CloudAuthUsersData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return CloudAuthUsersData( + userId: serializer.fromJson(json['userId']), + givenName: serializer.fromJson(json['givenName']), + familyName: serializer.fromJson(json['familyName']), + timeZone: serializer.fromJson(json['timeZone']), + languageCode: serializer.fromJson(json['languageCode']), + createTime: serializer.fromJson(json['createTime']), + updateTime: serializer.fromJson(json['updateTime']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'userId': serializer.toJson(userId), + 'givenName': serializer.toJson(givenName), + 'familyName': serializer.toJson(familyName), + 'timeZone': serializer.toJson(timeZone), + 'languageCode': serializer.toJson(languageCode), + 'createTime': serializer.toJson(createTime), + 'updateTime': serializer.toJson(updateTime), + }; + } + + CloudAuthUsersData copyWith({ + String? userId, + Value givenName = const Value.absent(), + Value familyName = const Value.absent(), + Value timeZone = const Value.absent(), + Value languageCode = const Value.absent(), + double? createTime, + Value updateTime = const Value.absent(), + }) => CloudAuthUsersData( + userId: userId ?? this.userId, + givenName: givenName.present ? givenName.value : this.givenName, + familyName: familyName.present ? familyName.value : this.familyName, + timeZone: timeZone.present ? timeZone.value : this.timeZone, + languageCode: languageCode.present ? languageCode.value : this.languageCode, + createTime: createTime ?? this.createTime, + updateTime: updateTime.present ? updateTime.value : this.updateTime, + ); + CloudAuthUsersData copyWithCompanion(CloudAuthUsersCompanion data) { + return CloudAuthUsersData( + userId: data.userId.present ? data.userId.value : this.userId, + givenName: data.givenName.present ? data.givenName.value : this.givenName, + familyName: + data.familyName.present ? data.familyName.value : this.familyName, + timeZone: data.timeZone.present ? data.timeZone.value : this.timeZone, + languageCode: + data.languageCode.present + ? data.languageCode.value + : this.languageCode, + createTime: + data.createTime.present ? data.createTime.value : this.createTime, + updateTime: + data.updateTime.present ? data.updateTime.value : this.updateTime, + ); + } + + @override + String toString() { + return (StringBuffer('CloudAuthUsersData(') + ..write('userId: $userId, ') + ..write('givenName: $givenName, ') + ..write('familyName: $familyName, ') + ..write('timeZone: $timeZone, ') + ..write('languageCode: $languageCode, ') + ..write('createTime: $createTime, ') + ..write('updateTime: $updateTime') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + userId, + givenName, + familyName, + timeZone, + languageCode, + createTime, + updateTime, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is CloudAuthUsersData && + other.userId == this.userId && + other.givenName == this.givenName && + other.familyName == this.familyName && + other.timeZone == this.timeZone && + other.languageCode == this.languageCode && + other.createTime == this.createTime && + other.updateTime == this.updateTime); +} + +class CloudAuthUsersCompanion extends UpdateCompanion { + final Value userId; + final Value givenName; + final Value familyName; + final Value timeZone; + final Value languageCode; + final Value createTime; + final Value updateTime; + final Value rowid; + const CloudAuthUsersCompanion({ + this.userId = const Value.absent(), + this.givenName = const Value.absent(), + this.familyName = const Value.absent(), + this.timeZone = const Value.absent(), + this.languageCode = const Value.absent(), + this.createTime = const Value.absent(), + this.updateTime = const Value.absent(), + this.rowid = const Value.absent(), + }); + CloudAuthUsersCompanion.insert({ + required String userId, + this.givenName = const Value.absent(), + this.familyName = const Value.absent(), + this.timeZone = const Value.absent(), + this.languageCode = const Value.absent(), + this.createTime = const Value.absent(), + this.updateTime = const Value.absent(), + this.rowid = const Value.absent(), + }) : userId = Value(userId); + static Insertable custom({ + Expression? userId, + Expression? givenName, + Expression? familyName, + Expression? timeZone, + Expression? languageCode, + Expression? createTime, + Expression? updateTime, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (userId != null) 'user_id': userId, + if (givenName != null) 'given_name': givenName, + if (familyName != null) 'family_name': familyName, + if (timeZone != null) 'time_zone': timeZone, + if (languageCode != null) 'language_code': languageCode, + if (createTime != null) 'create_time': createTime, + if (updateTime != null) 'update_time': updateTime, + if (rowid != null) 'rowid': rowid, + }); + } + + CloudAuthUsersCompanion copyWith({ + Value? userId, + Value? givenName, + Value? familyName, + Value? timeZone, + Value? languageCode, + Value? createTime, + Value? updateTime, + Value? rowid, + }) { + return CloudAuthUsersCompanion( + userId: userId ?? this.userId, + givenName: givenName ?? this.givenName, + familyName: familyName ?? this.familyName, + timeZone: timeZone ?? this.timeZone, + languageCode: languageCode ?? this.languageCode, + createTime: createTime ?? this.createTime, + updateTime: updateTime ?? this.updateTime, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (userId.present) { + map['user_id'] = Variable(userId.value); + } + if (givenName.present) { + map['given_name'] = Variable(givenName.value); + } + if (familyName.present) { + map['family_name'] = Variable(familyName.value); + } + if (timeZone.present) { + map['time_zone'] = Variable(timeZone.value); + } + if (languageCode.present) { + map['language_code'] = Variable(languageCode.value); + } + if (createTime.present) { + map['create_time'] = Variable(createTime.value); + } + if (updateTime.present) { + map['update_time'] = Variable(updateTime.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('CloudAuthUsersCompanion(') + ..write('userId: $userId, ') + ..write('givenName: $givenName, ') + ..write('familyName: $familyName, ') + ..write('timeZone: $timeZone, ') + ..write('languageCode: $languageCode, ') + ..write('createTime: $createTime, ') + ..write('updateTime: $updateTime, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +class CedarTypes extends Table with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + CedarTypes(this.attachedDatabase, [this._alias]); + late final GeneratedColumn fqn = GeneratedColumn( + 'fqn', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); + @override + List get $columns => [fqn]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'cedar_types'; + @override + Set get $primaryKey => {fqn}; + @override + CedarTypesData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return CedarTypesData( + fqn: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}fqn'], + )!, + ); + } + + @override + CedarTypes createAlias(String alias) { + return CedarTypes(attachedDatabase, alias); + } + + @override + bool get dontWriteConstraints => true; +} + +class CedarTypesData extends DataClass implements Insertable { + final String fqn; + const CedarTypesData({required this.fqn}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['fqn'] = Variable(fqn); + return map; + } + + CedarTypesCompanion toCompanion(bool nullToAbsent) { + return CedarTypesCompanion(fqn: Value(fqn)); + } + + factory CedarTypesData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return CedarTypesData(fqn: serializer.fromJson(json['fqn'])); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return {'fqn': serializer.toJson(fqn)}; + } + + CedarTypesData copyWith({String? fqn}) => + CedarTypesData(fqn: fqn ?? this.fqn); + CedarTypesData copyWithCompanion(CedarTypesCompanion data) { + return CedarTypesData(fqn: data.fqn.present ? data.fqn.value : this.fqn); + } + + @override + String toString() { + return (StringBuffer('CedarTypesData(') + ..write('fqn: $fqn') + ..write(')')) + .toString(); + } + + @override + int get hashCode => fqn.hashCode; + @override + bool operator ==(Object other) => + identical(this, other) || + (other is CedarTypesData && other.fqn == this.fqn); +} + +class CedarTypesCompanion extends UpdateCompanion { + final Value fqn; + final Value rowid; + const CedarTypesCompanion({ + this.fqn = const Value.absent(), + this.rowid = const Value.absent(), + }); + CedarTypesCompanion.insert({ + required String fqn, + this.rowid = const Value.absent(), + }) : fqn = Value(fqn); + static Insertable custom({ + Expression? fqn, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (fqn != null) 'fqn': fqn, + if (rowid != null) 'rowid': rowid, + }); + } + + CedarTypesCompanion copyWith({Value? fqn, Value? rowid}) { + return CedarTypesCompanion( + fqn: fqn ?? this.fqn, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (fqn.present) { + map['fqn'] = Variable(fqn.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('CedarTypesCompanion(') + ..write('fqn: $fqn, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +class CedarEntities extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + CedarEntities(this.attachedDatabase, [this._alias]); + late final GeneratedColumn entityType = GeneratedColumn( + 'entity_type', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL REFERENCES cedar_types(fqn)', + ); + late final GeneratedColumn entityId = GeneratedColumn( + 'entity_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn attributeJson = GeneratedColumn( + 'attribute_json', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT \'{}\'', + defaultValue: const CustomExpression('\'{}\''), + ); + late final GeneratedColumn entityJson = GeneratedColumn( + 'entity_json', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: + 'NOT NULL GENERATED ALWAYS AS (json_object(\'type\', entity_type, \'id\', entity_id)) VIRTUAL', + ); + @override + List get $columns => [ + entityType, + entityId, + attributeJson, + entityJson, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'cedar_entities'; + @override + Set get $primaryKey => {entityType, entityId}; + @override + CedarEntitiesData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return CedarEntitiesData( + entityType: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}entity_type'], + )!, + entityId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}entity_id'], + )!, + attributeJson: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}attribute_json'], + )!, + entityJson: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}entity_json'], + )!, + ); + } + + @override + CedarEntities createAlias(String alias) { + return CedarEntities(attachedDatabase, alias); + } + + @override + bool get withoutRowId => true; + @override + List get customConstraints => const [ + 'CONSTRAINT cedar_entities_pk PRIMARY KEY(entity_type, entity_id)ON CONFLICT IGNORE', + ]; + @override + bool get dontWriteConstraints => true; +} + +class CedarEntitiesData extends DataClass + implements Insertable { + final String entityType; + final String entityId; + final String attributeJson; + final String entityJson; + const CedarEntitiesData({ + required this.entityType, + required this.entityId, + required this.attributeJson, + required this.entityJson, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['entity_type'] = Variable(entityType); + map['entity_id'] = Variable(entityId); + map['attribute_json'] = Variable(attributeJson); + map['entity_json'] = Variable(entityJson); + return map; + } + + CedarEntitiesCompanion toCompanion(bool nullToAbsent) { + return CedarEntitiesCompanion( + entityType: Value(entityType), + entityId: Value(entityId), + attributeJson: Value(attributeJson), + entityJson: Value(entityJson), + ); + } + + factory CedarEntitiesData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return CedarEntitiesData( + entityType: serializer.fromJson(json['entityType']), + entityId: serializer.fromJson(json['entityId']), + attributeJson: serializer.fromJson(json['attributeJson']), + entityJson: serializer.fromJson(json['entityJson']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'entityType': serializer.toJson(entityType), + 'entityId': serializer.toJson(entityId), + 'attributeJson': serializer.toJson(attributeJson), + 'entityJson': serializer.toJson(entityJson), + }; + } + + CedarEntitiesData copyWith({ + String? entityType, + String? entityId, + String? attributeJson, + String? entityJson, + }) => CedarEntitiesData( + entityType: entityType ?? this.entityType, + entityId: entityId ?? this.entityId, + attributeJson: attributeJson ?? this.attributeJson, + entityJson: entityJson ?? this.entityJson, + ); + CedarEntitiesData copyWithCompanion(CedarEntitiesCompanion data) { + return CedarEntitiesData( + entityType: + data.entityType.present ? data.entityType.value : this.entityType, + entityId: data.entityId.present ? data.entityId.value : this.entityId, + attributeJson: + data.attributeJson.present + ? data.attributeJson.value + : this.attributeJson, + entityJson: + data.entityJson.present ? data.entityJson.value : this.entityJson, + ); + } + + @override + String toString() { + return (StringBuffer('CedarEntitiesData(') + ..write('entityType: $entityType, ') + ..write('entityId: $entityId, ') + ..write('attributeJson: $attributeJson, ') + ..write('entityJson: $entityJson') + ..write(')')) + .toString(); + } + + @override + int get hashCode => + Object.hash(entityType, entityId, attributeJson, entityJson); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is CedarEntitiesData && + other.entityType == this.entityType && + other.entityId == this.entityId && + other.attributeJson == this.attributeJson && + other.entityJson == this.entityJson); +} + +class CedarEntitiesCompanion extends UpdateCompanion { + final Value entityType; + final Value entityId; + final Value attributeJson; + final Value entityJson; + const CedarEntitiesCompanion({ + this.entityType = const Value.absent(), + this.entityId = const Value.absent(), + this.attributeJson = const Value.absent(), + this.entityJson = const Value.absent(), + }); + CedarEntitiesCompanion.insert({ + required String entityType, + required String entityId, + this.attributeJson = const Value.absent(), + required String entityJson, + }) : entityType = Value(entityType), + entityId = Value(entityId), + entityJson = Value(entityJson); + static Insertable custom({ + Expression? entityType, + Expression? entityId, + Expression? attributeJson, + Expression? entityJson, + }) { + return RawValuesInsertable({ + if (entityType != null) 'entity_type': entityType, + if (entityId != null) 'entity_id': entityId, + if (attributeJson != null) 'attribute_json': attributeJson, + if (entityJson != null) 'entity_json': entityJson, + }); + } + + CedarEntitiesCompanion copyWith({ + Value? entityType, + Value? entityId, + Value? attributeJson, + Value? entityJson, + }) { + return CedarEntitiesCompanion( + entityType: entityType ?? this.entityType, + entityId: entityId ?? this.entityId, + attributeJson: attributeJson ?? this.attributeJson, + entityJson: entityJson ?? this.entityJson, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (entityType.present) { + map['entity_type'] = Variable(entityType.value); + } + if (entityId.present) { + map['entity_id'] = Variable(entityId.value); + } + if (attributeJson.present) { + map['attribute_json'] = Variable(attributeJson.value); + } + if (entityJson.present) { + map['entity_json'] = Variable(entityJson.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('CedarEntitiesCompanion(') + ..write('entityType: $entityType, ') + ..write('entityId: $entityId, ') + ..write('attributeJson: $attributeJson, ') + ..write('entityJson: $entityJson') + ..write(')')) + .toString(); + } +} + +class CedarRelationships extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + CedarRelationships(this.attachedDatabase, [this._alias]); + late final GeneratedColumn entityType = GeneratedColumn( + 'entity_type', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn entityId = GeneratedColumn( + 'entity_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn entityJson = GeneratedColumn( + 'entity_json', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: + 'NOT NULL GENERATED ALWAYS AS (json_object(\'type\', entity_type, \'id\', entity_id)) VIRTUAL', + ); + late final GeneratedColumn parentType = GeneratedColumn( + 'parent_type', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn parentId = GeneratedColumn( + 'parent_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn parentJson = GeneratedColumn( + 'parent_json', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: + 'NOT NULL GENERATED ALWAYS AS (json_object(\'type\', parent_type, \'id\', parent_id)) VIRTUAL', + ); + @override + List get $columns => [ + entityType, + entityId, + entityJson, + parentType, + parentId, + parentJson, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'cedar_relationships'; + @override + Set get $primaryKey => { + entityType, + entityId, + parentType, + parentId, + }; + @override + CedarRelationshipsData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return CedarRelationshipsData( + entityType: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}entity_type'], + )!, + entityId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}entity_id'], + )!, + entityJson: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}entity_json'], + )!, + parentType: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}parent_type'], + )!, + parentId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}parent_id'], + )!, + parentJson: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}parent_json'], + )!, + ); + } + + @override + CedarRelationships createAlias(String alias) { + return CedarRelationships(attachedDatabase, alias); + } + + @override + bool get withoutRowId => true; + @override + List get customConstraints => const [ + 'CONSTRAINT cedar_relationships_pk PRIMARY KEY(entity_type, entity_id, parent_type, parent_id)ON CONFLICT IGNORE', + 'CONSTRAINT cedar_relationships_fk_entity FOREIGN KEY(entity_type, entity_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE CASCADE', + 'CONSTRAINT cedar_relationships_fk_parent FOREIGN KEY(parent_type, parent_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE CASCADE', + ]; + @override + bool get dontWriteConstraints => true; +} + +class CedarRelationshipsData extends DataClass + implements Insertable { + final String entityType; + final String entityId; + final String entityJson; + final String parentType; + final String parentId; + final String parentJson; + const CedarRelationshipsData({ + required this.entityType, + required this.entityId, + required this.entityJson, + required this.parentType, + required this.parentId, + required this.parentJson, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['entity_type'] = Variable(entityType); + map['entity_id'] = Variable(entityId); + map['entity_json'] = Variable(entityJson); + map['parent_type'] = Variable(parentType); + map['parent_id'] = Variable(parentId); + map['parent_json'] = Variable(parentJson); + return map; + } + + CedarRelationshipsCompanion toCompanion(bool nullToAbsent) { + return CedarRelationshipsCompanion( + entityType: Value(entityType), + entityId: Value(entityId), + entityJson: Value(entityJson), + parentType: Value(parentType), + parentId: Value(parentId), + parentJson: Value(parentJson), + ); + } + + factory CedarRelationshipsData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return CedarRelationshipsData( + entityType: serializer.fromJson(json['entityType']), + entityId: serializer.fromJson(json['entityId']), + entityJson: serializer.fromJson(json['entityJson']), + parentType: serializer.fromJson(json['parentType']), + parentId: serializer.fromJson(json['parentId']), + parentJson: serializer.fromJson(json['parentJson']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'entityType': serializer.toJson(entityType), + 'entityId': serializer.toJson(entityId), + 'entityJson': serializer.toJson(entityJson), + 'parentType': serializer.toJson(parentType), + 'parentId': serializer.toJson(parentId), + 'parentJson': serializer.toJson(parentJson), + }; + } + + CedarRelationshipsData copyWith({ + String? entityType, + String? entityId, + String? entityJson, + String? parentType, + String? parentId, + String? parentJson, + }) => CedarRelationshipsData( + entityType: entityType ?? this.entityType, + entityId: entityId ?? this.entityId, + entityJson: entityJson ?? this.entityJson, + parentType: parentType ?? this.parentType, + parentId: parentId ?? this.parentId, + parentJson: parentJson ?? this.parentJson, + ); + CedarRelationshipsData copyWithCompanion(CedarRelationshipsCompanion data) { + return CedarRelationshipsData( + entityType: + data.entityType.present ? data.entityType.value : this.entityType, + entityId: data.entityId.present ? data.entityId.value : this.entityId, + entityJson: + data.entityJson.present ? data.entityJson.value : this.entityJson, + parentType: + data.parentType.present ? data.parentType.value : this.parentType, + parentId: data.parentId.present ? data.parentId.value : this.parentId, + parentJson: + data.parentJson.present ? data.parentJson.value : this.parentJson, + ); + } + + @override + String toString() { + return (StringBuffer('CedarRelationshipsData(') + ..write('entityType: $entityType, ') + ..write('entityId: $entityId, ') + ..write('entityJson: $entityJson, ') + ..write('parentType: $parentType, ') + ..write('parentId: $parentId, ') + ..write('parentJson: $parentJson') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + entityType, + entityId, + entityJson, + parentType, + parentId, + parentJson, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is CedarRelationshipsData && + other.entityType == this.entityType && + other.entityId == this.entityId && + other.entityJson == this.entityJson && + other.parentType == this.parentType && + other.parentId == this.parentId && + other.parentJson == this.parentJson); +} + +class CedarRelationshipsCompanion + extends UpdateCompanion { + final Value entityType; + final Value entityId; + final Value entityJson; + final Value parentType; + final Value parentId; + final Value parentJson; + const CedarRelationshipsCompanion({ + this.entityType = const Value.absent(), + this.entityId = const Value.absent(), + this.entityJson = const Value.absent(), + this.parentType = const Value.absent(), + this.parentId = const Value.absent(), + this.parentJson = const Value.absent(), + }); + CedarRelationshipsCompanion.insert({ + required String entityType, + required String entityId, + required String entityJson, + required String parentType, + required String parentId, + required String parentJson, + }) : entityType = Value(entityType), + entityId = Value(entityId), + entityJson = Value(entityJson), + parentType = Value(parentType), + parentId = Value(parentId), + parentJson = Value(parentJson); + static Insertable custom({ + Expression? entityType, + Expression? entityId, + Expression? entityJson, + Expression? parentType, + Expression? parentId, + Expression? parentJson, + }) { + return RawValuesInsertable({ + if (entityType != null) 'entity_type': entityType, + if (entityId != null) 'entity_id': entityId, + if (entityJson != null) 'entity_json': entityJson, + if (parentType != null) 'parent_type': parentType, + if (parentId != null) 'parent_id': parentId, + if (parentJson != null) 'parent_json': parentJson, + }); + } + + CedarRelationshipsCompanion copyWith({ + Value? entityType, + Value? entityId, + Value? entityJson, + Value? parentType, + Value? parentId, + Value? parentJson, + }) { + return CedarRelationshipsCompanion( + entityType: entityType ?? this.entityType, + entityId: entityId ?? this.entityId, + entityJson: entityJson ?? this.entityJson, + parentType: parentType ?? this.parentType, + parentId: parentId ?? this.parentId, + parentJson: parentJson ?? this.parentJson, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (entityType.present) { + map['entity_type'] = Variable(entityType.value); + } + if (entityId.present) { + map['entity_id'] = Variable(entityId.value); + } + if (entityJson.present) { + map['entity_json'] = Variable(entityJson.value); + } + if (parentType.present) { + map['parent_type'] = Variable(parentType.value); + } + if (parentId.present) { + map['parent_id'] = Variable(parentId.value); + } + if (parentJson.present) { + map['parent_json'] = Variable(parentJson.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('CedarRelationshipsCompanion(') + ..write('entityType: $entityType, ') + ..write('entityId: $entityId, ') + ..write('entityJson: $entityJson, ') + ..write('parentType: $parentType, ') + ..write('parentId: $parentId, ') + ..write('parentJson: $parentJson') + ..write(')')) + .toString(); + } +} + +class CloudAuthUserEmails extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + CloudAuthUserEmails(this.attachedDatabase, [this._alias]); + late final GeneratedColumn userId = GeneratedColumn( + 'user_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn email = GeneratedColumn( + 'email', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn isVerified = GeneratedColumn( + 'is_verified', + aliasedName, + false, + type: DriftSqlType.bool, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT FALSE', + defaultValue: const CustomExpression('FALSE'), + ); + late final GeneratedColumn isPrimary = GeneratedColumn( + 'is_primary', + aliasedName, + false, + type: DriftSqlType.bool, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT FALSE', + defaultValue: const CustomExpression('FALSE'), + ); + @override + List get $columns => [userId, email, isVerified, isPrimary]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'cloud_auth_user_emails'; + @override + Set get $primaryKey => {userId, email}; + @override + CloudAuthUserEmailsData map( + Map data, { + String? tablePrefix, + }) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return CloudAuthUserEmailsData( + userId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}user_id'], + )!, + email: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}email'], + )!, + isVerified: + attachedDatabase.typeMapping.read( + DriftSqlType.bool, + data['${effectivePrefix}is_verified'], + )!, + isPrimary: + attachedDatabase.typeMapping.read( + DriftSqlType.bool, + data['${effectivePrefix}is_primary'], + )!, + ); + } + + @override + CloudAuthUserEmails createAlias(String alias) { + return CloudAuthUserEmails(attachedDatabase, alias); + } + + @override + bool get withoutRowId => true; + @override + List get customConstraints => const [ + 'CONSTRAINT cloud_auth_user_emails_pk PRIMARY KEY(user_id, email)', + 'CONSTRAINT cloud_auth_user_emails_user_fk FOREIGN KEY(user_id)REFERENCES cloud_auth_users(user_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED', + ]; + @override + bool get dontWriteConstraints => true; +} + +class CloudAuthUserEmailsData extends DataClass + implements Insertable { + final String userId; + final String email; + final bool isVerified; + final bool isPrimary; + const CloudAuthUserEmailsData({ + required this.userId, + required this.email, + required this.isVerified, + required this.isPrimary, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['user_id'] = Variable(userId); + map['email'] = Variable(email); + map['is_verified'] = Variable(isVerified); + map['is_primary'] = Variable(isPrimary); + return map; + } + + CloudAuthUserEmailsCompanion toCompanion(bool nullToAbsent) { + return CloudAuthUserEmailsCompanion( + userId: Value(userId), + email: Value(email), + isVerified: Value(isVerified), + isPrimary: Value(isPrimary), + ); + } + + factory CloudAuthUserEmailsData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return CloudAuthUserEmailsData( + userId: serializer.fromJson(json['userId']), + email: serializer.fromJson(json['email']), + isVerified: serializer.fromJson(json['isVerified']), + isPrimary: serializer.fromJson(json['isPrimary']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'userId': serializer.toJson(userId), + 'email': serializer.toJson(email), + 'isVerified': serializer.toJson(isVerified), + 'isPrimary': serializer.toJson(isPrimary), + }; + } + + CloudAuthUserEmailsData copyWith({ + String? userId, + String? email, + bool? isVerified, + bool? isPrimary, + }) => CloudAuthUserEmailsData( + userId: userId ?? this.userId, + email: email ?? this.email, + isVerified: isVerified ?? this.isVerified, + isPrimary: isPrimary ?? this.isPrimary, + ); + CloudAuthUserEmailsData copyWithCompanion(CloudAuthUserEmailsCompanion data) { + return CloudAuthUserEmailsData( + userId: data.userId.present ? data.userId.value : this.userId, + email: data.email.present ? data.email.value : this.email, + isVerified: + data.isVerified.present ? data.isVerified.value : this.isVerified, + isPrimary: data.isPrimary.present ? data.isPrimary.value : this.isPrimary, + ); + } + + @override + String toString() { + return (StringBuffer('CloudAuthUserEmailsData(') + ..write('userId: $userId, ') + ..write('email: $email, ') + ..write('isVerified: $isVerified, ') + ..write('isPrimary: $isPrimary') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(userId, email, isVerified, isPrimary); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is CloudAuthUserEmailsData && + other.userId == this.userId && + other.email == this.email && + other.isVerified == this.isVerified && + other.isPrimary == this.isPrimary); +} + +class CloudAuthUserEmailsCompanion + extends UpdateCompanion { + final Value userId; + final Value email; + final Value isVerified; + final Value isPrimary; + const CloudAuthUserEmailsCompanion({ + this.userId = const Value.absent(), + this.email = const Value.absent(), + this.isVerified = const Value.absent(), + this.isPrimary = const Value.absent(), + }); + CloudAuthUserEmailsCompanion.insert({ + required String userId, + required String email, + this.isVerified = const Value.absent(), + this.isPrimary = const Value.absent(), + }) : userId = Value(userId), + email = Value(email); + static Insertable custom({ + Expression? userId, + Expression? email, + Expression? isVerified, + Expression? isPrimary, + }) { + return RawValuesInsertable({ + if (userId != null) 'user_id': userId, + if (email != null) 'email': email, + if (isVerified != null) 'is_verified': isVerified, + if (isPrimary != null) 'is_primary': isPrimary, + }); + } + + CloudAuthUserEmailsCompanion copyWith({ + Value? userId, + Value? email, + Value? isVerified, + Value? isPrimary, + }) { + return CloudAuthUserEmailsCompanion( + userId: userId ?? this.userId, + email: email ?? this.email, + isVerified: isVerified ?? this.isVerified, + isPrimary: isPrimary ?? this.isPrimary, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (userId.present) { + map['user_id'] = Variable(userId.value); + } + if (email.present) { + map['email'] = Variable(email.value); + } + if (isVerified.present) { + map['is_verified'] = Variable(isVerified.value); + } + if (isPrimary.present) { + map['is_primary'] = Variable(isPrimary.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('CloudAuthUserEmailsCompanion(') + ..write('userId: $userId, ') + ..write('email: $email, ') + ..write('isVerified: $isVerified, ') + ..write('isPrimary: $isPrimary') + ..write(')')) + .toString(); + } +} + +class CloudAuthUserPhoneNumbers extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + CloudAuthUserPhoneNumbers(this.attachedDatabase, [this._alias]); + late final GeneratedColumn userId = GeneratedColumn( + 'user_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn phoneNumber = GeneratedColumn( + 'phone_number', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn isVerified = GeneratedColumn( + 'is_verified', + aliasedName, + false, + type: DriftSqlType.bool, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT FALSE', + defaultValue: const CustomExpression('FALSE'), + ); + late final GeneratedColumn isPrimary = GeneratedColumn( + 'is_primary', + aliasedName, + false, + type: DriftSqlType.bool, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT FALSE', + defaultValue: const CustomExpression('FALSE'), + ); + @override + List get $columns => [ + userId, + phoneNumber, + isVerified, + isPrimary, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'cloud_auth_user_phone_numbers'; + @override + Set get $primaryKey => {userId, phoneNumber}; + @override + CloudAuthUserPhoneNumbersData map( + Map data, { + String? tablePrefix, + }) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return CloudAuthUserPhoneNumbersData( + userId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}user_id'], + )!, + phoneNumber: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}phone_number'], + )!, + isVerified: + attachedDatabase.typeMapping.read( + DriftSqlType.bool, + data['${effectivePrefix}is_verified'], + )!, + isPrimary: + attachedDatabase.typeMapping.read( + DriftSqlType.bool, + data['${effectivePrefix}is_primary'], + )!, + ); + } + + @override + CloudAuthUserPhoneNumbers createAlias(String alias) { + return CloudAuthUserPhoneNumbers(attachedDatabase, alias); + } + + @override + bool get withoutRowId => true; + @override + List get customConstraints => const [ + 'CONSTRAINT cloud_auth_user_phone_numbers_pk PRIMARY KEY(user_id, phone_number)', + 'CONSTRAINT cloud_auth_user_phone_numbers_user_fk FOREIGN KEY(user_id)REFERENCES cloud_auth_users(user_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED', + ]; + @override + bool get dontWriteConstraints => true; +} + +class CloudAuthUserPhoneNumbersData extends DataClass + implements Insertable { + final String userId; + final String phoneNumber; + final bool isVerified; + final bool isPrimary; + const CloudAuthUserPhoneNumbersData({ + required this.userId, + required this.phoneNumber, + required this.isVerified, + required this.isPrimary, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['user_id'] = Variable(userId); + map['phone_number'] = Variable(phoneNumber); + map['is_verified'] = Variable(isVerified); + map['is_primary'] = Variable(isPrimary); + return map; + } + + CloudAuthUserPhoneNumbersCompanion toCompanion(bool nullToAbsent) { + return CloudAuthUserPhoneNumbersCompanion( + userId: Value(userId), + phoneNumber: Value(phoneNumber), + isVerified: Value(isVerified), + isPrimary: Value(isPrimary), + ); + } + + factory CloudAuthUserPhoneNumbersData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return CloudAuthUserPhoneNumbersData( + userId: serializer.fromJson(json['userId']), + phoneNumber: serializer.fromJson(json['phoneNumber']), + isVerified: serializer.fromJson(json['isVerified']), + isPrimary: serializer.fromJson(json['isPrimary']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'userId': serializer.toJson(userId), + 'phoneNumber': serializer.toJson(phoneNumber), + 'isVerified': serializer.toJson(isVerified), + 'isPrimary': serializer.toJson(isPrimary), + }; + } + + CloudAuthUserPhoneNumbersData copyWith({ + String? userId, + String? phoneNumber, + bool? isVerified, + bool? isPrimary, + }) => CloudAuthUserPhoneNumbersData( + userId: userId ?? this.userId, + phoneNumber: phoneNumber ?? this.phoneNumber, + isVerified: isVerified ?? this.isVerified, + isPrimary: isPrimary ?? this.isPrimary, + ); + CloudAuthUserPhoneNumbersData copyWithCompanion( + CloudAuthUserPhoneNumbersCompanion data, + ) { + return CloudAuthUserPhoneNumbersData( + userId: data.userId.present ? data.userId.value : this.userId, + phoneNumber: + data.phoneNumber.present ? data.phoneNumber.value : this.phoneNumber, + isVerified: + data.isVerified.present ? data.isVerified.value : this.isVerified, + isPrimary: data.isPrimary.present ? data.isPrimary.value : this.isPrimary, + ); + } + + @override + String toString() { + return (StringBuffer('CloudAuthUserPhoneNumbersData(') + ..write('userId: $userId, ') + ..write('phoneNumber: $phoneNumber, ') + ..write('isVerified: $isVerified, ') + ..write('isPrimary: $isPrimary') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(userId, phoneNumber, isVerified, isPrimary); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is CloudAuthUserPhoneNumbersData && + other.userId == this.userId && + other.phoneNumber == this.phoneNumber && + other.isVerified == this.isVerified && + other.isPrimary == this.isPrimary); +} + +class CloudAuthUserPhoneNumbersCompanion + extends UpdateCompanion { + final Value userId; + final Value phoneNumber; + final Value isVerified; + final Value isPrimary; + const CloudAuthUserPhoneNumbersCompanion({ + this.userId = const Value.absent(), + this.phoneNumber = const Value.absent(), + this.isVerified = const Value.absent(), + this.isPrimary = const Value.absent(), + }); + CloudAuthUserPhoneNumbersCompanion.insert({ + required String userId, + required String phoneNumber, + this.isVerified = const Value.absent(), + this.isPrimary = const Value.absent(), + }) : userId = Value(userId), + phoneNumber = Value(phoneNumber); + static Insertable custom({ + Expression? userId, + Expression? phoneNumber, + Expression? isVerified, + Expression? isPrimary, + }) { + return RawValuesInsertable({ + if (userId != null) 'user_id': userId, + if (phoneNumber != null) 'phone_number': phoneNumber, + if (isVerified != null) 'is_verified': isVerified, + if (isPrimary != null) 'is_primary': isPrimary, + }); + } + + CloudAuthUserPhoneNumbersCompanion copyWith({ + Value? userId, + Value? phoneNumber, + Value? isVerified, + Value? isPrimary, + }) { + return CloudAuthUserPhoneNumbersCompanion( + userId: userId ?? this.userId, + phoneNumber: phoneNumber ?? this.phoneNumber, + isVerified: isVerified ?? this.isVerified, + isPrimary: isPrimary ?? this.isPrimary, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (userId.present) { + map['user_id'] = Variable(userId.value); + } + if (phoneNumber.present) { + map['phone_number'] = Variable(phoneNumber.value); + } + if (isVerified.present) { + map['is_verified'] = Variable(isVerified.value); + } + if (isPrimary.present) { + map['is_primary'] = Variable(isPrimary.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('CloudAuthUserPhoneNumbersCompanion(') + ..write('userId: $userId, ') + ..write('phoneNumber: $phoneNumber, ') + ..write('isVerified: $isVerified, ') + ..write('isPrimary: $isPrimary') + ..write(')')) + .toString(); + } +} + +class CloudAuthProjects extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + CloudAuthProjects(this.attachedDatabase, [this._alias]); + late final GeneratedColumn projectId = GeneratedColumn( + 'project_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); + late final GeneratedColumn version = GeneratedColumn( + 'version', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn resolvedAst = + GeneratedColumn( + 'resolved_ast', + aliasedName, + false, + type: DriftSqlType.blob, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn etag = GeneratedColumn( + 'etag', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + @override + List get $columns => [projectId, version, resolvedAst, etag]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'cloud_auth_projects'; + @override + Set get $primaryKey => {projectId}; + @override + CloudAuthProjectsData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return CloudAuthProjectsData( + projectId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}project_id'], + )!, + version: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}version'], + )!, + resolvedAst: + attachedDatabase.typeMapping.read( + DriftSqlType.blob, + data['${effectivePrefix}resolved_ast'], + )!, + etag: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}etag'], + )!, + ); + } + + @override + CloudAuthProjects createAlias(String alias) { + return CloudAuthProjects(attachedDatabase, alias); + } + + @override + bool get dontWriteConstraints => true; +} + +class CloudAuthProjectsData extends DataClass + implements Insertable { + final String projectId; + final String version; + final Uint8List resolvedAst; + final String etag; + const CloudAuthProjectsData({ + required this.projectId, + required this.version, + required this.resolvedAst, + required this.etag, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['project_id'] = Variable(projectId); + map['version'] = Variable(version); + map['resolved_ast'] = Variable(resolvedAst); + map['etag'] = Variable(etag); + return map; + } + + CloudAuthProjectsCompanion toCompanion(bool nullToAbsent) { + return CloudAuthProjectsCompanion( + projectId: Value(projectId), + version: Value(version), + resolvedAst: Value(resolvedAst), + etag: Value(etag), + ); + } + + factory CloudAuthProjectsData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return CloudAuthProjectsData( + projectId: serializer.fromJson(json['projectId']), + version: serializer.fromJson(json['version']), + resolvedAst: serializer.fromJson(json['resolvedAst']), + etag: serializer.fromJson(json['etag']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'projectId': serializer.toJson(projectId), + 'version': serializer.toJson(version), + 'resolvedAst': serializer.toJson(resolvedAst), + 'etag': serializer.toJson(etag), + }; + } + + CloudAuthProjectsData copyWith({ + String? projectId, + String? version, + Uint8List? resolvedAst, + String? etag, + }) => CloudAuthProjectsData( + projectId: projectId ?? this.projectId, + version: version ?? this.version, + resolvedAst: resolvedAst ?? this.resolvedAst, + etag: etag ?? this.etag, + ); + CloudAuthProjectsData copyWithCompanion(CloudAuthProjectsCompanion data) { + return CloudAuthProjectsData( + projectId: data.projectId.present ? data.projectId.value : this.projectId, + version: data.version.present ? data.version.value : this.version, + resolvedAst: + data.resolvedAst.present ? data.resolvedAst.value : this.resolvedAst, + etag: data.etag.present ? data.etag.value : this.etag, + ); + } + + @override + String toString() { + return (StringBuffer('CloudAuthProjectsData(') + ..write('projectId: $projectId, ') + ..write('version: $version, ') + ..write('resolvedAst: $resolvedAst, ') + ..write('etag: $etag') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + projectId, + version, + $driftBlobEquality.hash(resolvedAst), + etag, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is CloudAuthProjectsData && + other.projectId == this.projectId && + other.version == this.version && + $driftBlobEquality.equals(other.resolvedAst, this.resolvedAst) && + other.etag == this.etag); +} + +class CloudAuthProjectsCompanion + extends UpdateCompanion { + final Value projectId; + final Value version; + final Value resolvedAst; + final Value etag; + final Value rowid; + const CloudAuthProjectsCompanion({ + this.projectId = const Value.absent(), + this.version = const Value.absent(), + this.resolvedAst = const Value.absent(), + this.etag = const Value.absent(), + this.rowid = const Value.absent(), + }); + CloudAuthProjectsCompanion.insert({ + required String projectId, + required String version, + required Uint8List resolvedAst, + required String etag, + this.rowid = const Value.absent(), + }) : projectId = Value(projectId), + version = Value(version), + resolvedAst = Value(resolvedAst), + etag = Value(etag); + static Insertable custom({ + Expression? projectId, + Expression? version, + Expression? resolvedAst, + Expression? etag, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (projectId != null) 'project_id': projectId, + if (version != null) 'version': version, + if (resolvedAst != null) 'resolved_ast': resolvedAst, + if (etag != null) 'etag': etag, + if (rowid != null) 'rowid': rowid, + }); + } + + CloudAuthProjectsCompanion copyWith({ + Value? projectId, + Value? version, + Value? resolvedAst, + Value? etag, + Value? rowid, + }) { + return CloudAuthProjectsCompanion( + projectId: projectId ?? this.projectId, + version: version ?? this.version, + resolvedAst: resolvedAst ?? this.resolvedAst, + etag: etag ?? this.etag, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (projectId.present) { + map['project_id'] = Variable(projectId.value); + } + if (version.present) { + map['version'] = Variable(version.value); + } + if (resolvedAst.present) { + map['resolved_ast'] = Variable(resolvedAst.value); + } + if (etag.present) { + map['etag'] = Variable(etag.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('CloudAuthProjectsCompanion(') + ..write('projectId: $projectId, ') + ..write('version: $version, ') + ..write('resolvedAst: $resolvedAst, ') + ..write('etag: $etag, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +class CloudAuthApis extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + CloudAuthApis(this.attachedDatabase, [this._alias]); + late final GeneratedColumn apiId = GeneratedColumn( + 'api_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); + late final GeneratedColumn projectId = GeneratedColumn( + 'project_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn resolvedAst = + GeneratedColumn( + 'resolved_ast', + aliasedName, + false, + type: DriftSqlType.blob, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn etag = GeneratedColumn( + 'etag', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + @override + List get $columns => [apiId, projectId, resolvedAst, etag]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'cloud_auth_apis'; + @override + Set get $primaryKey => {apiId}; + @override + CloudAuthApisData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return CloudAuthApisData( + apiId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}api_id'], + )!, + projectId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}project_id'], + )!, + resolvedAst: + attachedDatabase.typeMapping.read( + DriftSqlType.blob, + data['${effectivePrefix}resolved_ast'], + )!, + etag: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}etag'], + )!, + ); + } + + @override + CloudAuthApis createAlias(String alias) { + return CloudAuthApis(attachedDatabase, alias); + } + + @override + List get customConstraints => const [ + 'CONSTRAINT cloud_auth_apis_project_fk FOREIGN KEY(project_id)REFERENCES cloud_auth_projects(project_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED', + ]; + @override + bool get dontWriteConstraints => true; +} + +class CloudAuthApisData extends DataClass + implements Insertable { + final String apiId; + final String projectId; + final Uint8List resolvedAst; + final String etag; + const CloudAuthApisData({ + required this.apiId, + required this.projectId, + required this.resolvedAst, + required this.etag, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['api_id'] = Variable(apiId); + map['project_id'] = Variable(projectId); + map['resolved_ast'] = Variable(resolvedAst); + map['etag'] = Variable(etag); + return map; + } + + CloudAuthApisCompanion toCompanion(bool nullToAbsent) { + return CloudAuthApisCompanion( + apiId: Value(apiId), + projectId: Value(projectId), + resolvedAst: Value(resolvedAst), + etag: Value(etag), + ); + } + + factory CloudAuthApisData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return CloudAuthApisData( + apiId: serializer.fromJson(json['apiId']), + projectId: serializer.fromJson(json['projectId']), + resolvedAst: serializer.fromJson(json['resolvedAst']), + etag: serializer.fromJson(json['etag']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'apiId': serializer.toJson(apiId), + 'projectId': serializer.toJson(projectId), + 'resolvedAst': serializer.toJson(resolvedAst), + 'etag': serializer.toJson(etag), + }; + } + + CloudAuthApisData copyWith({ + String? apiId, + String? projectId, + Uint8List? resolvedAst, + String? etag, + }) => CloudAuthApisData( + apiId: apiId ?? this.apiId, + projectId: projectId ?? this.projectId, + resolvedAst: resolvedAst ?? this.resolvedAst, + etag: etag ?? this.etag, + ); + CloudAuthApisData copyWithCompanion(CloudAuthApisCompanion data) { + return CloudAuthApisData( + apiId: data.apiId.present ? data.apiId.value : this.apiId, + projectId: data.projectId.present ? data.projectId.value : this.projectId, + resolvedAst: + data.resolvedAst.present ? data.resolvedAst.value : this.resolvedAst, + etag: data.etag.present ? data.etag.value : this.etag, + ); + } + + @override + String toString() { + return (StringBuffer('CloudAuthApisData(') + ..write('apiId: $apiId, ') + ..write('projectId: $projectId, ') + ..write('resolvedAst: $resolvedAst, ') + ..write('etag: $etag') + ..write(')')) + .toString(); + } + + @override + int get hashCode => + Object.hash(apiId, projectId, $driftBlobEquality.hash(resolvedAst), etag); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is CloudAuthApisData && + other.apiId == this.apiId && + other.projectId == this.projectId && + $driftBlobEquality.equals(other.resolvedAst, this.resolvedAst) && + other.etag == this.etag); +} + +class CloudAuthApisCompanion extends UpdateCompanion { + final Value apiId; + final Value projectId; + final Value resolvedAst; + final Value etag; + final Value rowid; + const CloudAuthApisCompanion({ + this.apiId = const Value.absent(), + this.projectId = const Value.absent(), + this.resolvedAst = const Value.absent(), + this.etag = const Value.absent(), + this.rowid = const Value.absent(), + }); + CloudAuthApisCompanion.insert({ + required String apiId, + required String projectId, + required Uint8List resolvedAst, + required String etag, + this.rowid = const Value.absent(), + }) : apiId = Value(apiId), + projectId = Value(projectId), + resolvedAst = Value(resolvedAst), + etag = Value(etag); + static Insertable custom({ + Expression? apiId, + Expression? projectId, + Expression? resolvedAst, + Expression? etag, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (apiId != null) 'api_id': apiId, + if (projectId != null) 'project_id': projectId, + if (resolvedAst != null) 'resolved_ast': resolvedAst, + if (etag != null) 'etag': etag, + if (rowid != null) 'rowid': rowid, + }); + } + + CloudAuthApisCompanion copyWith({ + Value? apiId, + Value? projectId, + Value? resolvedAst, + Value? etag, + Value? rowid, + }) { + return CloudAuthApisCompanion( + apiId: apiId ?? this.apiId, + projectId: projectId ?? this.projectId, + resolvedAst: resolvedAst ?? this.resolvedAst, + etag: etag ?? this.etag, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (apiId.present) { + map['api_id'] = Variable(apiId.value); + } + if (projectId.present) { + map['project_id'] = Variable(projectId.value); + } + if (resolvedAst.present) { + map['resolved_ast'] = Variable(resolvedAst.value); + } + if (etag.present) { + map['etag'] = Variable(etag.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('CloudAuthApisCompanion(') + ..write('apiId: $apiId, ') + ..write('projectId: $projectId, ') + ..write('resolvedAst: $resolvedAst, ') + ..write('etag: $etag, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +class CloudAuthFunctions extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + CloudAuthFunctions(this.attachedDatabase, [this._alias]); + late final GeneratedColumn functionId = GeneratedColumn( + 'function_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); + late final GeneratedColumn apiId = GeneratedColumn( + 'api_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn resolvedAst = + GeneratedColumn( + 'resolved_ast', + aliasedName, + false, + type: DriftSqlType.blob, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn etag = GeneratedColumn( + 'etag', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + @override + List get $columns => [functionId, apiId, resolvedAst, etag]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'cloud_auth_functions'; + @override + Set get $primaryKey => {functionId}; + @override + CloudAuthFunctionsData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return CloudAuthFunctionsData( + functionId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}function_id'], + )!, + apiId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}api_id'], + )!, + resolvedAst: + attachedDatabase.typeMapping.read( + DriftSqlType.blob, + data['${effectivePrefix}resolved_ast'], + )!, + etag: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}etag'], + )!, + ); + } + + @override + CloudAuthFunctions createAlias(String alias) { + return CloudAuthFunctions(attachedDatabase, alias); + } + + @override + List get customConstraints => const [ + 'CONSTRAINT cloud_auth_functions_api_fk FOREIGN KEY(api_id)REFERENCES cloud_auth_apis(api_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED', + ]; + @override + bool get dontWriteConstraints => true; +} + +class CloudAuthFunctionsData extends DataClass + implements Insertable { + final String functionId; + final String apiId; + final Uint8List resolvedAst; + final String etag; + const CloudAuthFunctionsData({ + required this.functionId, + required this.apiId, + required this.resolvedAst, + required this.etag, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['function_id'] = Variable(functionId); + map['api_id'] = Variable(apiId); + map['resolved_ast'] = Variable(resolvedAst); + map['etag'] = Variable(etag); + return map; + } + + CloudAuthFunctionsCompanion toCompanion(bool nullToAbsent) { + return CloudAuthFunctionsCompanion( + functionId: Value(functionId), + apiId: Value(apiId), + resolvedAst: Value(resolvedAst), + etag: Value(etag), + ); + } + + factory CloudAuthFunctionsData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return CloudAuthFunctionsData( + functionId: serializer.fromJson(json['functionId']), + apiId: serializer.fromJson(json['apiId']), + resolvedAst: serializer.fromJson(json['resolvedAst']), + etag: serializer.fromJson(json['etag']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'functionId': serializer.toJson(functionId), + 'apiId': serializer.toJson(apiId), + 'resolvedAst': serializer.toJson(resolvedAst), + 'etag': serializer.toJson(etag), + }; + } + + CloudAuthFunctionsData copyWith({ + String? functionId, + String? apiId, + Uint8List? resolvedAst, + String? etag, + }) => CloudAuthFunctionsData( + functionId: functionId ?? this.functionId, + apiId: apiId ?? this.apiId, + resolvedAst: resolvedAst ?? this.resolvedAst, + etag: etag ?? this.etag, + ); + CloudAuthFunctionsData copyWithCompanion(CloudAuthFunctionsCompanion data) { + return CloudAuthFunctionsData( + functionId: + data.functionId.present ? data.functionId.value : this.functionId, + apiId: data.apiId.present ? data.apiId.value : this.apiId, + resolvedAst: + data.resolvedAst.present ? data.resolvedAst.value : this.resolvedAst, + etag: data.etag.present ? data.etag.value : this.etag, + ); + } + + @override + String toString() { + return (StringBuffer('CloudAuthFunctionsData(') + ..write('functionId: $functionId, ') + ..write('apiId: $apiId, ') + ..write('resolvedAst: $resolvedAst, ') + ..write('etag: $etag') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + functionId, + apiId, + $driftBlobEquality.hash(resolvedAst), + etag, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is CloudAuthFunctionsData && + other.functionId == this.functionId && + other.apiId == this.apiId && + $driftBlobEquality.equals(other.resolvedAst, this.resolvedAst) && + other.etag == this.etag); +} + +class CloudAuthFunctionsCompanion + extends UpdateCompanion { + final Value functionId; + final Value apiId; + final Value resolvedAst; + final Value etag; + final Value rowid; + const CloudAuthFunctionsCompanion({ + this.functionId = const Value.absent(), + this.apiId = const Value.absent(), + this.resolvedAst = const Value.absent(), + this.etag = const Value.absent(), + this.rowid = const Value.absent(), + }); + CloudAuthFunctionsCompanion.insert({ + required String functionId, + required String apiId, + required Uint8List resolvedAst, + required String etag, + this.rowid = const Value.absent(), + }) : functionId = Value(functionId), + apiId = Value(apiId), + resolvedAst = Value(resolvedAst), + etag = Value(etag); + static Insertable custom({ + Expression? functionId, + Expression? apiId, + Expression? resolvedAst, + Expression? etag, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (functionId != null) 'function_id': functionId, + if (apiId != null) 'api_id': apiId, + if (resolvedAst != null) 'resolved_ast': resolvedAst, + if (etag != null) 'etag': etag, + if (rowid != null) 'rowid': rowid, + }); + } + + CloudAuthFunctionsCompanion copyWith({ + Value? functionId, + Value? apiId, + Value? resolvedAst, + Value? etag, + Value? rowid, + }) { + return CloudAuthFunctionsCompanion( + functionId: functionId ?? this.functionId, + apiId: apiId ?? this.apiId, + resolvedAst: resolvedAst ?? this.resolvedAst, + etag: etag ?? this.etag, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (functionId.present) { + map['function_id'] = Variable(functionId.value); + } + if (apiId.present) { + map['api_id'] = Variable(apiId.value); + } + if (resolvedAst.present) { + map['resolved_ast'] = Variable(resolvedAst.value); + } + if (etag.present) { + map['etag'] = Variable(etag.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('CloudAuthFunctionsCompanion(') + ..write('functionId: $functionId, ') + ..write('apiId: $apiId, ') + ..write('resolvedAst: $resolvedAst, ') + ..write('etag: $etag, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +class CloudAuthMeta extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + CloudAuthMeta(this.attachedDatabase, [this._alias]); + late final GeneratedColumn schemaVersion = GeneratedColumn( + 'schema_version', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); + @override + List get $columns => [schemaVersion]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'cloud_auth_meta'; + @override + Set get $primaryKey => {schemaVersion}; + @override + CloudAuthMetaData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return CloudAuthMetaData( + schemaVersion: + attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}schema_version'], + )!, + ); + } + + @override + CloudAuthMeta createAlias(String alias) { + return CloudAuthMeta(attachedDatabase, alias); + } + + @override + bool get dontWriteConstraints => true; +} + +class CloudAuthMetaData extends DataClass + implements Insertable { + final int schemaVersion; + const CloudAuthMetaData({required this.schemaVersion}); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['schema_version'] = Variable(schemaVersion); + return map; + } + + CloudAuthMetaCompanion toCompanion(bool nullToAbsent) { + return CloudAuthMetaCompanion(schemaVersion: Value(schemaVersion)); + } + + factory CloudAuthMetaData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return CloudAuthMetaData( + schemaVersion: serializer.fromJson(json['schemaVersion']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'schemaVersion': serializer.toJson(schemaVersion), + }; + } + + CloudAuthMetaData copyWith({int? schemaVersion}) => + CloudAuthMetaData(schemaVersion: schemaVersion ?? this.schemaVersion); + CloudAuthMetaData copyWithCompanion(CloudAuthMetaCompanion data) { + return CloudAuthMetaData( + schemaVersion: + data.schemaVersion.present + ? data.schemaVersion.value + : this.schemaVersion, + ); + } + + @override + String toString() { + return (StringBuffer('CloudAuthMetaData(') + ..write('schemaVersion: $schemaVersion') + ..write(')')) + .toString(); + } + + @override + int get hashCode => schemaVersion.hashCode; + @override + bool operator ==(Object other) => + identical(this, other) || + (other is CloudAuthMetaData && other.schemaVersion == this.schemaVersion); +} + +class CloudAuthMetaCompanion extends UpdateCompanion { + final Value schemaVersion; + const CloudAuthMetaCompanion({this.schemaVersion = const Value.absent()}); + CloudAuthMetaCompanion.insert({this.schemaVersion = const Value.absent()}); + static Insertable custom({ + Expression? schemaVersion, + }) { + return RawValuesInsertable({ + if (schemaVersion != null) 'schema_version': schemaVersion, + }); + } + + CloudAuthMetaCompanion copyWith({Value? schemaVersion}) { + return CloudAuthMetaCompanion( + schemaVersion: schemaVersion ?? this.schemaVersion, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (schemaVersion.present) { + map['schema_version'] = Variable(schemaVersion.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('CloudAuthMetaCompanion(') + ..write('schemaVersion: $schemaVersion') + ..write(')')) + .toString(); + } +} + +class CloudAuthCryptoKeys extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + CloudAuthCryptoKeys(this.attachedDatabase, [this._alias]); + late final GeneratedColumn cryptoKeyId = + GeneratedColumn( + 'crypto_key_id', + aliasedName, + false, + type: DriftSqlType.blob, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); + late final GeneratedColumn keyPurpose = GeneratedColumn( + 'key_purpose', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn keyAlgorithm = GeneratedColumn( + 'key_algorithm', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn keyMaterial = + GeneratedColumn( + 'key_material', + aliasedName, + true, + type: DriftSqlType.blob, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn externalCryptoKeyId = + GeneratedColumn( + 'external_crypto_key_id', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'UNIQUE', + ); + @override + List get $columns => [ + cryptoKeyId, + keyPurpose, + keyAlgorithm, + keyMaterial, + externalCryptoKeyId, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'cloud_auth_crypto_keys'; + @override + Set get $primaryKey => {cryptoKeyId}; + @override + CloudAuthCryptoKeysData map( + Map data, { + String? tablePrefix, + }) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return CloudAuthCryptoKeysData( + cryptoKeyId: + attachedDatabase.typeMapping.read( + DriftSqlType.blob, + data['${effectivePrefix}crypto_key_id'], + )!, + keyPurpose: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}key_purpose'], + )!, + keyAlgorithm: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}key_algorithm'], + )!, + keyMaterial: attachedDatabase.typeMapping.read( + DriftSqlType.blob, + data['${effectivePrefix}key_material'], + ), + externalCryptoKeyId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}external_crypto_key_id'], + ), + ); + } + + @override + CloudAuthCryptoKeys createAlias(String alias) { + return CloudAuthCryptoKeys(attachedDatabase, alias); + } + + @override + List get customConstraints => const [ + 'CHECK(key_material IS NOT NULL OR external_crypto_key_id IS NOT NULL)', + ]; + @override + bool get dontWriteConstraints => true; +} + +class CloudAuthCryptoKeysData extends DataClass + implements Insertable { + final Uint8List cryptoKeyId; + final String keyPurpose; + final String keyAlgorithm; + final Uint8List? keyMaterial; + final String? externalCryptoKeyId; + const CloudAuthCryptoKeysData({ + required this.cryptoKeyId, + required this.keyPurpose, + required this.keyAlgorithm, + this.keyMaterial, + this.externalCryptoKeyId, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['crypto_key_id'] = Variable(cryptoKeyId); + map['key_purpose'] = Variable(keyPurpose); + map['key_algorithm'] = Variable(keyAlgorithm); + if (!nullToAbsent || keyMaterial != null) { + map['key_material'] = Variable(keyMaterial); + } + if (!nullToAbsent || externalCryptoKeyId != null) { + map['external_crypto_key_id'] = Variable(externalCryptoKeyId); + } + return map; + } + + CloudAuthCryptoKeysCompanion toCompanion(bool nullToAbsent) { + return CloudAuthCryptoKeysCompanion( + cryptoKeyId: Value(cryptoKeyId), + keyPurpose: Value(keyPurpose), + keyAlgorithm: Value(keyAlgorithm), + keyMaterial: + keyMaterial == null && nullToAbsent + ? const Value.absent() + : Value(keyMaterial), + externalCryptoKeyId: + externalCryptoKeyId == null && nullToAbsent + ? const Value.absent() + : Value(externalCryptoKeyId), + ); + } + + factory CloudAuthCryptoKeysData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return CloudAuthCryptoKeysData( + cryptoKeyId: serializer.fromJson(json['cryptoKeyId']), + keyPurpose: serializer.fromJson(json['keyPurpose']), + keyAlgorithm: serializer.fromJson(json['keyAlgorithm']), + keyMaterial: serializer.fromJson(json['keyMaterial']), + externalCryptoKeyId: serializer.fromJson( + json['externalCryptoKeyId'], + ), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'cryptoKeyId': serializer.toJson(cryptoKeyId), + 'keyPurpose': serializer.toJson(keyPurpose), + 'keyAlgorithm': serializer.toJson(keyAlgorithm), + 'keyMaterial': serializer.toJson(keyMaterial), + 'externalCryptoKeyId': serializer.toJson(externalCryptoKeyId), + }; + } + + CloudAuthCryptoKeysData copyWith({ + Uint8List? cryptoKeyId, + String? keyPurpose, + String? keyAlgorithm, + Value keyMaterial = const Value.absent(), + Value externalCryptoKeyId = const Value.absent(), + }) => CloudAuthCryptoKeysData( + cryptoKeyId: cryptoKeyId ?? this.cryptoKeyId, + keyPurpose: keyPurpose ?? this.keyPurpose, + keyAlgorithm: keyAlgorithm ?? this.keyAlgorithm, + keyMaterial: keyMaterial.present ? keyMaterial.value : this.keyMaterial, + externalCryptoKeyId: + externalCryptoKeyId.present + ? externalCryptoKeyId.value + : this.externalCryptoKeyId, + ); + CloudAuthCryptoKeysData copyWithCompanion(CloudAuthCryptoKeysCompanion data) { + return CloudAuthCryptoKeysData( + cryptoKeyId: + data.cryptoKeyId.present ? data.cryptoKeyId.value : this.cryptoKeyId, + keyPurpose: + data.keyPurpose.present ? data.keyPurpose.value : this.keyPurpose, + keyAlgorithm: + data.keyAlgorithm.present + ? data.keyAlgorithm.value + : this.keyAlgorithm, + keyMaterial: + data.keyMaterial.present ? data.keyMaterial.value : this.keyMaterial, + externalCryptoKeyId: + data.externalCryptoKeyId.present + ? data.externalCryptoKeyId.value + : this.externalCryptoKeyId, + ); + } + + @override + String toString() { + return (StringBuffer('CloudAuthCryptoKeysData(') + ..write('cryptoKeyId: $cryptoKeyId, ') + ..write('keyPurpose: $keyPurpose, ') + ..write('keyAlgorithm: $keyAlgorithm, ') + ..write('keyMaterial: $keyMaterial, ') + ..write('externalCryptoKeyId: $externalCryptoKeyId') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + $driftBlobEquality.hash(cryptoKeyId), + keyPurpose, + keyAlgorithm, + $driftBlobEquality.hash(keyMaterial), + externalCryptoKeyId, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is CloudAuthCryptoKeysData && + $driftBlobEquality.equals(other.cryptoKeyId, this.cryptoKeyId) && + other.keyPurpose == this.keyPurpose && + other.keyAlgorithm == this.keyAlgorithm && + $driftBlobEquality.equals(other.keyMaterial, this.keyMaterial) && + other.externalCryptoKeyId == this.externalCryptoKeyId); +} + +class CloudAuthCryptoKeysCompanion + extends UpdateCompanion { + final Value cryptoKeyId; + final Value keyPurpose; + final Value keyAlgorithm; + final Value keyMaterial; + final Value externalCryptoKeyId; + final Value rowid; + const CloudAuthCryptoKeysCompanion({ + this.cryptoKeyId = const Value.absent(), + this.keyPurpose = const Value.absent(), + this.keyAlgorithm = const Value.absent(), + this.keyMaterial = const Value.absent(), + this.externalCryptoKeyId = const Value.absent(), + this.rowid = const Value.absent(), + }); + CloudAuthCryptoKeysCompanion.insert({ + required Uint8List cryptoKeyId, + required String keyPurpose, + required String keyAlgorithm, + this.keyMaterial = const Value.absent(), + this.externalCryptoKeyId = const Value.absent(), + this.rowid = const Value.absent(), + }) : cryptoKeyId = Value(cryptoKeyId), + keyPurpose = Value(keyPurpose), + keyAlgorithm = Value(keyAlgorithm); + static Insertable custom({ + Expression? cryptoKeyId, + Expression? keyPurpose, + Expression? keyAlgorithm, + Expression? keyMaterial, + Expression? externalCryptoKeyId, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (cryptoKeyId != null) 'crypto_key_id': cryptoKeyId, + if (keyPurpose != null) 'key_purpose': keyPurpose, + if (keyAlgorithm != null) 'key_algorithm': keyAlgorithm, + if (keyMaterial != null) 'key_material': keyMaterial, + if (externalCryptoKeyId != null) + 'external_crypto_key_id': externalCryptoKeyId, + if (rowid != null) 'rowid': rowid, + }); + } + + CloudAuthCryptoKeysCompanion copyWith({ + Value? cryptoKeyId, + Value? keyPurpose, + Value? keyAlgorithm, + Value? keyMaterial, + Value? externalCryptoKeyId, + Value? rowid, + }) { + return CloudAuthCryptoKeysCompanion( + cryptoKeyId: cryptoKeyId ?? this.cryptoKeyId, + keyPurpose: keyPurpose ?? this.keyPurpose, + keyAlgorithm: keyAlgorithm ?? this.keyAlgorithm, + keyMaterial: keyMaterial ?? this.keyMaterial, + externalCryptoKeyId: externalCryptoKeyId ?? this.externalCryptoKeyId, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (cryptoKeyId.present) { + map['crypto_key_id'] = Variable(cryptoKeyId.value); + } + if (keyPurpose.present) { + map['key_purpose'] = Variable(keyPurpose.value); + } + if (keyAlgorithm.present) { + map['key_algorithm'] = Variable(keyAlgorithm.value); + } + if (keyMaterial.present) { + map['key_material'] = Variable(keyMaterial.value); + } + if (externalCryptoKeyId.present) { + map['external_crypto_key_id'] = Variable( + externalCryptoKeyId.value, + ); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('CloudAuthCryptoKeysCompanion(') + ..write('cryptoKeyId: $cryptoKeyId, ') + ..write('keyPurpose: $keyPurpose, ') + ..write('keyAlgorithm: $keyAlgorithm, ') + ..write('keyMaterial: $keyMaterial, ') + ..write('externalCryptoKeyId: $externalCryptoKeyId, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +class CloudAuthSessions extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + CloudAuthSessions(this.attachedDatabase, [this._alias]); + late final GeneratedColumn rowid = GeneratedColumn( + 'rowid', + aliasedName, + false, + hasAutoIncrement: true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'PRIMARY KEY AUTOINCREMENT', + ); + late final GeneratedColumn sessionId = GeneratedColumn( + 'session_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL UNIQUE', + ); + late final GeneratedColumn cryptoKeyId = + GeneratedColumn( + 'crypto_key_id', + aliasedName, + false, + type: DriftSqlType.blob, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn userId = GeneratedColumn( + 'user_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn clientInfo = GeneratedColumn( + 'client_info', + aliasedName, + true, + type: DriftSqlType.blob, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn authenticationFactor = + GeneratedColumn( + 'authentication_factor', + aliasedName, + false, + type: DriftSqlType.blob, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn state = GeneratedColumn( + 'state', + aliasedName, + true, + type: DriftSqlType.blob, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn ipAddress = GeneratedColumn( + 'ip_address', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn externalSessionId = + GeneratedColumn( + 'external_session_id', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn createTime = GeneratedColumn( + 'create_time', + aliasedName, + false, + type: DriftSqlType.double, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT (unixepoch(\'now\', \'subsec\'))', + defaultValue: const CustomExpression('unixepoch(\'now\', \'subsec\')'), + ); + late final GeneratedColumn updateTime = GeneratedColumn( + 'update_time', + aliasedName, + true, + type: DriftSqlType.double, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn expireTime = GeneratedColumn( + 'expire_time', + aliasedName, + false, + type: DriftSqlType.double, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + @override + List get $columns => [ + rowid, + sessionId, + cryptoKeyId, + userId, + clientInfo, + authenticationFactor, + state, + ipAddress, + externalSessionId, + createTime, + updateTime, + expireTime, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'cloud_auth_sessions'; + @override + Set get $primaryKey => {rowid}; + @override + CloudAuthSessionsData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return CloudAuthSessionsData( + rowid: + attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}rowid'], + )!, + sessionId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}session_id'], + )!, + cryptoKeyId: + attachedDatabase.typeMapping.read( + DriftSqlType.blob, + data['${effectivePrefix}crypto_key_id'], + )!, + userId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}user_id'], + )!, + clientInfo: attachedDatabase.typeMapping.read( + DriftSqlType.blob, + data['${effectivePrefix}client_info'], + ), + authenticationFactor: + attachedDatabase.typeMapping.read( + DriftSqlType.blob, + data['${effectivePrefix}authentication_factor'], + )!, + state: attachedDatabase.typeMapping.read( + DriftSqlType.blob, + data['${effectivePrefix}state'], + ), + ipAddress: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}ip_address'], + ), + externalSessionId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}external_session_id'], + ), + createTime: + attachedDatabase.typeMapping.read( + DriftSqlType.double, + data['${effectivePrefix}create_time'], + )!, + updateTime: attachedDatabase.typeMapping.read( + DriftSqlType.double, + data['${effectivePrefix}update_time'], + ), + expireTime: + attachedDatabase.typeMapping.read( + DriftSqlType.double, + data['${effectivePrefix}expire_time'], + )!, + ); + } + + @override + CloudAuthSessions createAlias(String alias) { + return CloudAuthSessions(attachedDatabase, alias); + } + + @override + List get customConstraints => const [ + 'CONSTRAINT cloud_auth_sessions_user_fk FOREIGN KEY(user_id)REFERENCES cloud_auth_users(user_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED', + 'CONSTRAINT cloud_auth_sessions_key_fk FOREIGN KEY(crypto_key_id)REFERENCES cloud_auth_crypto_keys(crypto_key_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED', + ]; + @override + bool get dontWriteConstraints => true; +} + +class CloudAuthSessionsData extends DataClass + implements Insertable { + final int rowid; + final String sessionId; + final Uint8List cryptoKeyId; + final String userId; + final Uint8List? clientInfo; + final Uint8List authenticationFactor; + final Uint8List? state; + final String? ipAddress; + final String? externalSessionId; + final double createTime; + final double? updateTime; + final double expireTime; + const CloudAuthSessionsData({ + required this.rowid, + required this.sessionId, + required this.cryptoKeyId, + required this.userId, + this.clientInfo, + required this.authenticationFactor, + this.state, + this.ipAddress, + this.externalSessionId, + required this.createTime, + this.updateTime, + required this.expireTime, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['rowid'] = Variable(rowid); + map['session_id'] = Variable(sessionId); + map['crypto_key_id'] = Variable(cryptoKeyId); + map['user_id'] = Variable(userId); + if (!nullToAbsent || clientInfo != null) { + map['client_info'] = Variable(clientInfo); + } + map['authentication_factor'] = Variable(authenticationFactor); + if (!nullToAbsent || state != null) { + map['state'] = Variable(state); + } + if (!nullToAbsent || ipAddress != null) { + map['ip_address'] = Variable(ipAddress); + } + if (!nullToAbsent || externalSessionId != null) { + map['external_session_id'] = Variable(externalSessionId); + } + map['create_time'] = Variable(createTime); + if (!nullToAbsent || updateTime != null) { + map['update_time'] = Variable(updateTime); + } + map['expire_time'] = Variable(expireTime); + return map; + } + + CloudAuthSessionsCompanion toCompanion(bool nullToAbsent) { + return CloudAuthSessionsCompanion( + rowid: Value(rowid), + sessionId: Value(sessionId), + cryptoKeyId: Value(cryptoKeyId), + userId: Value(userId), + clientInfo: + clientInfo == null && nullToAbsent + ? const Value.absent() + : Value(clientInfo), + authenticationFactor: Value(authenticationFactor), + state: + state == null && nullToAbsent ? const Value.absent() : Value(state), + ipAddress: + ipAddress == null && nullToAbsent + ? const Value.absent() + : Value(ipAddress), + externalSessionId: + externalSessionId == null && nullToAbsent + ? const Value.absent() + : Value(externalSessionId), + createTime: Value(createTime), + updateTime: + updateTime == null && nullToAbsent + ? const Value.absent() + : Value(updateTime), + expireTime: Value(expireTime), + ); + } + + factory CloudAuthSessionsData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return CloudAuthSessionsData( + rowid: serializer.fromJson(json['rowid']), + sessionId: serializer.fromJson(json['sessionId']), + cryptoKeyId: serializer.fromJson(json['cryptoKeyId']), + userId: serializer.fromJson(json['userId']), + clientInfo: serializer.fromJson(json['clientInfo']), + authenticationFactor: serializer.fromJson( + json['authenticationFactor'], + ), + state: serializer.fromJson(json['state']), + ipAddress: serializer.fromJson(json['ipAddress']), + externalSessionId: serializer.fromJson( + json['externalSessionId'], + ), + createTime: serializer.fromJson(json['createTime']), + updateTime: serializer.fromJson(json['updateTime']), + expireTime: serializer.fromJson(json['expireTime']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'rowid': serializer.toJson(rowid), + 'sessionId': serializer.toJson(sessionId), + 'cryptoKeyId': serializer.toJson(cryptoKeyId), + 'userId': serializer.toJson(userId), + 'clientInfo': serializer.toJson(clientInfo), + 'authenticationFactor': serializer.toJson( + authenticationFactor, + ), + 'state': serializer.toJson(state), + 'ipAddress': serializer.toJson(ipAddress), + 'externalSessionId': serializer.toJson(externalSessionId), + 'createTime': serializer.toJson(createTime), + 'updateTime': serializer.toJson(updateTime), + 'expireTime': serializer.toJson(expireTime), + }; + } + + CloudAuthSessionsData copyWith({ + int? rowid, + String? sessionId, + Uint8List? cryptoKeyId, + String? userId, + Value clientInfo = const Value.absent(), + Uint8List? authenticationFactor, + Value state = const Value.absent(), + Value ipAddress = const Value.absent(), + Value externalSessionId = const Value.absent(), + double? createTime, + Value updateTime = const Value.absent(), + double? expireTime, + }) => CloudAuthSessionsData( + rowid: rowid ?? this.rowid, + sessionId: sessionId ?? this.sessionId, + cryptoKeyId: cryptoKeyId ?? this.cryptoKeyId, + userId: userId ?? this.userId, + clientInfo: clientInfo.present ? clientInfo.value : this.clientInfo, + authenticationFactor: authenticationFactor ?? this.authenticationFactor, + state: state.present ? state.value : this.state, + ipAddress: ipAddress.present ? ipAddress.value : this.ipAddress, + externalSessionId: + externalSessionId.present + ? externalSessionId.value + : this.externalSessionId, + createTime: createTime ?? this.createTime, + updateTime: updateTime.present ? updateTime.value : this.updateTime, + expireTime: expireTime ?? this.expireTime, + ); + CloudAuthSessionsData copyWithCompanion(CloudAuthSessionsCompanion data) { + return CloudAuthSessionsData( + rowid: data.rowid.present ? data.rowid.value : this.rowid, + sessionId: data.sessionId.present ? data.sessionId.value : this.sessionId, + cryptoKeyId: + data.cryptoKeyId.present ? data.cryptoKeyId.value : this.cryptoKeyId, + userId: data.userId.present ? data.userId.value : this.userId, + clientInfo: + data.clientInfo.present ? data.clientInfo.value : this.clientInfo, + authenticationFactor: + data.authenticationFactor.present + ? data.authenticationFactor.value + : this.authenticationFactor, + state: data.state.present ? data.state.value : this.state, + ipAddress: data.ipAddress.present ? data.ipAddress.value : this.ipAddress, + externalSessionId: + data.externalSessionId.present + ? data.externalSessionId.value + : this.externalSessionId, + createTime: + data.createTime.present ? data.createTime.value : this.createTime, + updateTime: + data.updateTime.present ? data.updateTime.value : this.updateTime, + expireTime: + data.expireTime.present ? data.expireTime.value : this.expireTime, + ); + } + + @override + String toString() { + return (StringBuffer('CloudAuthSessionsData(') + ..write('rowid: $rowid, ') + ..write('sessionId: $sessionId, ') + ..write('cryptoKeyId: $cryptoKeyId, ') + ..write('userId: $userId, ') + ..write('clientInfo: $clientInfo, ') + ..write('authenticationFactor: $authenticationFactor, ') + ..write('state: $state, ') + ..write('ipAddress: $ipAddress, ') + ..write('externalSessionId: $externalSessionId, ') + ..write('createTime: $createTime, ') + ..write('updateTime: $updateTime, ') + ..write('expireTime: $expireTime') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + rowid, + sessionId, + $driftBlobEquality.hash(cryptoKeyId), + userId, + $driftBlobEquality.hash(clientInfo), + $driftBlobEquality.hash(authenticationFactor), + $driftBlobEquality.hash(state), + ipAddress, + externalSessionId, + createTime, + updateTime, + expireTime, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is CloudAuthSessionsData && + other.rowid == this.rowid && + other.sessionId == this.sessionId && + $driftBlobEquality.equals(other.cryptoKeyId, this.cryptoKeyId) && + other.userId == this.userId && + $driftBlobEquality.equals(other.clientInfo, this.clientInfo) && + $driftBlobEquality.equals( + other.authenticationFactor, + this.authenticationFactor, + ) && + $driftBlobEquality.equals(other.state, this.state) && + other.ipAddress == this.ipAddress && + other.externalSessionId == this.externalSessionId && + other.createTime == this.createTime && + other.updateTime == this.updateTime && + other.expireTime == this.expireTime); +} + +class CloudAuthSessionsCompanion + extends UpdateCompanion { + final Value rowid; + final Value sessionId; + final Value cryptoKeyId; + final Value userId; + final Value clientInfo; + final Value authenticationFactor; + final Value state; + final Value ipAddress; + final Value externalSessionId; + final Value createTime; + final Value updateTime; + final Value expireTime; + const CloudAuthSessionsCompanion({ + this.rowid = const Value.absent(), + this.sessionId = const Value.absent(), + this.cryptoKeyId = const Value.absent(), + this.userId = const Value.absent(), + this.clientInfo = const Value.absent(), + this.authenticationFactor = const Value.absent(), + this.state = const Value.absent(), + this.ipAddress = const Value.absent(), + this.externalSessionId = const Value.absent(), + this.createTime = const Value.absent(), + this.updateTime = const Value.absent(), + this.expireTime = const Value.absent(), + }); + CloudAuthSessionsCompanion.insert({ + this.rowid = const Value.absent(), + required String sessionId, + required Uint8List cryptoKeyId, + required String userId, + this.clientInfo = const Value.absent(), + required Uint8List authenticationFactor, + this.state = const Value.absent(), + this.ipAddress = const Value.absent(), + this.externalSessionId = const Value.absent(), + this.createTime = const Value.absent(), + this.updateTime = const Value.absent(), + required double expireTime, + }) : sessionId = Value(sessionId), + cryptoKeyId = Value(cryptoKeyId), + userId = Value(userId), + authenticationFactor = Value(authenticationFactor), + expireTime = Value(expireTime); + static Insertable custom({ + Expression? rowid, + Expression? sessionId, + Expression? cryptoKeyId, + Expression? userId, + Expression? clientInfo, + Expression? authenticationFactor, + Expression? state, + Expression? ipAddress, + Expression? externalSessionId, + Expression? createTime, + Expression? updateTime, + Expression? expireTime, + }) { + return RawValuesInsertable({ + if (rowid != null) 'rowid': rowid, + if (sessionId != null) 'session_id': sessionId, + if (cryptoKeyId != null) 'crypto_key_id': cryptoKeyId, + if (userId != null) 'user_id': userId, + if (clientInfo != null) 'client_info': clientInfo, + if (authenticationFactor != null) + 'authentication_factor': authenticationFactor, + if (state != null) 'state': state, + if (ipAddress != null) 'ip_address': ipAddress, + if (externalSessionId != null) 'external_session_id': externalSessionId, + if (createTime != null) 'create_time': createTime, + if (updateTime != null) 'update_time': updateTime, + if (expireTime != null) 'expire_time': expireTime, + }); + } + + CloudAuthSessionsCompanion copyWith({ + Value? rowid, + Value? sessionId, + Value? cryptoKeyId, + Value? userId, + Value? clientInfo, + Value? authenticationFactor, + Value? state, + Value? ipAddress, + Value? externalSessionId, + Value? createTime, + Value? updateTime, + Value? expireTime, + }) { + return CloudAuthSessionsCompanion( + rowid: rowid ?? this.rowid, + sessionId: sessionId ?? this.sessionId, + cryptoKeyId: cryptoKeyId ?? this.cryptoKeyId, + userId: userId ?? this.userId, + clientInfo: clientInfo ?? this.clientInfo, + authenticationFactor: authenticationFactor ?? this.authenticationFactor, + state: state ?? this.state, + ipAddress: ipAddress ?? this.ipAddress, + externalSessionId: externalSessionId ?? this.externalSessionId, + createTime: createTime ?? this.createTime, + updateTime: updateTime ?? this.updateTime, + expireTime: expireTime ?? this.expireTime, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + if (sessionId.present) { + map['session_id'] = Variable(sessionId.value); + } + if (cryptoKeyId.present) { + map['crypto_key_id'] = Variable(cryptoKeyId.value); + } + if (userId.present) { + map['user_id'] = Variable(userId.value); + } + if (clientInfo.present) { + map['client_info'] = Variable(clientInfo.value); + } + if (authenticationFactor.present) { + map['authentication_factor'] = Variable( + authenticationFactor.value, + ); + } + if (state.present) { + map['state'] = Variable(state.value); + } + if (ipAddress.present) { + map['ip_address'] = Variable(ipAddress.value); + } + if (externalSessionId.present) { + map['external_session_id'] = Variable(externalSessionId.value); + } + if (createTime.present) { + map['create_time'] = Variable(createTime.value); + } + if (updateTime.present) { + map['update_time'] = Variable(updateTime.value); + } + if (expireTime.present) { + map['expire_time'] = Variable(expireTime.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('CloudAuthSessionsCompanion(') + ..write('rowid: $rowid, ') + ..write('sessionId: $sessionId, ') + ..write('cryptoKeyId: $cryptoKeyId, ') + ..write('userId: $userId, ') + ..write('clientInfo: $clientInfo, ') + ..write('authenticationFactor: $authenticationFactor, ') + ..write('state: $state, ') + ..write('ipAddress: $ipAddress, ') + ..write('externalSessionId: $externalSessionId, ') + ..write('createTime: $createTime, ') + ..write('updateTime: $updateTime, ') + ..write('expireTime: $expireTime') + ..write(')')) + .toString(); + } +} + +class CloudAuthOtpCodes extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + CloudAuthOtpCodes(this.attachedDatabase, [this._alias]); + late final GeneratedColumn rowid = GeneratedColumn( + 'rowid', + aliasedName, + false, + hasAutoIncrement: true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'PRIMARY KEY AUTOINCREMENT', + ); + late final GeneratedColumn sessionId = GeneratedColumn( + 'session_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL UNIQUE', + ); + late final GeneratedColumn resendAttempt = GeneratedColumn( + 'resend_attempt', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT 0', + defaultValue: const CustomExpression('0'), + ); + late final GeneratedColumn verifyAttempt = GeneratedColumn( + 'verify_attempt', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT 0', + defaultValue: const CustomExpression('0'), + ); + late final GeneratedColumn updateTime = GeneratedColumn( + 'update_time', + aliasedName, + false, + type: DriftSqlType.double, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT (unixepoch(\'now\', \'subsec\'))', + defaultValue: const CustomExpression('unixepoch(\'now\', \'subsec\')'), + ); + @override + List get $columns => [ + rowid, + sessionId, + resendAttempt, + verifyAttempt, + updateTime, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'cloud_auth_otp_codes'; + @override + Set get $primaryKey => {rowid}; + @override + CloudAuthOtpCodesData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return CloudAuthOtpCodesData( + rowid: + attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}rowid'], + )!, + sessionId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}session_id'], + )!, + resendAttempt: + attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}resend_attempt'], + )!, + verifyAttempt: + attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}verify_attempt'], + )!, + updateTime: + attachedDatabase.typeMapping.read( + DriftSqlType.double, + data['${effectivePrefix}update_time'], + )!, + ); + } + + @override + CloudAuthOtpCodes createAlias(String alias) { + return CloudAuthOtpCodes(attachedDatabase, alias); + } + + @override + List get customConstraints => const [ + 'CONSTRAINT cloud_auth_otp_codes_session_id_fk FOREIGN KEY(session_id)REFERENCES cloud_auth_sessions(session_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED', + ]; + @override + bool get dontWriteConstraints => true; +} + +class CloudAuthOtpCodesData extends DataClass + implements Insertable { + final int rowid; + final String sessionId; + final int resendAttempt; + final int verifyAttempt; + final double updateTime; + const CloudAuthOtpCodesData({ + required this.rowid, + required this.sessionId, + required this.resendAttempt, + required this.verifyAttempt, + required this.updateTime, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['rowid'] = Variable(rowid); + map['session_id'] = Variable(sessionId); + map['resend_attempt'] = Variable(resendAttempt); + map['verify_attempt'] = Variable(verifyAttempt); + map['update_time'] = Variable(updateTime); + return map; + } + + CloudAuthOtpCodesCompanion toCompanion(bool nullToAbsent) { + return CloudAuthOtpCodesCompanion( + rowid: Value(rowid), + sessionId: Value(sessionId), + resendAttempt: Value(resendAttempt), + verifyAttempt: Value(verifyAttempt), + updateTime: Value(updateTime), + ); + } + + factory CloudAuthOtpCodesData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return CloudAuthOtpCodesData( + rowid: serializer.fromJson(json['rowid']), + sessionId: serializer.fromJson(json['sessionId']), + resendAttempt: serializer.fromJson(json['resendAttempt']), + verifyAttempt: serializer.fromJson(json['verifyAttempt']), + updateTime: serializer.fromJson(json['updateTime']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'rowid': serializer.toJson(rowid), + 'sessionId': serializer.toJson(sessionId), + 'resendAttempt': serializer.toJson(resendAttempt), + 'verifyAttempt': serializer.toJson(verifyAttempt), + 'updateTime': serializer.toJson(updateTime), + }; + } + + CloudAuthOtpCodesData copyWith({ + int? rowid, + String? sessionId, + int? resendAttempt, + int? verifyAttempt, + double? updateTime, + }) => CloudAuthOtpCodesData( + rowid: rowid ?? this.rowid, + sessionId: sessionId ?? this.sessionId, + resendAttempt: resendAttempt ?? this.resendAttempt, + verifyAttempt: verifyAttempt ?? this.verifyAttempt, + updateTime: updateTime ?? this.updateTime, + ); + CloudAuthOtpCodesData copyWithCompanion(CloudAuthOtpCodesCompanion data) { + return CloudAuthOtpCodesData( + rowid: data.rowid.present ? data.rowid.value : this.rowid, + sessionId: data.sessionId.present ? data.sessionId.value : this.sessionId, + resendAttempt: + data.resendAttempt.present + ? data.resendAttempt.value + : this.resendAttempt, + verifyAttempt: + data.verifyAttempt.present + ? data.verifyAttempt.value + : this.verifyAttempt, + updateTime: + data.updateTime.present ? data.updateTime.value : this.updateTime, + ); + } + + @override + String toString() { + return (StringBuffer('CloudAuthOtpCodesData(') + ..write('rowid: $rowid, ') + ..write('sessionId: $sessionId, ') + ..write('resendAttempt: $resendAttempt, ') + ..write('verifyAttempt: $verifyAttempt, ') + ..write('updateTime: $updateTime') + ..write(')')) + .toString(); + } + + @override + int get hashCode => + Object.hash(rowid, sessionId, resendAttempt, verifyAttempt, updateTime); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is CloudAuthOtpCodesData && + other.rowid == this.rowid && + other.sessionId == this.sessionId && + other.resendAttempt == this.resendAttempt && + other.verifyAttempt == this.verifyAttempt && + other.updateTime == this.updateTime); +} + +class CloudAuthOtpCodesCompanion + extends UpdateCompanion { + final Value rowid; + final Value sessionId; + final Value resendAttempt; + final Value verifyAttempt; + final Value updateTime; + const CloudAuthOtpCodesCompanion({ + this.rowid = const Value.absent(), + this.sessionId = const Value.absent(), + this.resendAttempt = const Value.absent(), + this.verifyAttempt = const Value.absent(), + this.updateTime = const Value.absent(), + }); + CloudAuthOtpCodesCompanion.insert({ + this.rowid = const Value.absent(), + required String sessionId, + this.resendAttempt = const Value.absent(), + this.verifyAttempt = const Value.absent(), + this.updateTime = const Value.absent(), + }) : sessionId = Value(sessionId); + static Insertable custom({ + Expression? rowid, + Expression? sessionId, + Expression? resendAttempt, + Expression? verifyAttempt, + Expression? updateTime, + }) { + return RawValuesInsertable({ + if (rowid != null) 'rowid': rowid, + if (sessionId != null) 'session_id': sessionId, + if (resendAttempt != null) 'resend_attempt': resendAttempt, + if (verifyAttempt != null) 'verify_attempt': verifyAttempt, + if (updateTime != null) 'update_time': updateTime, + }); + } + + CloudAuthOtpCodesCompanion copyWith({ + Value? rowid, + Value? sessionId, + Value? resendAttempt, + Value? verifyAttempt, + Value? updateTime, + }) { + return CloudAuthOtpCodesCompanion( + rowid: rowid ?? this.rowid, + sessionId: sessionId ?? this.sessionId, + resendAttempt: resendAttempt ?? this.resendAttempt, + verifyAttempt: verifyAttempt ?? this.verifyAttempt, + updateTime: updateTime ?? this.updateTime, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + if (sessionId.present) { + map['session_id'] = Variable(sessionId.value); + } + if (resendAttempt.present) { + map['resend_attempt'] = Variable(resendAttempt.value); + } + if (verifyAttempt.present) { + map['verify_attempt'] = Variable(verifyAttempt.value); + } + if (updateTime.present) { + map['update_time'] = Variable(updateTime.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('CloudAuthOtpCodesCompanion(') + ..write('rowid: $rowid, ') + ..write('sessionId: $sessionId, ') + ..write('resendAttempt: $resendAttempt, ') + ..write('verifyAttempt: $verifyAttempt, ') + ..write('updateTime: $updateTime') + ..write(')')) + .toString(); + } +} + +class CloudAuthCorks extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + CloudAuthCorks(this.attachedDatabase, [this._alias]); + late final GeneratedColumn corkId = GeneratedColumn( + 'cork_id', + aliasedName, + false, + type: DriftSqlType.blob, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); + late final GeneratedColumn cryptoKeyId = + GeneratedColumn( + 'crypto_key_id', + aliasedName, + false, + type: DriftSqlType.blob, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn bearerType = GeneratedColumn( + 'bearer_type', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn bearerId = GeneratedColumn( + 'bearer_id', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn audienceType = GeneratedColumn( + 'audience_type', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn audienceId = GeneratedColumn( + 'audience_id', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn issuerType = GeneratedColumn( + 'issuer_type', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn issuerId = GeneratedColumn( + 'issuer_id', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn createTime = GeneratedColumn( + 'create_time', + aliasedName, + false, + type: DriftSqlType.double, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT (unixepoch(\'now\', \'subsec\'))', + defaultValue: const CustomExpression('unixepoch(\'now\', \'subsec\')'), + ); + late final GeneratedColumn expireTime = GeneratedColumn( + 'expire_time', + aliasedName, + true, + type: DriftSqlType.double, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn lastUseTime = GeneratedColumn( + 'last_use_time', + aliasedName, + true, + type: DriftSqlType.double, + requiredDuringInsert: false, + $customConstraints: '', + ); + @override + List get $columns => [ + corkId, + cryptoKeyId, + bearerType, + bearerId, + audienceType, + audienceId, + issuerType, + issuerId, + createTime, + expireTime, + lastUseTime, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'cloud_auth_corks'; + @override + Set get $primaryKey => {corkId}; + @override + CloudAuthCorksData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return CloudAuthCorksData( + corkId: + attachedDatabase.typeMapping.read( + DriftSqlType.blob, + data['${effectivePrefix}cork_id'], + )!, + cryptoKeyId: + attachedDatabase.typeMapping.read( + DriftSqlType.blob, + data['${effectivePrefix}crypto_key_id'], + )!, + bearerType: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}bearer_type'], + ), + bearerId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}bearer_id'], + ), + audienceType: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}audience_type'], + ), + audienceId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}audience_id'], + ), + issuerType: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}issuer_type'], + ), + issuerId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}issuer_id'], + ), + createTime: + attachedDatabase.typeMapping.read( + DriftSqlType.double, + data['${effectivePrefix}create_time'], + )!, + expireTime: attachedDatabase.typeMapping.read( + DriftSqlType.double, + data['${effectivePrefix}expire_time'], + ), + lastUseTime: attachedDatabase.typeMapping.read( + DriftSqlType.double, + data['${effectivePrefix}last_use_time'], + ), + ); + } + + @override + CloudAuthCorks createAlias(String alias) { + return CloudAuthCorks(attachedDatabase, alias); + } + + @override + List get customConstraints => const [ + 'CONSTRAINT cloud_auth_corks_crypto_key_fk FOREIGN KEY(crypto_key_id)REFERENCES cloud_auth_crypto_keys(crypto_key_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED', + 'CONSTRAINT cloud_auth_corks_bearer_fk FOREIGN KEY(bearer_type, bearer_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED', + 'CONSTRAINT cloud_auth_corks_audience_fk FOREIGN KEY(audience_type, audience_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED', + 'CONSTRAINT cloud_auth_corks_issuer_fk FOREIGN KEY(issuer_type, issuer_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED', + ]; + @override + bool get dontWriteConstraints => true; +} + +class CloudAuthCorksData extends DataClass + implements Insertable { + final Uint8List corkId; + final Uint8List cryptoKeyId; + final String? bearerType; + final String? bearerId; + final String? audienceType; + final String? audienceId; + final String? issuerType; + final String? issuerId; + final double createTime; + final double? expireTime; + final double? lastUseTime; + const CloudAuthCorksData({ + required this.corkId, + required this.cryptoKeyId, + this.bearerType, + this.bearerId, + this.audienceType, + this.audienceId, + this.issuerType, + this.issuerId, + required this.createTime, + this.expireTime, + this.lastUseTime, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['cork_id'] = Variable(corkId); + map['crypto_key_id'] = Variable(cryptoKeyId); + if (!nullToAbsent || bearerType != null) { + map['bearer_type'] = Variable(bearerType); + } + if (!nullToAbsent || bearerId != null) { + map['bearer_id'] = Variable(bearerId); + } + if (!nullToAbsent || audienceType != null) { + map['audience_type'] = Variable(audienceType); + } + if (!nullToAbsent || audienceId != null) { + map['audience_id'] = Variable(audienceId); + } + if (!nullToAbsent || issuerType != null) { + map['issuer_type'] = Variable(issuerType); + } + if (!nullToAbsent || issuerId != null) { + map['issuer_id'] = Variable(issuerId); + } + map['create_time'] = Variable(createTime); + if (!nullToAbsent || expireTime != null) { + map['expire_time'] = Variable(expireTime); + } + if (!nullToAbsent || lastUseTime != null) { + map['last_use_time'] = Variable(lastUseTime); + } + return map; + } + + CloudAuthCorksCompanion toCompanion(bool nullToAbsent) { + return CloudAuthCorksCompanion( + corkId: Value(corkId), + cryptoKeyId: Value(cryptoKeyId), + bearerType: + bearerType == null && nullToAbsent + ? const Value.absent() + : Value(bearerType), + bearerId: + bearerId == null && nullToAbsent + ? const Value.absent() + : Value(bearerId), + audienceType: + audienceType == null && nullToAbsent + ? const Value.absent() + : Value(audienceType), + audienceId: + audienceId == null && nullToAbsent + ? const Value.absent() + : Value(audienceId), + issuerType: + issuerType == null && nullToAbsent + ? const Value.absent() + : Value(issuerType), + issuerId: + issuerId == null && nullToAbsent + ? const Value.absent() + : Value(issuerId), + createTime: Value(createTime), + expireTime: + expireTime == null && nullToAbsent + ? const Value.absent() + : Value(expireTime), + lastUseTime: + lastUseTime == null && nullToAbsent + ? const Value.absent() + : Value(lastUseTime), + ); + } + + factory CloudAuthCorksData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return CloudAuthCorksData( + corkId: serializer.fromJson(json['corkId']), + cryptoKeyId: serializer.fromJson(json['cryptoKeyId']), + bearerType: serializer.fromJson(json['bearerType']), + bearerId: serializer.fromJson(json['bearerId']), + audienceType: serializer.fromJson(json['audienceType']), + audienceId: serializer.fromJson(json['audienceId']), + issuerType: serializer.fromJson(json['issuerType']), + issuerId: serializer.fromJson(json['issuerId']), + createTime: serializer.fromJson(json['createTime']), + expireTime: serializer.fromJson(json['expireTime']), + lastUseTime: serializer.fromJson(json['lastUseTime']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'corkId': serializer.toJson(corkId), + 'cryptoKeyId': serializer.toJson(cryptoKeyId), + 'bearerType': serializer.toJson(bearerType), + 'bearerId': serializer.toJson(bearerId), + 'audienceType': serializer.toJson(audienceType), + 'audienceId': serializer.toJson(audienceId), + 'issuerType': serializer.toJson(issuerType), + 'issuerId': serializer.toJson(issuerId), + 'createTime': serializer.toJson(createTime), + 'expireTime': serializer.toJson(expireTime), + 'lastUseTime': serializer.toJson(lastUseTime), + }; + } + + CloudAuthCorksData copyWith({ + Uint8List? corkId, + Uint8List? cryptoKeyId, + Value bearerType = const Value.absent(), + Value bearerId = const Value.absent(), + Value audienceType = const Value.absent(), + Value audienceId = const Value.absent(), + Value issuerType = const Value.absent(), + Value issuerId = const Value.absent(), + double? createTime, + Value expireTime = const Value.absent(), + Value lastUseTime = const Value.absent(), + }) => CloudAuthCorksData( + corkId: corkId ?? this.corkId, + cryptoKeyId: cryptoKeyId ?? this.cryptoKeyId, + bearerType: bearerType.present ? bearerType.value : this.bearerType, + bearerId: bearerId.present ? bearerId.value : this.bearerId, + audienceType: audienceType.present ? audienceType.value : this.audienceType, + audienceId: audienceId.present ? audienceId.value : this.audienceId, + issuerType: issuerType.present ? issuerType.value : this.issuerType, + issuerId: issuerId.present ? issuerId.value : this.issuerId, + createTime: createTime ?? this.createTime, + expireTime: expireTime.present ? expireTime.value : this.expireTime, + lastUseTime: lastUseTime.present ? lastUseTime.value : this.lastUseTime, + ); + CloudAuthCorksData copyWithCompanion(CloudAuthCorksCompanion data) { + return CloudAuthCorksData( + corkId: data.corkId.present ? data.corkId.value : this.corkId, + cryptoKeyId: + data.cryptoKeyId.present ? data.cryptoKeyId.value : this.cryptoKeyId, + bearerType: + data.bearerType.present ? data.bearerType.value : this.bearerType, + bearerId: data.bearerId.present ? data.bearerId.value : this.bearerId, + audienceType: + data.audienceType.present + ? data.audienceType.value + : this.audienceType, + audienceId: + data.audienceId.present ? data.audienceId.value : this.audienceId, + issuerType: + data.issuerType.present ? data.issuerType.value : this.issuerType, + issuerId: data.issuerId.present ? data.issuerId.value : this.issuerId, + createTime: + data.createTime.present ? data.createTime.value : this.createTime, + expireTime: + data.expireTime.present ? data.expireTime.value : this.expireTime, + lastUseTime: + data.lastUseTime.present ? data.lastUseTime.value : this.lastUseTime, + ); + } + + @override + String toString() { + return (StringBuffer('CloudAuthCorksData(') + ..write('corkId: $corkId, ') + ..write('cryptoKeyId: $cryptoKeyId, ') + ..write('bearerType: $bearerType, ') + ..write('bearerId: $bearerId, ') + ..write('audienceType: $audienceType, ') + ..write('audienceId: $audienceId, ') + ..write('issuerType: $issuerType, ') + ..write('issuerId: $issuerId, ') + ..write('createTime: $createTime, ') + ..write('expireTime: $expireTime, ') + ..write('lastUseTime: $lastUseTime') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + $driftBlobEquality.hash(corkId), + $driftBlobEquality.hash(cryptoKeyId), + bearerType, + bearerId, + audienceType, + audienceId, + issuerType, + issuerId, + createTime, + expireTime, + lastUseTime, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is CloudAuthCorksData && + $driftBlobEquality.equals(other.corkId, this.corkId) && + $driftBlobEquality.equals(other.cryptoKeyId, this.cryptoKeyId) && + other.bearerType == this.bearerType && + other.bearerId == this.bearerId && + other.audienceType == this.audienceType && + other.audienceId == this.audienceId && + other.issuerType == this.issuerType && + other.issuerId == this.issuerId && + other.createTime == this.createTime && + other.expireTime == this.expireTime && + other.lastUseTime == this.lastUseTime); +} + +class CloudAuthCorksCompanion extends UpdateCompanion { + final Value corkId; + final Value cryptoKeyId; + final Value bearerType; + final Value bearerId; + final Value audienceType; + final Value audienceId; + final Value issuerType; + final Value issuerId; + final Value createTime; + final Value expireTime; + final Value lastUseTime; + final Value rowid; + const CloudAuthCorksCompanion({ + this.corkId = const Value.absent(), + this.cryptoKeyId = const Value.absent(), + this.bearerType = const Value.absent(), + this.bearerId = const Value.absent(), + this.audienceType = const Value.absent(), + this.audienceId = const Value.absent(), + this.issuerType = const Value.absent(), + this.issuerId = const Value.absent(), + this.createTime = const Value.absent(), + this.expireTime = const Value.absent(), + this.lastUseTime = const Value.absent(), + this.rowid = const Value.absent(), + }); + CloudAuthCorksCompanion.insert({ + required Uint8List corkId, + required Uint8List cryptoKeyId, + this.bearerType = const Value.absent(), + this.bearerId = const Value.absent(), + this.audienceType = const Value.absent(), + this.audienceId = const Value.absent(), + this.issuerType = const Value.absent(), + this.issuerId = const Value.absent(), + this.createTime = const Value.absent(), + this.expireTime = const Value.absent(), + this.lastUseTime = const Value.absent(), + this.rowid = const Value.absent(), + }) : corkId = Value(corkId), + cryptoKeyId = Value(cryptoKeyId); + static Insertable custom({ + Expression? corkId, + Expression? cryptoKeyId, + Expression? bearerType, + Expression? bearerId, + Expression? audienceType, + Expression? audienceId, + Expression? issuerType, + Expression? issuerId, + Expression? createTime, + Expression? expireTime, + Expression? lastUseTime, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (corkId != null) 'cork_id': corkId, + if (cryptoKeyId != null) 'crypto_key_id': cryptoKeyId, + if (bearerType != null) 'bearer_type': bearerType, + if (bearerId != null) 'bearer_id': bearerId, + if (audienceType != null) 'audience_type': audienceType, + if (audienceId != null) 'audience_id': audienceId, + if (issuerType != null) 'issuer_type': issuerType, + if (issuerId != null) 'issuer_id': issuerId, + if (createTime != null) 'create_time': createTime, + if (expireTime != null) 'expire_time': expireTime, + if (lastUseTime != null) 'last_use_time': lastUseTime, + if (rowid != null) 'rowid': rowid, + }); + } + + CloudAuthCorksCompanion copyWith({ + Value? corkId, + Value? cryptoKeyId, + Value? bearerType, + Value? bearerId, + Value? audienceType, + Value? audienceId, + Value? issuerType, + Value? issuerId, + Value? createTime, + Value? expireTime, + Value? lastUseTime, + Value? rowid, + }) { + return CloudAuthCorksCompanion( + corkId: corkId ?? this.corkId, + cryptoKeyId: cryptoKeyId ?? this.cryptoKeyId, + bearerType: bearerType ?? this.bearerType, + bearerId: bearerId ?? this.bearerId, + audienceType: audienceType ?? this.audienceType, + audienceId: audienceId ?? this.audienceId, + issuerType: issuerType ?? this.issuerType, + issuerId: issuerId ?? this.issuerId, + createTime: createTime ?? this.createTime, + expireTime: expireTime ?? this.expireTime, + lastUseTime: lastUseTime ?? this.lastUseTime, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (corkId.present) { + map['cork_id'] = Variable(corkId.value); + } + if (cryptoKeyId.present) { + map['crypto_key_id'] = Variable(cryptoKeyId.value); + } + if (bearerType.present) { + map['bearer_type'] = Variable(bearerType.value); + } + if (bearerId.present) { + map['bearer_id'] = Variable(bearerId.value); + } + if (audienceType.present) { + map['audience_type'] = Variable(audienceType.value); + } + if (audienceId.present) { + map['audience_id'] = Variable(audienceId.value); + } + if (issuerType.present) { + map['issuer_type'] = Variable(issuerType.value); + } + if (issuerId.present) { + map['issuer_id'] = Variable(issuerId.value); + } + if (createTime.present) { + map['create_time'] = Variable(createTime.value); + } + if (expireTime.present) { + map['expire_time'] = Variable(expireTime.value); + } + if (lastUseTime.present) { + map['last_use_time'] = Variable(lastUseTime.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('CloudAuthCorksCompanion(') + ..write('corkId: $corkId, ') + ..write('cryptoKeyId: $cryptoKeyId, ') + ..write('bearerType: $bearerType, ') + ..write('bearerId: $bearerId, ') + ..write('audienceType: $audienceType, ') + ..write('audienceId: $audienceId, ') + ..write('issuerType: $issuerType, ') + ..write('issuerId: $issuerId, ') + ..write('createTime: $createTime, ') + ..write('expireTime: $expireTime, ') + ..write('lastUseTime: $lastUseTime, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +class CedarPolicies extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + CedarPolicies(this.attachedDatabase, [this._alias]); + late final GeneratedColumn id = GeneratedColumn( + 'id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); + late final GeneratedColumn policyId = GeneratedColumn( + 'policy_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL UNIQUE', + ); + late final GeneratedColumn policy = GeneratedColumn( + 'policy', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn enforcementLevel = GeneratedColumn( + 'enforcement_level', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT 1', + defaultValue: const CustomExpression('1'), + ); + @override + List get $columns => [ + id, + policyId, + policy, + enforcementLevel, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'cedar_policies'; + @override + Set get $primaryKey => {id}; + @override + CedarPoliciesData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return CedarPoliciesData( + id: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}id'], + )!, + policyId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}policy_id'], + )!, + policy: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}policy'], + )!, + enforcementLevel: + attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}enforcement_level'], + )!, + ); + } + + @override + CedarPolicies createAlias(String alias) { + return CedarPolicies(attachedDatabase, alias); + } + + @override + List get customConstraints => const [ + 'CHECK(enforcement_level IN (0, 1))', + ]; + @override + bool get dontWriteConstraints => true; +} + +class CedarPoliciesData extends DataClass + implements Insertable { + final String id; + final String policyId; + final String policy; + final int enforcementLevel; + const CedarPoliciesData({ + required this.id, + required this.policyId, + required this.policy, + required this.enforcementLevel, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['policy_id'] = Variable(policyId); + map['policy'] = Variable(policy); + map['enforcement_level'] = Variable(enforcementLevel); + return map; + } + + CedarPoliciesCompanion toCompanion(bool nullToAbsent) { + return CedarPoliciesCompanion( + id: Value(id), + policyId: Value(policyId), + policy: Value(policy), + enforcementLevel: Value(enforcementLevel), + ); + } + + factory CedarPoliciesData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return CedarPoliciesData( + id: serializer.fromJson(json['id']), + policyId: serializer.fromJson(json['policyId']), + policy: serializer.fromJson(json['policy']), + enforcementLevel: serializer.fromJson(json['enforcementLevel']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'policyId': serializer.toJson(policyId), + 'policy': serializer.toJson(policy), + 'enforcementLevel': serializer.toJson(enforcementLevel), + }; + } + + CedarPoliciesData copyWith({ + String? id, + String? policyId, + String? policy, + int? enforcementLevel, + }) => CedarPoliciesData( + id: id ?? this.id, + policyId: policyId ?? this.policyId, + policy: policy ?? this.policy, + enforcementLevel: enforcementLevel ?? this.enforcementLevel, + ); + CedarPoliciesData copyWithCompanion(CedarPoliciesCompanion data) { + return CedarPoliciesData( + id: data.id.present ? data.id.value : this.id, + policyId: data.policyId.present ? data.policyId.value : this.policyId, + policy: data.policy.present ? data.policy.value : this.policy, + enforcementLevel: + data.enforcementLevel.present + ? data.enforcementLevel.value + : this.enforcementLevel, + ); + } + + @override + String toString() { + return (StringBuffer('CedarPoliciesData(') + ..write('id: $id, ') + ..write('policyId: $policyId, ') + ..write('policy: $policy, ') + ..write('enforcementLevel: $enforcementLevel') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(id, policyId, policy, enforcementLevel); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is CedarPoliciesData && + other.id == this.id && + other.policyId == this.policyId && + other.policy == this.policy && + other.enforcementLevel == this.enforcementLevel); +} + +class CedarPoliciesCompanion extends UpdateCompanion { + final Value id; + final Value policyId; + final Value policy; + final Value enforcementLevel; + final Value rowid; + const CedarPoliciesCompanion({ + this.id = const Value.absent(), + this.policyId = const Value.absent(), + this.policy = const Value.absent(), + this.enforcementLevel = const Value.absent(), + this.rowid = const Value.absent(), + }); + CedarPoliciesCompanion.insert({ + required String id, + required String policyId, + required String policy, + this.enforcementLevel = const Value.absent(), + this.rowid = const Value.absent(), + }) : id = Value(id), + policyId = Value(policyId), + policy = Value(policy); + static Insertable custom({ + Expression? id, + Expression? policyId, + Expression? policy, + Expression? enforcementLevel, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (policyId != null) 'policy_id': policyId, + if (policy != null) 'policy': policy, + if (enforcementLevel != null) 'enforcement_level': enforcementLevel, + if (rowid != null) 'rowid': rowid, + }); + } + + CedarPoliciesCompanion copyWith({ + Value? id, + Value? policyId, + Value? policy, + Value? enforcementLevel, + Value? rowid, + }) { + return CedarPoliciesCompanion( + id: id ?? this.id, + policyId: policyId ?? this.policyId, + policy: policy ?? this.policy, + enforcementLevel: enforcementLevel ?? this.enforcementLevel, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (policyId.present) { + map['policy_id'] = Variable(policyId.value); + } + if (policy.present) { + map['policy'] = Variable(policy.value); + } + if (enforcementLevel.present) { + map['enforcement_level'] = Variable(enforcementLevel.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('CedarPoliciesCompanion(') + ..write('id: $id, ') + ..write('policyId: $policyId, ') + ..write('policy: $policy, ') + ..write('enforcementLevel: $enforcementLevel, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +class CedarPolicyTemplates extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + CedarPolicyTemplates(this.attachedDatabase, [this._alias]); + late final GeneratedColumn id = GeneratedColumn( + 'id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); + late final GeneratedColumn templateId = GeneratedColumn( + 'template_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL UNIQUE', + ); + late final GeneratedColumn template = GeneratedColumn( + 'template', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + @override + List get $columns => [id, templateId, template]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'cedar_policy_templates'; + @override + Set get $primaryKey => {id}; + @override + CedarPolicyTemplatesData map( + Map data, { + String? tablePrefix, + }) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return CedarPolicyTemplatesData( + id: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}id'], + )!, + templateId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}template_id'], + )!, + template: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}template'], + )!, + ); + } + + @override + CedarPolicyTemplates createAlias(String alias) { + return CedarPolicyTemplates(attachedDatabase, alias); + } + + @override + List get customConstraints => const [ + 'CHECK(template IS NOT NULL OR template IS NOT NULL)', + ]; + @override + bool get dontWriteConstraints => true; +} + +class CedarPolicyTemplatesData extends DataClass + implements Insertable { + final String id; + final String templateId; + final String template; + const CedarPolicyTemplatesData({ + required this.id, + required this.templateId, + required this.template, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['template_id'] = Variable(templateId); + map['template'] = Variable(template); + return map; + } + + CedarPolicyTemplatesCompanion toCompanion(bool nullToAbsent) { + return CedarPolicyTemplatesCompanion( + id: Value(id), + templateId: Value(templateId), + template: Value(template), + ); + } + + factory CedarPolicyTemplatesData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return CedarPolicyTemplatesData( + id: serializer.fromJson(json['id']), + templateId: serializer.fromJson(json['templateId']), + template: serializer.fromJson(json['template']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'templateId': serializer.toJson(templateId), + 'template': serializer.toJson(template), + }; + } + + CedarPolicyTemplatesData copyWith({ + String? id, + String? templateId, + String? template, + }) => CedarPolicyTemplatesData( + id: id ?? this.id, + templateId: templateId ?? this.templateId, + template: template ?? this.template, + ); + CedarPolicyTemplatesData copyWithCompanion( + CedarPolicyTemplatesCompanion data, + ) { + return CedarPolicyTemplatesData( + id: data.id.present ? data.id.value : this.id, + templateId: + data.templateId.present ? data.templateId.value : this.templateId, + template: data.template.present ? data.template.value : this.template, + ); + } + + @override + String toString() { + return (StringBuffer('CedarPolicyTemplatesData(') + ..write('id: $id, ') + ..write('templateId: $templateId, ') + ..write('template: $template') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash(id, templateId, template); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is CedarPolicyTemplatesData && + other.id == this.id && + other.templateId == this.templateId && + other.template == this.template); +} + +class CedarPolicyTemplatesCompanion + extends UpdateCompanion { + final Value id; + final Value templateId; + final Value template; + final Value rowid; + const CedarPolicyTemplatesCompanion({ + this.id = const Value.absent(), + this.templateId = const Value.absent(), + this.template = const Value.absent(), + this.rowid = const Value.absent(), + }); + CedarPolicyTemplatesCompanion.insert({ + required String id, + required String templateId, + required String template, + this.rowid = const Value.absent(), + }) : id = Value(id), + templateId = Value(templateId), + template = Value(template); + static Insertable custom({ + Expression? id, + Expression? templateId, + Expression? template, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (templateId != null) 'template_id': templateId, + if (template != null) 'template': template, + if (rowid != null) 'rowid': rowid, + }); + } + + CedarPolicyTemplatesCompanion copyWith({ + Value? id, + Value? templateId, + Value? template, + Value? rowid, + }) { + return CedarPolicyTemplatesCompanion( + id: id ?? this.id, + templateId: templateId ?? this.templateId, + template: template ?? this.template, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (templateId.present) { + map['template_id'] = Variable(templateId.value); + } + if (template.present) { + map['template'] = Variable(template.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('CedarPolicyTemplatesCompanion(') + ..write('id: $id, ') + ..write('templateId: $templateId, ') + ..write('template: $template, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +class CedarPolicyTemplateLinks extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + CedarPolicyTemplateLinks(this.attachedDatabase, [this._alias]); + late final GeneratedColumn id = GeneratedColumn( + 'id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); + late final GeneratedColumn policyId = GeneratedColumn( + 'policy_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL UNIQUE', + ); + late final GeneratedColumn templateId = GeneratedColumn( + 'template_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn principalType = GeneratedColumn( + 'principal_type', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn principalId = GeneratedColumn( + 'principal_id', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn resourceType = GeneratedColumn( + 'resource_type', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn resourceId = GeneratedColumn( + 'resource_id', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn enforcementLevel = GeneratedColumn( + 'enforcement_level', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT 1', + defaultValue: const CustomExpression('1'), + ); + @override + List get $columns => [ + id, + policyId, + templateId, + principalType, + principalId, + resourceType, + resourceId, + enforcementLevel, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'cedar_policy_template_links'; + @override + Set get $primaryKey => {id}; + @override + CedarPolicyTemplateLinksData map( + Map data, { + String? tablePrefix, + }) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return CedarPolicyTemplateLinksData( + id: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}id'], + )!, + policyId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}policy_id'], + )!, + templateId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}template_id'], + )!, + principalType: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}principal_type'], + ), + principalId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}principal_id'], + ), + resourceType: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}resource_type'], + ), + resourceId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}resource_id'], + ), + enforcementLevel: + attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}enforcement_level'], + )!, + ); + } + + @override + CedarPolicyTemplateLinks createAlias(String alias) { + return CedarPolicyTemplateLinks(attachedDatabase, alias); + } + + @override + List get customConstraints => const [ + 'CHECK(principal_type IS NOT NULL AND principal_id IS NOT NULL OR resource_type IS NOT NULL AND resource_id IS NOT NULL)', + 'CHECK(enforcement_level IN (0, 1))', + 'CONSTRAINT cedar_policy_template_links_fk_template_id FOREIGN KEY(template_id)REFERENCES cedar_policy_templates(template_id)ON UPDATE CASCADE ON DELETE CASCADE', + 'CONSTRAINT cedar_policy_template_links_fk_principal FOREIGN KEY(principal_type, principal_id)REFERENCES cedar_entities(entity_type, entity_id)ON DELETE CASCADE', + 'CONSTRAINT cedar_policy_template_links_fk_resource FOREIGN KEY(resource_type, resource_id)REFERENCES cedar_entities(entity_type, entity_id)ON DELETE CASCADE', + ]; + @override + bool get dontWriteConstraints => true; +} + +class CedarPolicyTemplateLinksData extends DataClass + implements Insertable { + final String id; + final String policyId; + final String templateId; + final String? principalType; + final String? principalId; + final String? resourceType; + final String? resourceId; + final int enforcementLevel; + const CedarPolicyTemplateLinksData({ + required this.id, + required this.policyId, + required this.templateId, + this.principalType, + this.principalId, + this.resourceType, + this.resourceId, + required this.enforcementLevel, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['policy_id'] = Variable(policyId); + map['template_id'] = Variable(templateId); + if (!nullToAbsent || principalType != null) { + map['principal_type'] = Variable(principalType); + } + if (!nullToAbsent || principalId != null) { + map['principal_id'] = Variable(principalId); + } + if (!nullToAbsent || resourceType != null) { + map['resource_type'] = Variable(resourceType); + } + if (!nullToAbsent || resourceId != null) { + map['resource_id'] = Variable(resourceId); + } + map['enforcement_level'] = Variable(enforcementLevel); + return map; + } + + CedarPolicyTemplateLinksCompanion toCompanion(bool nullToAbsent) { + return CedarPolicyTemplateLinksCompanion( + id: Value(id), + policyId: Value(policyId), + templateId: Value(templateId), + principalType: + principalType == null && nullToAbsent + ? const Value.absent() + : Value(principalType), + principalId: + principalId == null && nullToAbsent + ? const Value.absent() + : Value(principalId), + resourceType: + resourceType == null && nullToAbsent + ? const Value.absent() + : Value(resourceType), + resourceId: + resourceId == null && nullToAbsent + ? const Value.absent() + : Value(resourceId), + enforcementLevel: Value(enforcementLevel), + ); + } + + factory CedarPolicyTemplateLinksData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return CedarPolicyTemplateLinksData( + id: serializer.fromJson(json['id']), + policyId: serializer.fromJson(json['policyId']), + templateId: serializer.fromJson(json['templateId']), + principalType: serializer.fromJson(json['principalType']), + principalId: serializer.fromJson(json['principalId']), + resourceType: serializer.fromJson(json['resourceType']), + resourceId: serializer.fromJson(json['resourceId']), + enforcementLevel: serializer.fromJson(json['enforcementLevel']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'policyId': serializer.toJson(policyId), + 'templateId': serializer.toJson(templateId), + 'principalType': serializer.toJson(principalType), + 'principalId': serializer.toJson(principalId), + 'resourceType': serializer.toJson(resourceType), + 'resourceId': serializer.toJson(resourceId), + 'enforcementLevel': serializer.toJson(enforcementLevel), + }; + } + + CedarPolicyTemplateLinksData copyWith({ + String? id, + String? policyId, + String? templateId, + Value principalType = const Value.absent(), + Value principalId = const Value.absent(), + Value resourceType = const Value.absent(), + Value resourceId = const Value.absent(), + int? enforcementLevel, + }) => CedarPolicyTemplateLinksData( + id: id ?? this.id, + policyId: policyId ?? this.policyId, + templateId: templateId ?? this.templateId, + principalType: + principalType.present ? principalType.value : this.principalType, + principalId: principalId.present ? principalId.value : this.principalId, + resourceType: resourceType.present ? resourceType.value : this.resourceType, + resourceId: resourceId.present ? resourceId.value : this.resourceId, + enforcementLevel: enforcementLevel ?? this.enforcementLevel, + ); + CedarPolicyTemplateLinksData copyWithCompanion( + CedarPolicyTemplateLinksCompanion data, + ) { + return CedarPolicyTemplateLinksData( + id: data.id.present ? data.id.value : this.id, + policyId: data.policyId.present ? data.policyId.value : this.policyId, + templateId: + data.templateId.present ? data.templateId.value : this.templateId, + principalType: + data.principalType.present + ? data.principalType.value + : this.principalType, + principalId: + data.principalId.present ? data.principalId.value : this.principalId, + resourceType: + data.resourceType.present + ? data.resourceType.value + : this.resourceType, + resourceId: + data.resourceId.present ? data.resourceId.value : this.resourceId, + enforcementLevel: + data.enforcementLevel.present + ? data.enforcementLevel.value + : this.enforcementLevel, + ); + } + + @override + String toString() { + return (StringBuffer('CedarPolicyTemplateLinksData(') + ..write('id: $id, ') + ..write('policyId: $policyId, ') + ..write('templateId: $templateId, ') + ..write('principalType: $principalType, ') + ..write('principalId: $principalId, ') + ..write('resourceType: $resourceType, ') + ..write('resourceId: $resourceId, ') + ..write('enforcementLevel: $enforcementLevel') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + id, + policyId, + templateId, + principalType, + principalId, + resourceType, + resourceId, + enforcementLevel, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is CedarPolicyTemplateLinksData && + other.id == this.id && + other.policyId == this.policyId && + other.templateId == this.templateId && + other.principalType == this.principalType && + other.principalId == this.principalId && + other.resourceType == this.resourceType && + other.resourceId == this.resourceId && + other.enforcementLevel == this.enforcementLevel); +} + +class CedarPolicyTemplateLinksCompanion + extends UpdateCompanion { + final Value id; + final Value policyId; + final Value templateId; + final Value principalType; + final Value principalId; + final Value resourceType; + final Value resourceId; + final Value enforcementLevel; + final Value rowid; + const CedarPolicyTemplateLinksCompanion({ + this.id = const Value.absent(), + this.policyId = const Value.absent(), + this.templateId = const Value.absent(), + this.principalType = const Value.absent(), + this.principalId = const Value.absent(), + this.resourceType = const Value.absent(), + this.resourceId = const Value.absent(), + this.enforcementLevel = const Value.absent(), + this.rowid = const Value.absent(), + }); + CedarPolicyTemplateLinksCompanion.insert({ + required String id, + required String policyId, + required String templateId, + this.principalType = const Value.absent(), + this.principalId = const Value.absent(), + this.resourceType = const Value.absent(), + this.resourceId = const Value.absent(), + this.enforcementLevel = const Value.absent(), + this.rowid = const Value.absent(), + }) : id = Value(id), + policyId = Value(policyId), + templateId = Value(templateId); + static Insertable custom({ + Expression? id, + Expression? policyId, + Expression? templateId, + Expression? principalType, + Expression? principalId, + Expression? resourceType, + Expression? resourceId, + Expression? enforcementLevel, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (policyId != null) 'policy_id': policyId, + if (templateId != null) 'template_id': templateId, + if (principalType != null) 'principal_type': principalType, + if (principalId != null) 'principal_id': principalId, + if (resourceType != null) 'resource_type': resourceType, + if (resourceId != null) 'resource_id': resourceId, + if (enforcementLevel != null) 'enforcement_level': enforcementLevel, + if (rowid != null) 'rowid': rowid, + }); + } + + CedarPolicyTemplateLinksCompanion copyWith({ + Value? id, + Value? policyId, + Value? templateId, + Value? principalType, + Value? principalId, + Value? resourceType, + Value? resourceId, + Value? enforcementLevel, + Value? rowid, + }) { + return CedarPolicyTemplateLinksCompanion( + id: id ?? this.id, + policyId: policyId ?? this.policyId, + templateId: templateId ?? this.templateId, + principalType: principalType ?? this.principalType, + principalId: principalId ?? this.principalId, + resourceType: resourceType ?? this.resourceType, + resourceId: resourceId ?? this.resourceId, + enforcementLevel: enforcementLevel ?? this.enforcementLevel, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (policyId.present) { + map['policy_id'] = Variable(policyId.value); + } + if (templateId.present) { + map['template_id'] = Variable(templateId.value); + } + if (principalType.present) { + map['principal_type'] = Variable(principalType.value); + } + if (principalId.present) { + map['principal_id'] = Variable(principalId.value); + } + if (resourceType.present) { + map['resource_type'] = Variable(resourceType.value); + } + if (resourceId.present) { + map['resource_id'] = Variable(resourceId.value); + } + if (enforcementLevel.present) { + map['enforcement_level'] = Variable(enforcementLevel.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('CedarPolicyTemplateLinksCompanion(') + ..write('id: $id, ') + ..write('policyId: $policyId, ') + ..write('templateId: $templateId, ') + ..write('principalType: $principalType, ') + ..write('principalId: $principalId, ') + ..write('resourceType: $resourceType, ') + ..write('resourceId: $resourceId, ') + ..write('enforcementLevel: $enforcementLevel, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +class CedarAuthorizationLogs extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + CedarAuthorizationLogs(this.attachedDatabase, [this._alias]); + late final GeneratedColumn rowid = GeneratedColumn( + 'rowid', + aliasedName, + false, + hasAutoIncrement: true, + type: DriftSqlType.int, + requiredDuringInsert: false, + $customConstraints: 'PRIMARY KEY AUTOINCREMENT', + ); + late final GeneratedColumn createTime = GeneratedColumn( + 'create_time', + aliasedName, + false, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT (unixepoch(\'now\', \'subsec\'))', + defaultValue: const CustomExpression('unixepoch(\'now\', \'subsec\')'), + ); + late final GeneratedColumn expireTime = GeneratedColumn( + 'expire_time', + aliasedName, + true, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn principalType = GeneratedColumn( + 'principal_type', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn principalId = GeneratedColumn( + 'principal_id', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn actionType = GeneratedColumn( + 'action_type', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn actionId = GeneratedColumn( + 'action_id', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn resourceType = GeneratedColumn( + 'resource_type', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn resourceId = GeneratedColumn( + 'resource_id', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn contextJson = GeneratedColumn( + 'context_json', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT \'{}\'', + defaultValue: const CustomExpression('\'{}\''), + ); + late final GeneratedColumn decision = GeneratedColumn( + 'decision', + aliasedName, + false, + type: DriftSqlType.bool, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn reasonsJson = GeneratedColumn( + 'reasons_json', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT \'[]\'', + defaultValue: const CustomExpression('\'[]\''), + ); + late final GeneratedColumn errorsJson = GeneratedColumn( + 'errors_json', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT \'[]\'', + defaultValue: const CustomExpression('\'[]\''), + ); + @override + List get $columns => [ + rowid, + createTime, + expireTime, + principalType, + principalId, + actionType, + actionId, + resourceType, + resourceId, + contextJson, + decision, + reasonsJson, + errorsJson, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'cedar_authorization_logs'; + @override + Set get $primaryKey => {rowid}; + @override + CedarAuthorizationLogsData map( + Map data, { + String? tablePrefix, + }) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return CedarAuthorizationLogsData( + rowid: + attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}rowid'], + )!, + createTime: + attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}create_time'], + )!, + expireTime: attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}expire_time'], + ), + principalType: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}principal_type'], + ), + principalId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}principal_id'], + ), + actionType: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}action_type'], + ), + actionId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}action_id'], + ), + resourceType: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}resource_type'], + ), + resourceId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}resource_id'], + ), + contextJson: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}context_json'], + )!, + decision: + attachedDatabase.typeMapping.read( + DriftSqlType.bool, + data['${effectivePrefix}decision'], + )!, + reasonsJson: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}reasons_json'], + )!, + errorsJson: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}errors_json'], + )!, + ); + } + + @override + CedarAuthorizationLogs createAlias(String alias) { + return CedarAuthorizationLogs(attachedDatabase, alias); + } + + @override + bool get dontWriteConstraints => true; +} + +class CedarAuthorizationLogsData extends DataClass + implements Insertable { + final int rowid; + final DateTime createTime; + final DateTime? expireTime; + final String? principalType; + final String? principalId; + final String? actionType; + final String? actionId; + final String? resourceType; + final String? resourceId; + final String contextJson; + final bool decision; + final String reasonsJson; + final String errorsJson; + const CedarAuthorizationLogsData({ + required this.rowid, + required this.createTime, + this.expireTime, + this.principalType, + this.principalId, + this.actionType, + this.actionId, + this.resourceType, + this.resourceId, + required this.contextJson, + required this.decision, + required this.reasonsJson, + required this.errorsJson, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['rowid'] = Variable(rowid); + map['create_time'] = Variable(createTime); + if (!nullToAbsent || expireTime != null) { + map['expire_time'] = Variable(expireTime); + } + if (!nullToAbsent || principalType != null) { + map['principal_type'] = Variable(principalType); + } + if (!nullToAbsent || principalId != null) { + map['principal_id'] = Variable(principalId); + } + if (!nullToAbsent || actionType != null) { + map['action_type'] = Variable(actionType); + } + if (!nullToAbsent || actionId != null) { + map['action_id'] = Variable(actionId); + } + if (!nullToAbsent || resourceType != null) { + map['resource_type'] = Variable(resourceType); + } + if (!nullToAbsent || resourceId != null) { + map['resource_id'] = Variable(resourceId); + } + map['context_json'] = Variable(contextJson); + map['decision'] = Variable(decision); + map['reasons_json'] = Variable(reasonsJson); + map['errors_json'] = Variable(errorsJson); + return map; + } + + CedarAuthorizationLogsCompanion toCompanion(bool nullToAbsent) { + return CedarAuthorizationLogsCompanion( + rowid: Value(rowid), + createTime: Value(createTime), + expireTime: + expireTime == null && nullToAbsent + ? const Value.absent() + : Value(expireTime), + principalType: + principalType == null && nullToAbsent + ? const Value.absent() + : Value(principalType), + principalId: + principalId == null && nullToAbsent + ? const Value.absent() + : Value(principalId), + actionType: + actionType == null && nullToAbsent + ? const Value.absent() + : Value(actionType), + actionId: + actionId == null && nullToAbsent + ? const Value.absent() + : Value(actionId), + resourceType: + resourceType == null && nullToAbsent + ? const Value.absent() + : Value(resourceType), + resourceId: + resourceId == null && nullToAbsent + ? const Value.absent() + : Value(resourceId), + contextJson: Value(contextJson), + decision: Value(decision), + reasonsJson: Value(reasonsJson), + errorsJson: Value(errorsJson), + ); + } + + factory CedarAuthorizationLogsData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return CedarAuthorizationLogsData( + rowid: serializer.fromJson(json['rowid']), + createTime: serializer.fromJson(json['createTime']), + expireTime: serializer.fromJson(json['expireTime']), + principalType: serializer.fromJson(json['principalType']), + principalId: serializer.fromJson(json['principalId']), + actionType: serializer.fromJson(json['actionType']), + actionId: serializer.fromJson(json['actionId']), + resourceType: serializer.fromJson(json['resourceType']), + resourceId: serializer.fromJson(json['resourceId']), + contextJson: serializer.fromJson(json['contextJson']), + decision: serializer.fromJson(json['decision']), + reasonsJson: serializer.fromJson(json['reasonsJson']), + errorsJson: serializer.fromJson(json['errorsJson']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'rowid': serializer.toJson(rowid), + 'createTime': serializer.toJson(createTime), + 'expireTime': serializer.toJson(expireTime), + 'principalType': serializer.toJson(principalType), + 'principalId': serializer.toJson(principalId), + 'actionType': serializer.toJson(actionType), + 'actionId': serializer.toJson(actionId), + 'resourceType': serializer.toJson(resourceType), + 'resourceId': serializer.toJson(resourceId), + 'contextJson': serializer.toJson(contextJson), + 'decision': serializer.toJson(decision), + 'reasonsJson': serializer.toJson(reasonsJson), + 'errorsJson': serializer.toJson(errorsJson), + }; + } + + CedarAuthorizationLogsData copyWith({ + int? rowid, + DateTime? createTime, + Value expireTime = const Value.absent(), + Value principalType = const Value.absent(), + Value principalId = const Value.absent(), + Value actionType = const Value.absent(), + Value actionId = const Value.absent(), + Value resourceType = const Value.absent(), + Value resourceId = const Value.absent(), + String? contextJson, + bool? decision, + String? reasonsJson, + String? errorsJson, + }) => CedarAuthorizationLogsData( + rowid: rowid ?? this.rowid, + createTime: createTime ?? this.createTime, + expireTime: expireTime.present ? expireTime.value : this.expireTime, + principalType: + principalType.present ? principalType.value : this.principalType, + principalId: principalId.present ? principalId.value : this.principalId, + actionType: actionType.present ? actionType.value : this.actionType, + actionId: actionId.present ? actionId.value : this.actionId, + resourceType: resourceType.present ? resourceType.value : this.resourceType, + resourceId: resourceId.present ? resourceId.value : this.resourceId, + contextJson: contextJson ?? this.contextJson, + decision: decision ?? this.decision, + reasonsJson: reasonsJson ?? this.reasonsJson, + errorsJson: errorsJson ?? this.errorsJson, + ); + CedarAuthorizationLogsData copyWithCompanion( + CedarAuthorizationLogsCompanion data, + ) { + return CedarAuthorizationLogsData( + rowid: data.rowid.present ? data.rowid.value : this.rowid, + createTime: + data.createTime.present ? data.createTime.value : this.createTime, + expireTime: + data.expireTime.present ? data.expireTime.value : this.expireTime, + principalType: + data.principalType.present + ? data.principalType.value + : this.principalType, + principalId: + data.principalId.present ? data.principalId.value : this.principalId, + actionType: + data.actionType.present ? data.actionType.value : this.actionType, + actionId: data.actionId.present ? data.actionId.value : this.actionId, + resourceType: + data.resourceType.present + ? data.resourceType.value + : this.resourceType, + resourceId: + data.resourceId.present ? data.resourceId.value : this.resourceId, + contextJson: + data.contextJson.present ? data.contextJson.value : this.contextJson, + decision: data.decision.present ? data.decision.value : this.decision, + reasonsJson: + data.reasonsJson.present ? data.reasonsJson.value : this.reasonsJson, + errorsJson: + data.errorsJson.present ? data.errorsJson.value : this.errorsJson, + ); + } + + @override + String toString() { + return (StringBuffer('CedarAuthorizationLogsData(') + ..write('rowid: $rowid, ') + ..write('createTime: $createTime, ') + ..write('expireTime: $expireTime, ') + ..write('principalType: $principalType, ') + ..write('principalId: $principalId, ') + ..write('actionType: $actionType, ') + ..write('actionId: $actionId, ') + ..write('resourceType: $resourceType, ') + ..write('resourceId: $resourceId, ') + ..write('contextJson: $contextJson, ') + ..write('decision: $decision, ') + ..write('reasonsJson: $reasonsJson, ') + ..write('errorsJson: $errorsJson') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + rowid, + createTime, + expireTime, + principalType, + principalId, + actionType, + actionId, + resourceType, + resourceId, + contextJson, + decision, + reasonsJson, + errorsJson, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is CedarAuthorizationLogsData && + other.rowid == this.rowid && + other.createTime == this.createTime && + other.expireTime == this.expireTime && + other.principalType == this.principalType && + other.principalId == this.principalId && + other.actionType == this.actionType && + other.actionId == this.actionId && + other.resourceType == this.resourceType && + other.resourceId == this.resourceId && + other.contextJson == this.contextJson && + other.decision == this.decision && + other.reasonsJson == this.reasonsJson && + other.errorsJson == this.errorsJson); +} + +class CedarAuthorizationLogsCompanion + extends UpdateCompanion { + final Value rowid; + final Value createTime; + final Value expireTime; + final Value principalType; + final Value principalId; + final Value actionType; + final Value actionId; + final Value resourceType; + final Value resourceId; + final Value contextJson; + final Value decision; + final Value reasonsJson; + final Value errorsJson; + const CedarAuthorizationLogsCompanion({ + this.rowid = const Value.absent(), + this.createTime = const Value.absent(), + this.expireTime = const Value.absent(), + this.principalType = const Value.absent(), + this.principalId = const Value.absent(), + this.actionType = const Value.absent(), + this.actionId = const Value.absent(), + this.resourceType = const Value.absent(), + this.resourceId = const Value.absent(), + this.contextJson = const Value.absent(), + this.decision = const Value.absent(), + this.reasonsJson = const Value.absent(), + this.errorsJson = const Value.absent(), + }); + CedarAuthorizationLogsCompanion.insert({ + this.rowid = const Value.absent(), + this.createTime = const Value.absent(), + this.expireTime = const Value.absent(), + this.principalType = const Value.absent(), + this.principalId = const Value.absent(), + this.actionType = const Value.absent(), + this.actionId = const Value.absent(), + this.resourceType = const Value.absent(), + this.resourceId = const Value.absent(), + this.contextJson = const Value.absent(), + required bool decision, + this.reasonsJson = const Value.absent(), + this.errorsJson = const Value.absent(), + }) : decision = Value(decision); + static Insertable custom({ + Expression? rowid, + Expression? createTime, + Expression? expireTime, + Expression? principalType, + Expression? principalId, + Expression? actionType, + Expression? actionId, + Expression? resourceType, + Expression? resourceId, + Expression? contextJson, + Expression? decision, + Expression? reasonsJson, + Expression? errorsJson, + }) { + return RawValuesInsertable({ + if (rowid != null) 'rowid': rowid, + if (createTime != null) 'create_time': createTime, + if (expireTime != null) 'expire_time': expireTime, + if (principalType != null) 'principal_type': principalType, + if (principalId != null) 'principal_id': principalId, + if (actionType != null) 'action_type': actionType, + if (actionId != null) 'action_id': actionId, + if (resourceType != null) 'resource_type': resourceType, + if (resourceId != null) 'resource_id': resourceId, + if (contextJson != null) 'context_json': contextJson, + if (decision != null) 'decision': decision, + if (reasonsJson != null) 'reasons_json': reasonsJson, + if (errorsJson != null) 'errors_json': errorsJson, + }); + } + + CedarAuthorizationLogsCompanion copyWith({ + Value? rowid, + Value? createTime, + Value? expireTime, + Value? principalType, + Value? principalId, + Value? actionType, + Value? actionId, + Value? resourceType, + Value? resourceId, + Value? contextJson, + Value? decision, + Value? reasonsJson, + Value? errorsJson, + }) { + return CedarAuthorizationLogsCompanion( + rowid: rowid ?? this.rowid, + createTime: createTime ?? this.createTime, + expireTime: expireTime ?? this.expireTime, + principalType: principalType ?? this.principalType, + principalId: principalId ?? this.principalId, + actionType: actionType ?? this.actionType, + actionId: actionId ?? this.actionId, + resourceType: resourceType ?? this.resourceType, + resourceId: resourceId ?? this.resourceId, + contextJson: contextJson ?? this.contextJson, + decision: decision ?? this.decision, + reasonsJson: reasonsJson ?? this.reasonsJson, + errorsJson: errorsJson ?? this.errorsJson, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + if (createTime.present) { + map['create_time'] = Variable(createTime.value); + } + if (expireTime.present) { + map['expire_time'] = Variable(expireTime.value); + } + if (principalType.present) { + map['principal_type'] = Variable(principalType.value); + } + if (principalId.present) { + map['principal_id'] = Variable(principalId.value); + } + if (actionType.present) { + map['action_type'] = Variable(actionType.value); + } + if (actionId.present) { + map['action_id'] = Variable(actionId.value); + } + if (resourceType.present) { + map['resource_type'] = Variable(resourceType.value); + } + if (resourceId.present) { + map['resource_id'] = Variable(resourceId.value); + } + if (contextJson.present) { + map['context_json'] = Variable(contextJson.value); + } + if (decision.present) { + map['decision'] = Variable(decision.value); + } + if (reasonsJson.present) { + map['reasons_json'] = Variable(reasonsJson.value); + } + if (errorsJson.present) { + map['errors_json'] = Variable(errorsJson.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('CedarAuthorizationLogsCompanion(') + ..write('rowid: $rowid, ') + ..write('createTime: $createTime, ') + ..write('expireTime: $expireTime, ') + ..write('principalType: $principalType, ') + ..write('principalId: $principalId, ') + ..write('actionType: $actionType, ') + ..write('actionId: $actionId, ') + ..write('resourceType: $resourceType, ') + ..write('resourceId: $resourceId, ') + ..write('contextJson: $contextJson, ') + ..write('decision: $decision, ') + ..write('reasonsJson: $reasonsJson, ') + ..write('errorsJson: $errorsJson') + ..write(')')) + .toString(); + } +} + +class UserMemberships extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + UserMemberships(this.attachedDatabase, [this._alias]); + late final GeneratedColumn membershipId = GeneratedColumn( + 'membership_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); + late final GeneratedColumn userId = GeneratedColumn( + 'user_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn parentType = GeneratedColumn( + 'parent_type', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn parentId = GeneratedColumn( + 'parent_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn role = GeneratedColumn( + 'role', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn createTime = GeneratedColumn( + 'create_time', + aliasedName, + false, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT (unixepoch(\'now\', \'subsec\'))', + defaultValue: const CustomExpression('unixepoch(\'now\', \'subsec\')'), + ); + late final GeneratedColumn updateTime = GeneratedColumn( + 'update_time', + aliasedName, + false, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT (unixepoch(\'now\', \'subsec\'))', + defaultValue: const CustomExpression('unixepoch(\'now\', \'subsec\')'), + ); + @override + List get $columns => [ + membershipId, + userId, + parentType, + parentId, + role, + createTime, + updateTime, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'user_memberships'; + @override + Set get $primaryKey => {membershipId}; + @override + UserMembershipsData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return UserMembershipsData( + membershipId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}membership_id'], + )!, + userId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}user_id'], + )!, + parentType: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}parent_type'], + )!, + parentId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}parent_id'], + )!, + role: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}role'], + )!, + createTime: + attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}create_time'], + )!, + updateTime: + attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}update_time'], + )!, + ); + } + + @override + UserMemberships createAlias(String alias) { + return UserMemberships(attachedDatabase, alias); + } + + @override + List get customConstraints => const [ + 'CHECK(parent_type = \'Celest::Organization\' OR parent_type = \'Celest::Project\' OR parent_type = \'Celest::Project::Environment\')', + 'CONSTRAINT user_memberships_parent_fk FOREIGN KEY(parent_type, parent_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED', + ]; + @override + bool get dontWriteConstraints => true; +} + +class UserMembershipsData extends DataClass + implements Insertable { + final String membershipId; + final String userId; + final String parentType; + final String parentId; + final String role; + final DateTime createTime; + final DateTime updateTime; + const UserMembershipsData({ + required this.membershipId, + required this.userId, + required this.parentType, + required this.parentId, + required this.role, + required this.createTime, + required this.updateTime, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['membership_id'] = Variable(membershipId); + map['user_id'] = Variable(userId); + map['parent_type'] = Variable(parentType); + map['parent_id'] = Variable(parentId); + map['role'] = Variable(role); + map['create_time'] = Variable(createTime); + map['update_time'] = Variable(updateTime); + return map; + } + + UserMembershipsCompanion toCompanion(bool nullToAbsent) { + return UserMembershipsCompanion( + membershipId: Value(membershipId), + userId: Value(userId), + parentType: Value(parentType), + parentId: Value(parentId), + role: Value(role), + createTime: Value(createTime), + updateTime: Value(updateTime), + ); + } + + factory UserMembershipsData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return UserMembershipsData( + membershipId: serializer.fromJson(json['membershipId']), + userId: serializer.fromJson(json['userId']), + parentType: serializer.fromJson(json['parentType']), + parentId: serializer.fromJson(json['parentId']), + role: serializer.fromJson(json['role']), + createTime: serializer.fromJson(json['createTime']), + updateTime: serializer.fromJson(json['updateTime']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'membershipId': serializer.toJson(membershipId), + 'userId': serializer.toJson(userId), + 'parentType': serializer.toJson(parentType), + 'parentId': serializer.toJson(parentId), + 'role': serializer.toJson(role), + 'createTime': serializer.toJson(createTime), + 'updateTime': serializer.toJson(updateTime), + }; + } + + UserMembershipsData copyWith({ + String? membershipId, + String? userId, + String? parentType, + String? parentId, + String? role, + DateTime? createTime, + DateTime? updateTime, + }) => UserMembershipsData( + membershipId: membershipId ?? this.membershipId, + userId: userId ?? this.userId, + parentType: parentType ?? this.parentType, + parentId: parentId ?? this.parentId, + role: role ?? this.role, + createTime: createTime ?? this.createTime, + updateTime: updateTime ?? this.updateTime, + ); + UserMembershipsData copyWithCompanion(UserMembershipsCompanion data) { + return UserMembershipsData( + membershipId: + data.membershipId.present + ? data.membershipId.value + : this.membershipId, + userId: data.userId.present ? data.userId.value : this.userId, + parentType: + data.parentType.present ? data.parentType.value : this.parentType, + parentId: data.parentId.present ? data.parentId.value : this.parentId, + role: data.role.present ? data.role.value : this.role, + createTime: + data.createTime.present ? data.createTime.value : this.createTime, + updateTime: + data.updateTime.present ? data.updateTime.value : this.updateTime, + ); + } + + @override + String toString() { + return (StringBuffer('UserMembershipsData(') + ..write('membershipId: $membershipId, ') + ..write('userId: $userId, ') + ..write('parentType: $parentType, ') + ..write('parentId: $parentId, ') + ..write('role: $role, ') + ..write('createTime: $createTime, ') + ..write('updateTime: $updateTime') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + membershipId, + userId, + parentType, + parentId, + role, + createTime, + updateTime, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is UserMembershipsData && + other.membershipId == this.membershipId && + other.userId == this.userId && + other.parentType == this.parentType && + other.parentId == this.parentId && + other.role == this.role && + other.createTime == this.createTime && + other.updateTime == this.updateTime); +} + +class UserMembershipsCompanion extends UpdateCompanion { + final Value membershipId; + final Value userId; + final Value parentType; + final Value parentId; + final Value role; + final Value createTime; + final Value updateTime; + final Value rowid; + const UserMembershipsCompanion({ + this.membershipId = const Value.absent(), + this.userId = const Value.absent(), + this.parentType = const Value.absent(), + this.parentId = const Value.absent(), + this.role = const Value.absent(), + this.createTime = const Value.absent(), + this.updateTime = const Value.absent(), + this.rowid = const Value.absent(), + }); + UserMembershipsCompanion.insert({ + required String membershipId, + required String userId, + required String parentType, + required String parentId, + required String role, + this.createTime = const Value.absent(), + this.updateTime = const Value.absent(), + this.rowid = const Value.absent(), + }) : membershipId = Value(membershipId), + userId = Value(userId), + parentType = Value(parentType), + parentId = Value(parentId), + role = Value(role); + static Insertable custom({ + Expression? membershipId, + Expression? userId, + Expression? parentType, + Expression? parentId, + Expression? role, + Expression? createTime, + Expression? updateTime, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (membershipId != null) 'membership_id': membershipId, + if (userId != null) 'user_id': userId, + if (parentType != null) 'parent_type': parentType, + if (parentId != null) 'parent_id': parentId, + if (role != null) 'role': role, + if (createTime != null) 'create_time': createTime, + if (updateTime != null) 'update_time': updateTime, + if (rowid != null) 'rowid': rowid, + }); + } + + UserMembershipsCompanion copyWith({ + Value? membershipId, + Value? userId, + Value? parentType, + Value? parentId, + Value? role, + Value? createTime, + Value? updateTime, + Value? rowid, + }) { + return UserMembershipsCompanion( + membershipId: membershipId ?? this.membershipId, + userId: userId ?? this.userId, + parentType: parentType ?? this.parentType, + parentId: parentId ?? this.parentId, + role: role ?? this.role, + createTime: createTime ?? this.createTime, + updateTime: updateTime ?? this.updateTime, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (membershipId.present) { + map['membership_id'] = Variable(membershipId.value); + } + if (userId.present) { + map['user_id'] = Variable(userId.value); + } + if (parentType.present) { + map['parent_type'] = Variable(parentType.value); + } + if (parentId.present) { + map['parent_id'] = Variable(parentId.value); + } + if (role.present) { + map['role'] = Variable(role.value); + } + if (createTime.present) { + map['create_time'] = Variable(createTime.value); + } + if (updateTime.present) { + map['update_time'] = Variable(updateTime.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('UserMembershipsCompanion(') + ..write('membershipId: $membershipId, ') + ..write('userId: $userId, ') + ..write('parentType: $parentType, ') + ..write('parentId: $parentId, ') + ..write('role: $role, ') + ..write('createTime: $createTime, ') + ..write('updateTime: $updateTime, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +class Organizations extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + Organizations(this.attachedDatabase, [this._alias]); + late final GeneratedColumn id = GeneratedColumn( + 'id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); + late final GeneratedColumn parentType = GeneratedColumn( + 'parent_type', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn parentId = GeneratedColumn( + 'parent_id', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn organizationId = GeneratedColumn( + 'organization_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL UNIQUE', + ); + late final GeneratedColumn state = GeneratedColumn( + 'state', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT \'CREATING\'', + defaultValue: const CustomExpression('\'CREATING\''), + ); + late final GeneratedColumn displayName = GeneratedColumn( + 'display_name', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn createTime = GeneratedColumn( + 'create_time', + aliasedName, + false, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT (unixepoch(\'now\', \'subsec\'))', + defaultValue: const CustomExpression('unixepoch(\'now\', \'subsec\')'), + ); + late final GeneratedColumn updateTime = GeneratedColumn( + 'update_time', + aliasedName, + false, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT (unixepoch(\'now\', \'subsec\'))', + defaultValue: const CustomExpression('unixepoch(\'now\', \'subsec\')'), + ); + late final GeneratedColumn deleteTime = GeneratedColumn( + 'delete_time', + aliasedName, + true, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn purgeTime = GeneratedColumn( + 'purge_time', + aliasedName, + true, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn annotations = GeneratedColumn( + 'annotations', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn primaryRegion = GeneratedColumn( + 'primary_region', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn reconciling = GeneratedColumn( + 'reconciling', + aliasedName, + false, + type: DriftSqlType.bool, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT FALSE', + defaultValue: const CustomExpression('FALSE'), + ); + late final GeneratedColumn etag = GeneratedColumn( + 'etag', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: + 'NOT NULL GENERATED ALWAYS AS (hex(md5(json_array(id, parent_type, parent_id, organization_id, state, display_name, create_time, update_time, delete_time, purge_time, annotations, primary_region, reconciling)))) STORED', + ); + @override + List get $columns => [ + id, + parentType, + parentId, + organizationId, + state, + displayName, + createTime, + updateTime, + deleteTime, + purgeTime, + annotations, + primaryRegion, + reconciling, + etag, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'organizations'; + @override + Set get $primaryKey => {id}; + @override + OrganizationsData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return OrganizationsData( + id: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}id'], + )!, + parentType: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}parent_type'], + ), + parentId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}parent_id'], + ), + organizationId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}organization_id'], + )!, + state: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}state'], + )!, + displayName: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}display_name'], + )!, + createTime: + attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}create_time'], + )!, + updateTime: + attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}update_time'], + )!, + deleteTime: attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}delete_time'], + ), + purgeTime: attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}purge_time'], + ), + annotations: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}annotations'], + ), + primaryRegion: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}primary_region'], + ), + reconciling: + attachedDatabase.typeMapping.read( + DriftSqlType.bool, + data['${effectivePrefix}reconciling'], + )!, + etag: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}etag'], + )!, + ); + } + + @override + Organizations createAlias(String alias) { + return Organizations(attachedDatabase, alias); + } + + @override + List get customConstraints => const [ + 'CONSTRAINT organizations_parent_fk FOREIGN KEY(parent_type, parent_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE SET NULL', + ]; + @override + bool get dontWriteConstraints => true; +} + +class OrganizationsData extends DataClass + implements Insertable { + final String id; + final String? parentType; + final String? parentId; + final String organizationId; + final String state; + final String displayName; + final DateTime createTime; + final DateTime updateTime; + final DateTime? deleteTime; + final DateTime? purgeTime; + final String? annotations; + final String? primaryRegion; + final bool reconciling; + final String etag; + const OrganizationsData({ + required this.id, + this.parentType, + this.parentId, + required this.organizationId, + required this.state, + required this.displayName, + required this.createTime, + required this.updateTime, + this.deleteTime, + this.purgeTime, + this.annotations, + this.primaryRegion, + required this.reconciling, + required this.etag, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + if (!nullToAbsent || parentType != null) { + map['parent_type'] = Variable(parentType); + } + if (!nullToAbsent || parentId != null) { + map['parent_id'] = Variable(parentId); + } + map['organization_id'] = Variable(organizationId); + map['state'] = Variable(state); + map['display_name'] = Variable(displayName); + map['create_time'] = Variable(createTime); + map['update_time'] = Variable(updateTime); + if (!nullToAbsent || deleteTime != null) { + map['delete_time'] = Variable(deleteTime); + } + if (!nullToAbsent || purgeTime != null) { + map['purge_time'] = Variable(purgeTime); + } + if (!nullToAbsent || annotations != null) { + map['annotations'] = Variable(annotations); + } + if (!nullToAbsent || primaryRegion != null) { + map['primary_region'] = Variable(primaryRegion); + } + map['reconciling'] = Variable(reconciling); + map['etag'] = Variable(etag); + return map; + } + + OrganizationsCompanion toCompanion(bool nullToAbsent) { + return OrganizationsCompanion( + id: Value(id), + parentType: + parentType == null && nullToAbsent + ? const Value.absent() + : Value(parentType), + parentId: + parentId == null && nullToAbsent + ? const Value.absent() + : Value(parentId), + organizationId: Value(organizationId), + state: Value(state), + displayName: Value(displayName), + createTime: Value(createTime), + updateTime: Value(updateTime), + deleteTime: + deleteTime == null && nullToAbsent + ? const Value.absent() + : Value(deleteTime), + purgeTime: + purgeTime == null && nullToAbsent + ? const Value.absent() + : Value(purgeTime), + annotations: + annotations == null && nullToAbsent + ? const Value.absent() + : Value(annotations), + primaryRegion: + primaryRegion == null && nullToAbsent + ? const Value.absent() + : Value(primaryRegion), + reconciling: Value(reconciling), + etag: Value(etag), + ); + } + + factory OrganizationsData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return OrganizationsData( + id: serializer.fromJson(json['id']), + parentType: serializer.fromJson(json['parentType']), + parentId: serializer.fromJson(json['parentId']), + organizationId: serializer.fromJson(json['organizationId']), + state: serializer.fromJson(json['state']), + displayName: serializer.fromJson(json['displayName']), + createTime: serializer.fromJson(json['createTime']), + updateTime: serializer.fromJson(json['updateTime']), + deleteTime: serializer.fromJson(json['deleteTime']), + purgeTime: serializer.fromJson(json['purgeTime']), + annotations: serializer.fromJson(json['annotations']), + primaryRegion: serializer.fromJson(json['primaryRegion']), + reconciling: serializer.fromJson(json['reconciling']), + etag: serializer.fromJson(json['etag']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'parentType': serializer.toJson(parentType), + 'parentId': serializer.toJson(parentId), + 'organizationId': serializer.toJson(organizationId), + 'state': serializer.toJson(state), + 'displayName': serializer.toJson(displayName), + 'createTime': serializer.toJson(createTime), + 'updateTime': serializer.toJson(updateTime), + 'deleteTime': serializer.toJson(deleteTime), + 'purgeTime': serializer.toJson(purgeTime), + 'annotations': serializer.toJson(annotations), + 'primaryRegion': serializer.toJson(primaryRegion), + 'reconciling': serializer.toJson(reconciling), + 'etag': serializer.toJson(etag), + }; + } + + OrganizationsData copyWith({ + String? id, + Value parentType = const Value.absent(), + Value parentId = const Value.absent(), + String? organizationId, + String? state, + String? displayName, + DateTime? createTime, + DateTime? updateTime, + Value deleteTime = const Value.absent(), + Value purgeTime = const Value.absent(), + Value annotations = const Value.absent(), + Value primaryRegion = const Value.absent(), + bool? reconciling, + String? etag, + }) => OrganizationsData( + id: id ?? this.id, + parentType: parentType.present ? parentType.value : this.parentType, + parentId: parentId.present ? parentId.value : this.parentId, + organizationId: organizationId ?? this.organizationId, + state: state ?? this.state, + displayName: displayName ?? this.displayName, + createTime: createTime ?? this.createTime, + updateTime: updateTime ?? this.updateTime, + deleteTime: deleteTime.present ? deleteTime.value : this.deleteTime, + purgeTime: purgeTime.present ? purgeTime.value : this.purgeTime, + annotations: annotations.present ? annotations.value : this.annotations, + primaryRegion: + primaryRegion.present ? primaryRegion.value : this.primaryRegion, + reconciling: reconciling ?? this.reconciling, + etag: etag ?? this.etag, + ); + OrganizationsData copyWithCompanion(OrganizationsCompanion data) { + return OrganizationsData( + id: data.id.present ? data.id.value : this.id, + parentType: + data.parentType.present ? data.parentType.value : this.parentType, + parentId: data.parentId.present ? data.parentId.value : this.parentId, + organizationId: + data.organizationId.present + ? data.organizationId.value + : this.organizationId, + state: data.state.present ? data.state.value : this.state, + displayName: + data.displayName.present ? data.displayName.value : this.displayName, + createTime: + data.createTime.present ? data.createTime.value : this.createTime, + updateTime: + data.updateTime.present ? data.updateTime.value : this.updateTime, + deleteTime: + data.deleteTime.present ? data.deleteTime.value : this.deleteTime, + purgeTime: data.purgeTime.present ? data.purgeTime.value : this.purgeTime, + annotations: + data.annotations.present ? data.annotations.value : this.annotations, + primaryRegion: + data.primaryRegion.present + ? data.primaryRegion.value + : this.primaryRegion, + reconciling: + data.reconciling.present ? data.reconciling.value : this.reconciling, + etag: data.etag.present ? data.etag.value : this.etag, + ); + } + + @override + String toString() { + return (StringBuffer('OrganizationsData(') + ..write('id: $id, ') + ..write('parentType: $parentType, ') + ..write('parentId: $parentId, ') + ..write('organizationId: $organizationId, ') + ..write('state: $state, ') + ..write('displayName: $displayName, ') + ..write('createTime: $createTime, ') + ..write('updateTime: $updateTime, ') + ..write('deleteTime: $deleteTime, ') + ..write('purgeTime: $purgeTime, ') + ..write('annotations: $annotations, ') + ..write('primaryRegion: $primaryRegion, ') + ..write('reconciling: $reconciling, ') + ..write('etag: $etag') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + id, + parentType, + parentId, + organizationId, + state, + displayName, + createTime, + updateTime, + deleteTime, + purgeTime, + annotations, + primaryRegion, + reconciling, + etag, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is OrganizationsData && + other.id == this.id && + other.parentType == this.parentType && + other.parentId == this.parentId && + other.organizationId == this.organizationId && + other.state == this.state && + other.displayName == this.displayName && + other.createTime == this.createTime && + other.updateTime == this.updateTime && + other.deleteTime == this.deleteTime && + other.purgeTime == this.purgeTime && + other.annotations == this.annotations && + other.primaryRegion == this.primaryRegion && + other.reconciling == this.reconciling && + other.etag == this.etag); +} + +class OrganizationsCompanion extends UpdateCompanion { + final Value id; + final Value parentType; + final Value parentId; + final Value organizationId; + final Value state; + final Value displayName; + final Value createTime; + final Value updateTime; + final Value deleteTime; + final Value purgeTime; + final Value annotations; + final Value primaryRegion; + final Value reconciling; + final Value etag; + final Value rowid; + const OrganizationsCompanion({ + this.id = const Value.absent(), + this.parentType = const Value.absent(), + this.parentId = const Value.absent(), + this.organizationId = const Value.absent(), + this.state = const Value.absent(), + this.displayName = const Value.absent(), + this.createTime = const Value.absent(), + this.updateTime = const Value.absent(), + this.deleteTime = const Value.absent(), + this.purgeTime = const Value.absent(), + this.annotations = const Value.absent(), + this.primaryRegion = const Value.absent(), + this.reconciling = const Value.absent(), + this.etag = const Value.absent(), + this.rowid = const Value.absent(), + }); + OrganizationsCompanion.insert({ + required String id, + this.parentType = const Value.absent(), + this.parentId = const Value.absent(), + required String organizationId, + this.state = const Value.absent(), + required String displayName, + this.createTime = const Value.absent(), + this.updateTime = const Value.absent(), + this.deleteTime = const Value.absent(), + this.purgeTime = const Value.absent(), + this.annotations = const Value.absent(), + this.primaryRegion = const Value.absent(), + this.reconciling = const Value.absent(), + required String etag, + this.rowid = const Value.absent(), + }) : id = Value(id), + organizationId = Value(organizationId), + displayName = Value(displayName), + etag = Value(etag); + static Insertable custom({ + Expression? id, + Expression? parentType, + Expression? parentId, + Expression? organizationId, + Expression? state, + Expression? displayName, + Expression? createTime, + Expression? updateTime, + Expression? deleteTime, + Expression? purgeTime, + Expression? annotations, + Expression? primaryRegion, + Expression? reconciling, + Expression? etag, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (parentType != null) 'parent_type': parentType, + if (parentId != null) 'parent_id': parentId, + if (organizationId != null) 'organization_id': organizationId, + if (state != null) 'state': state, + if (displayName != null) 'display_name': displayName, + if (createTime != null) 'create_time': createTime, + if (updateTime != null) 'update_time': updateTime, + if (deleteTime != null) 'delete_time': deleteTime, + if (purgeTime != null) 'purge_time': purgeTime, + if (annotations != null) 'annotations': annotations, + if (primaryRegion != null) 'primary_region': primaryRegion, + if (reconciling != null) 'reconciling': reconciling, + if (etag != null) 'etag': etag, + if (rowid != null) 'rowid': rowid, + }); + } + + OrganizationsCompanion copyWith({ + Value? id, + Value? parentType, + Value? parentId, + Value? organizationId, + Value? state, + Value? displayName, + Value? createTime, + Value? updateTime, + Value? deleteTime, + Value? purgeTime, + Value? annotations, + Value? primaryRegion, + Value? reconciling, + Value? etag, + Value? rowid, + }) { + return OrganizationsCompanion( + id: id ?? this.id, + parentType: parentType ?? this.parentType, + parentId: parentId ?? this.parentId, + organizationId: organizationId ?? this.organizationId, + state: state ?? this.state, + displayName: displayName ?? this.displayName, + createTime: createTime ?? this.createTime, + updateTime: updateTime ?? this.updateTime, + deleteTime: deleteTime ?? this.deleteTime, + purgeTime: purgeTime ?? this.purgeTime, + annotations: annotations ?? this.annotations, + primaryRegion: primaryRegion ?? this.primaryRegion, + reconciling: reconciling ?? this.reconciling, + etag: etag ?? this.etag, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (parentType.present) { + map['parent_type'] = Variable(parentType.value); + } + if (parentId.present) { + map['parent_id'] = Variable(parentId.value); + } + if (organizationId.present) { + map['organization_id'] = Variable(organizationId.value); + } + if (state.present) { + map['state'] = Variable(state.value); + } + if (displayName.present) { + map['display_name'] = Variable(displayName.value); + } + if (createTime.present) { + map['create_time'] = Variable(createTime.value); + } + if (updateTime.present) { + map['update_time'] = Variable(updateTime.value); + } + if (deleteTime.present) { + map['delete_time'] = Variable(deleteTime.value); + } + if (purgeTime.present) { + map['purge_time'] = Variable(purgeTime.value); + } + if (annotations.present) { + map['annotations'] = Variable(annotations.value); + } + if (primaryRegion.present) { + map['primary_region'] = Variable(primaryRegion.value); + } + if (reconciling.present) { + map['reconciling'] = Variable(reconciling.value); + } + if (etag.present) { + map['etag'] = Variable(etag.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('OrganizationsCompanion(') + ..write('id: $id, ') + ..write('parentType: $parentType, ') + ..write('parentId: $parentId, ') + ..write('organizationId: $organizationId, ') + ..write('state: $state, ') + ..write('displayName: $displayName, ') + ..write('createTime: $createTime, ') + ..write('updateTime: $updateTime, ') + ..write('deleteTime: $deleteTime, ') + ..write('purgeTime: $purgeTime, ') + ..write('annotations: $annotations, ') + ..write('primaryRegion: $primaryRegion, ') + ..write('reconciling: $reconciling, ') + ..write('etag: $etag, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +class Projects extends Table with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + Projects(this.attachedDatabase, [this._alias]); + late final GeneratedColumn id = GeneratedColumn( + 'id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); + late final GeneratedColumn parentType = GeneratedColumn( + 'parent_type', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn parentId = GeneratedColumn( + 'parent_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn projectId = GeneratedColumn( + 'project_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn state = GeneratedColumn( + 'state', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT \'CREATING\'', + defaultValue: const CustomExpression('\'CREATING\''), + ); + late final GeneratedColumn displayName = GeneratedColumn( + 'display_name', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn createTime = GeneratedColumn( + 'create_time', + aliasedName, + false, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT (unixepoch(\'now\', \'subsec\'))', + defaultValue: const CustomExpression('unixepoch(\'now\', \'subsec\')'), + ); + late final GeneratedColumn updateTime = GeneratedColumn( + 'update_time', + aliasedName, + false, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT (unixepoch(\'now\', \'subsec\'))', + defaultValue: const CustomExpression('unixepoch(\'now\', \'subsec\')'), + ); + late final GeneratedColumn deleteTime = GeneratedColumn( + 'delete_time', + aliasedName, + true, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn purgeTime = GeneratedColumn( + 'purge_time', + aliasedName, + true, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn annotations = GeneratedColumn( + 'annotations', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn regions = GeneratedColumn( + 'regions', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn reconciling = GeneratedColumn( + 'reconciling', + aliasedName, + false, + type: DriftSqlType.bool, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT FALSE', + defaultValue: const CustomExpression('FALSE'), + ); + late final GeneratedColumn etag = GeneratedColumn( + 'etag', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: + 'NOT NULL GENERATED ALWAYS AS (hex(md5(json_array(id, parent_type, parent_id, project_id, state, display_name, create_time, update_time, delete_time, purge_time, annotations, regions, reconciling)))) STORED', + ); + @override + List get $columns => [ + id, + parentType, + parentId, + projectId, + state, + displayName, + createTime, + updateTime, + deleteTime, + purgeTime, + annotations, + regions, + reconciling, + etag, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'projects'; + @override + Set get $primaryKey => {id}; + @override + List> get uniqueKeys => [ + {projectId, parentId}, + ]; + @override + ProjectsData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return ProjectsData( + id: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}id'], + )!, + parentType: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}parent_type'], + )!, + parentId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}parent_id'], + )!, + projectId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}project_id'], + )!, + state: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}state'], + )!, + displayName: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}display_name'], + ), + createTime: + attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}create_time'], + )!, + updateTime: + attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}update_time'], + )!, + deleteTime: attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}delete_time'], + ), + purgeTime: attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}purge_time'], + ), + annotations: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}annotations'], + ), + regions: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}regions'], + )!, + reconciling: + attachedDatabase.typeMapping.read( + DriftSqlType.bool, + data['${effectivePrefix}reconciling'], + )!, + etag: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}etag'], + )!, + ); + } + + @override + Projects createAlias(String alias) { + return Projects(attachedDatabase, alias); + } + + @override + List get customConstraints => const [ + 'CHECK(parent_type = \'Celest::Organization\')', + 'CONSTRAINT projects_fk_parent FOREIGN KEY(parent_type, parent_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE CASCADE', + 'CONSTRAINT projects_fk_organization FOREIGN KEY(parent_id)REFERENCES organizations(id)ON UPDATE CASCADE ON DELETE CASCADE', + 'CONSTRAINT projects_uq_project_id UNIQUE(project_id, parent_id)', + ]; + @override + bool get dontWriteConstraints => true; +} + +class ProjectsData extends DataClass implements Insertable { + final String id; + final String parentType; + final String parentId; + final String projectId; + final String state; + final String? displayName; + final DateTime createTime; + final DateTime updateTime; + final DateTime? deleteTime; + final DateTime? purgeTime; + final String? annotations; + final String regions; + final bool reconciling; + final String etag; + const ProjectsData({ + required this.id, + required this.parentType, + required this.parentId, + required this.projectId, + required this.state, + this.displayName, + required this.createTime, + required this.updateTime, + this.deleteTime, + this.purgeTime, + this.annotations, + required this.regions, + required this.reconciling, + required this.etag, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['parent_type'] = Variable(parentType); + map['parent_id'] = Variable(parentId); + map['project_id'] = Variable(projectId); + map['state'] = Variable(state); + if (!nullToAbsent || displayName != null) { + map['display_name'] = Variable(displayName); + } + map['create_time'] = Variable(createTime); + map['update_time'] = Variable(updateTime); + if (!nullToAbsent || deleteTime != null) { + map['delete_time'] = Variable(deleteTime); + } + if (!nullToAbsent || purgeTime != null) { + map['purge_time'] = Variable(purgeTime); + } + if (!nullToAbsent || annotations != null) { + map['annotations'] = Variable(annotations); + } + map['regions'] = Variable(regions); + map['reconciling'] = Variable(reconciling); + map['etag'] = Variable(etag); + return map; + } + + ProjectsCompanion toCompanion(bool nullToAbsent) { + return ProjectsCompanion( + id: Value(id), + parentType: Value(parentType), + parentId: Value(parentId), + projectId: Value(projectId), + state: Value(state), + displayName: + displayName == null && nullToAbsent + ? const Value.absent() + : Value(displayName), + createTime: Value(createTime), + updateTime: Value(updateTime), + deleteTime: + deleteTime == null && nullToAbsent + ? const Value.absent() + : Value(deleteTime), + purgeTime: + purgeTime == null && nullToAbsent + ? const Value.absent() + : Value(purgeTime), + annotations: + annotations == null && nullToAbsent + ? const Value.absent() + : Value(annotations), + regions: Value(regions), + reconciling: Value(reconciling), + etag: Value(etag), + ); + } + + factory ProjectsData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return ProjectsData( + id: serializer.fromJson(json['id']), + parentType: serializer.fromJson(json['parentType']), + parentId: serializer.fromJson(json['parentId']), + projectId: serializer.fromJson(json['projectId']), + state: serializer.fromJson(json['state']), + displayName: serializer.fromJson(json['displayName']), + createTime: serializer.fromJson(json['createTime']), + updateTime: serializer.fromJson(json['updateTime']), + deleteTime: serializer.fromJson(json['deleteTime']), + purgeTime: serializer.fromJson(json['purgeTime']), + annotations: serializer.fromJson(json['annotations']), + regions: serializer.fromJson(json['regions']), + reconciling: serializer.fromJson(json['reconciling']), + etag: serializer.fromJson(json['etag']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'parentType': serializer.toJson(parentType), + 'parentId': serializer.toJson(parentId), + 'projectId': serializer.toJson(projectId), + 'state': serializer.toJson(state), + 'displayName': serializer.toJson(displayName), + 'createTime': serializer.toJson(createTime), + 'updateTime': serializer.toJson(updateTime), + 'deleteTime': serializer.toJson(deleteTime), + 'purgeTime': serializer.toJson(purgeTime), + 'annotations': serializer.toJson(annotations), + 'regions': serializer.toJson(regions), + 'reconciling': serializer.toJson(reconciling), + 'etag': serializer.toJson(etag), + }; + } + + ProjectsData copyWith({ + String? id, + String? parentType, + String? parentId, + String? projectId, + String? state, + Value displayName = const Value.absent(), + DateTime? createTime, + DateTime? updateTime, + Value deleteTime = const Value.absent(), + Value purgeTime = const Value.absent(), + Value annotations = const Value.absent(), + String? regions, + bool? reconciling, + String? etag, + }) => ProjectsData( + id: id ?? this.id, + parentType: parentType ?? this.parentType, + parentId: parentId ?? this.parentId, + projectId: projectId ?? this.projectId, + state: state ?? this.state, + displayName: displayName.present ? displayName.value : this.displayName, + createTime: createTime ?? this.createTime, + updateTime: updateTime ?? this.updateTime, + deleteTime: deleteTime.present ? deleteTime.value : this.deleteTime, + purgeTime: purgeTime.present ? purgeTime.value : this.purgeTime, + annotations: annotations.present ? annotations.value : this.annotations, + regions: regions ?? this.regions, + reconciling: reconciling ?? this.reconciling, + etag: etag ?? this.etag, + ); + ProjectsData copyWithCompanion(ProjectsCompanion data) { + return ProjectsData( + id: data.id.present ? data.id.value : this.id, + parentType: + data.parentType.present ? data.parentType.value : this.parentType, + parentId: data.parentId.present ? data.parentId.value : this.parentId, + projectId: data.projectId.present ? data.projectId.value : this.projectId, + state: data.state.present ? data.state.value : this.state, + displayName: + data.displayName.present ? data.displayName.value : this.displayName, + createTime: + data.createTime.present ? data.createTime.value : this.createTime, + updateTime: + data.updateTime.present ? data.updateTime.value : this.updateTime, + deleteTime: + data.deleteTime.present ? data.deleteTime.value : this.deleteTime, + purgeTime: data.purgeTime.present ? data.purgeTime.value : this.purgeTime, + annotations: + data.annotations.present ? data.annotations.value : this.annotations, + regions: data.regions.present ? data.regions.value : this.regions, + reconciling: + data.reconciling.present ? data.reconciling.value : this.reconciling, + etag: data.etag.present ? data.etag.value : this.etag, + ); + } + + @override + String toString() { + return (StringBuffer('ProjectsData(') + ..write('id: $id, ') + ..write('parentType: $parentType, ') + ..write('parentId: $parentId, ') + ..write('projectId: $projectId, ') + ..write('state: $state, ') + ..write('displayName: $displayName, ') + ..write('createTime: $createTime, ') + ..write('updateTime: $updateTime, ') + ..write('deleteTime: $deleteTime, ') + ..write('purgeTime: $purgeTime, ') + ..write('annotations: $annotations, ') + ..write('regions: $regions, ') + ..write('reconciling: $reconciling, ') + ..write('etag: $etag') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + id, + parentType, + parentId, + projectId, + state, + displayName, + createTime, + updateTime, + deleteTime, + purgeTime, + annotations, + regions, + reconciling, + etag, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is ProjectsData && + other.id == this.id && + other.parentType == this.parentType && + other.parentId == this.parentId && + other.projectId == this.projectId && + other.state == this.state && + other.displayName == this.displayName && + other.createTime == this.createTime && + other.updateTime == this.updateTime && + other.deleteTime == this.deleteTime && + other.purgeTime == this.purgeTime && + other.annotations == this.annotations && + other.regions == this.regions && + other.reconciling == this.reconciling && + other.etag == this.etag); +} + +class ProjectsCompanion extends UpdateCompanion { + final Value id; + final Value parentType; + final Value parentId; + final Value projectId; + final Value state; + final Value displayName; + final Value createTime; + final Value updateTime; + final Value deleteTime; + final Value purgeTime; + final Value annotations; + final Value regions; + final Value reconciling; + final Value etag; + final Value rowid; + const ProjectsCompanion({ + this.id = const Value.absent(), + this.parentType = const Value.absent(), + this.parentId = const Value.absent(), + this.projectId = const Value.absent(), + this.state = const Value.absent(), + this.displayName = const Value.absent(), + this.createTime = const Value.absent(), + this.updateTime = const Value.absent(), + this.deleteTime = const Value.absent(), + this.purgeTime = const Value.absent(), + this.annotations = const Value.absent(), + this.regions = const Value.absent(), + this.reconciling = const Value.absent(), + this.etag = const Value.absent(), + this.rowid = const Value.absent(), + }); + ProjectsCompanion.insert({ + required String id, + required String parentType, + required String parentId, + required String projectId, + this.state = const Value.absent(), + this.displayName = const Value.absent(), + this.createTime = const Value.absent(), + this.updateTime = const Value.absent(), + this.deleteTime = const Value.absent(), + this.purgeTime = const Value.absent(), + this.annotations = const Value.absent(), + required String regions, + this.reconciling = const Value.absent(), + required String etag, + this.rowid = const Value.absent(), + }) : id = Value(id), + parentType = Value(parentType), + parentId = Value(parentId), + projectId = Value(projectId), + regions = Value(regions), + etag = Value(etag); + static Insertable custom({ + Expression? id, + Expression? parentType, + Expression? parentId, + Expression? projectId, + Expression? state, + Expression? displayName, + Expression? createTime, + Expression? updateTime, + Expression? deleteTime, + Expression? purgeTime, + Expression? annotations, + Expression? regions, + Expression? reconciling, + Expression? etag, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (parentType != null) 'parent_type': parentType, + if (parentId != null) 'parent_id': parentId, + if (projectId != null) 'project_id': projectId, + if (state != null) 'state': state, + if (displayName != null) 'display_name': displayName, + if (createTime != null) 'create_time': createTime, + if (updateTime != null) 'update_time': updateTime, + if (deleteTime != null) 'delete_time': deleteTime, + if (purgeTime != null) 'purge_time': purgeTime, + if (annotations != null) 'annotations': annotations, + if (regions != null) 'regions': regions, + if (reconciling != null) 'reconciling': reconciling, + if (etag != null) 'etag': etag, + if (rowid != null) 'rowid': rowid, + }); + } + + ProjectsCompanion copyWith({ + Value? id, + Value? parentType, + Value? parentId, + Value? projectId, + Value? state, + Value? displayName, + Value? createTime, + Value? updateTime, + Value? deleteTime, + Value? purgeTime, + Value? annotations, + Value? regions, + Value? reconciling, + Value? etag, + Value? rowid, + }) { + return ProjectsCompanion( + id: id ?? this.id, + parentType: parentType ?? this.parentType, + parentId: parentId ?? this.parentId, + projectId: projectId ?? this.projectId, + state: state ?? this.state, + displayName: displayName ?? this.displayName, + createTime: createTime ?? this.createTime, + updateTime: updateTime ?? this.updateTime, + deleteTime: deleteTime ?? this.deleteTime, + purgeTime: purgeTime ?? this.purgeTime, + annotations: annotations ?? this.annotations, + regions: regions ?? this.regions, + reconciling: reconciling ?? this.reconciling, + etag: etag ?? this.etag, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (parentType.present) { + map['parent_type'] = Variable(parentType.value); + } + if (parentId.present) { + map['parent_id'] = Variable(parentId.value); + } + if (projectId.present) { + map['project_id'] = Variable(projectId.value); + } + if (state.present) { + map['state'] = Variable(state.value); + } + if (displayName.present) { + map['display_name'] = Variable(displayName.value); + } + if (createTime.present) { + map['create_time'] = Variable(createTime.value); + } + if (updateTime.present) { + map['update_time'] = Variable(updateTime.value); + } + if (deleteTime.present) { + map['delete_time'] = Variable(deleteTime.value); + } + if (purgeTime.present) { + map['purge_time'] = Variable(purgeTime.value); + } + if (annotations.present) { + map['annotations'] = Variable(annotations.value); + } + if (regions.present) { + map['regions'] = Variable(regions.value); + } + if (reconciling.present) { + map['reconciling'] = Variable(reconciling.value); + } + if (etag.present) { + map['etag'] = Variable(etag.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('ProjectsCompanion(') + ..write('id: $id, ') + ..write('parentType: $parentType, ') + ..write('parentId: $parentId, ') + ..write('projectId: $projectId, ') + ..write('state: $state, ') + ..write('displayName: $displayName, ') + ..write('createTime: $createTime, ') + ..write('updateTime: $updateTime, ') + ..write('deleteTime: $deleteTime, ') + ..write('purgeTime: $purgeTime, ') + ..write('annotations: $annotations, ') + ..write('regions: $regions, ') + ..write('reconciling: $reconciling, ') + ..write('etag: $etag, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +class ProjectEnvironments extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + ProjectEnvironments(this.attachedDatabase, [this._alias]); + late final GeneratedColumn id = GeneratedColumn( + 'id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); + late final GeneratedColumn parentType = GeneratedColumn( + 'parent_type', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn parentId = GeneratedColumn( + 'parent_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn projectEnvironmentId = + GeneratedColumn( + 'project_environment_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn state = GeneratedColumn( + 'state', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT \'CREATING\'', + defaultValue: const CustomExpression('\'CREATING\''), + ); + late final GeneratedColumn displayName = GeneratedColumn( + 'display_name', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn createTime = GeneratedColumn( + 'create_time', + aliasedName, + false, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT (unixepoch(\'now\', \'subsec\'))', + defaultValue: const CustomExpression('unixepoch(\'now\', \'subsec\')'), + ); + late final GeneratedColumn updateTime = GeneratedColumn( + 'update_time', + aliasedName, + false, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT (unixepoch(\'now\', \'subsec\'))', + defaultValue: const CustomExpression('unixepoch(\'now\', \'subsec\')'), + ); + late final GeneratedColumn deleteTime = GeneratedColumn( + 'delete_time', + aliasedName, + true, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn annotations = GeneratedColumn( + 'annotations', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn reconciling = GeneratedColumn( + 'reconciling', + aliasedName, + false, + type: DriftSqlType.bool, + requiredDuringInsert: true, + $customConstraints: + 'NOT NULL GENERATED ALWAYS AS (state IN (\'CREATING\', \'UPDATING\', \'DELETING\')) VIRTUAL', + ); + late final GeneratedColumn etag = GeneratedColumn( + 'etag', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: + 'NOT NULL GENERATED ALWAYS AS (hex(md5(json_array(id, parent_type, parent_id, project_environment_id, state, display_name, create_time, update_time, delete_time, annotations, reconciling)))) STORED', + ); + @override + List get $columns => [ + id, + parentType, + parentId, + projectEnvironmentId, + state, + displayName, + createTime, + updateTime, + deleteTime, + annotations, + reconciling, + etag, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'project_environments'; + @override + Set get $primaryKey => {id}; + @override + List> get uniqueKeys => [ + {projectEnvironmentId, parentId}, + ]; + @override + ProjectEnvironmentsData map( + Map data, { + String? tablePrefix, + }) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return ProjectEnvironmentsData( + id: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}id'], + )!, + parentType: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}parent_type'], + )!, + parentId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}parent_id'], + )!, + projectEnvironmentId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}project_environment_id'], + )!, + state: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}state'], + )!, + displayName: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}display_name'], + ), + createTime: + attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}create_time'], + )!, + updateTime: + attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}update_time'], + )!, + deleteTime: attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}delete_time'], + ), + annotations: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}annotations'], + ), + reconciling: + attachedDatabase.typeMapping.read( + DriftSqlType.bool, + data['${effectivePrefix}reconciling'], + )!, + etag: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}etag'], + )!, + ); + } + + @override + ProjectEnvironments createAlias(String alias) { + return ProjectEnvironments(attachedDatabase, alias); + } + + @override + List get customConstraints => const [ + 'CHECK(parent_type = \'Celest::Project\')', + 'CONSTRAINT project_environments_parent_fk FOREIGN KEY(parent_type, parent_id)REFERENCES cedar_entities(entity_type, entity_id)ON UPDATE CASCADE ON DELETE CASCADE', + 'CONSTRAINT project_environments_organization_fk FOREIGN KEY(parent_id)REFERENCES projects(id)ON UPDATE CASCADE ON DELETE CASCADE', + 'CONSTRAINT project_environments_project_environment_id_unique_idx UNIQUE(project_environment_id, parent_id)', + ]; + @override + bool get dontWriteConstraints => true; +} + +class ProjectEnvironmentsData extends DataClass + implements Insertable { + final String id; + final String parentType; + final String parentId; + final String projectEnvironmentId; + final String state; + final String? displayName; + final DateTime createTime; + final DateTime updateTime; + final DateTime? deleteTime; + final String? annotations; + final bool reconciling; + final String etag; + const ProjectEnvironmentsData({ + required this.id, + required this.parentType, + required this.parentId, + required this.projectEnvironmentId, + required this.state, + this.displayName, + required this.createTime, + required this.updateTime, + this.deleteTime, + this.annotations, + required this.reconciling, + required this.etag, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + map['parent_type'] = Variable(parentType); + map['parent_id'] = Variable(parentId); + map['project_environment_id'] = Variable(projectEnvironmentId); + map['state'] = Variable(state); + if (!nullToAbsent || displayName != null) { + map['display_name'] = Variable(displayName); + } + map['create_time'] = Variable(createTime); + map['update_time'] = Variable(updateTime); + if (!nullToAbsent || deleteTime != null) { + map['delete_time'] = Variable(deleteTime); + } + if (!nullToAbsent || annotations != null) { + map['annotations'] = Variable(annotations); + } + map['reconciling'] = Variable(reconciling); + map['etag'] = Variable(etag); + return map; + } + + ProjectEnvironmentsCompanion toCompanion(bool nullToAbsent) { + return ProjectEnvironmentsCompanion( + id: Value(id), + parentType: Value(parentType), + parentId: Value(parentId), + projectEnvironmentId: Value(projectEnvironmentId), + state: Value(state), + displayName: + displayName == null && nullToAbsent + ? const Value.absent() + : Value(displayName), + createTime: Value(createTime), + updateTime: Value(updateTime), + deleteTime: + deleteTime == null && nullToAbsent + ? const Value.absent() + : Value(deleteTime), + annotations: + annotations == null && nullToAbsent + ? const Value.absent() + : Value(annotations), + reconciling: Value(reconciling), + etag: Value(etag), + ); + } + + factory ProjectEnvironmentsData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return ProjectEnvironmentsData( + id: serializer.fromJson(json['id']), + parentType: serializer.fromJson(json['parentType']), + parentId: serializer.fromJson(json['parentId']), + projectEnvironmentId: serializer.fromJson( + json['projectEnvironmentId'], + ), + state: serializer.fromJson(json['state']), + displayName: serializer.fromJson(json['displayName']), + createTime: serializer.fromJson(json['createTime']), + updateTime: serializer.fromJson(json['updateTime']), + deleteTime: serializer.fromJson(json['deleteTime']), + annotations: serializer.fromJson(json['annotations']), + reconciling: serializer.fromJson(json['reconciling']), + etag: serializer.fromJson(json['etag']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'parentType': serializer.toJson(parentType), + 'parentId': serializer.toJson(parentId), + 'projectEnvironmentId': serializer.toJson(projectEnvironmentId), + 'state': serializer.toJson(state), + 'displayName': serializer.toJson(displayName), + 'createTime': serializer.toJson(createTime), + 'updateTime': serializer.toJson(updateTime), + 'deleteTime': serializer.toJson(deleteTime), + 'annotations': serializer.toJson(annotations), + 'reconciling': serializer.toJson(reconciling), + 'etag': serializer.toJson(etag), + }; + } + + ProjectEnvironmentsData copyWith({ + String? id, + String? parentType, + String? parentId, + String? projectEnvironmentId, + String? state, + Value displayName = const Value.absent(), + DateTime? createTime, + DateTime? updateTime, + Value deleteTime = const Value.absent(), + Value annotations = const Value.absent(), + bool? reconciling, + String? etag, + }) => ProjectEnvironmentsData( + id: id ?? this.id, + parentType: parentType ?? this.parentType, + parentId: parentId ?? this.parentId, + projectEnvironmentId: projectEnvironmentId ?? this.projectEnvironmentId, + state: state ?? this.state, + displayName: displayName.present ? displayName.value : this.displayName, + createTime: createTime ?? this.createTime, + updateTime: updateTime ?? this.updateTime, + deleteTime: deleteTime.present ? deleteTime.value : this.deleteTime, + annotations: annotations.present ? annotations.value : this.annotations, + reconciling: reconciling ?? this.reconciling, + etag: etag ?? this.etag, + ); + ProjectEnvironmentsData copyWithCompanion(ProjectEnvironmentsCompanion data) { + return ProjectEnvironmentsData( + id: data.id.present ? data.id.value : this.id, + parentType: + data.parentType.present ? data.parentType.value : this.parentType, + parentId: data.parentId.present ? data.parentId.value : this.parentId, + projectEnvironmentId: + data.projectEnvironmentId.present + ? data.projectEnvironmentId.value + : this.projectEnvironmentId, + state: data.state.present ? data.state.value : this.state, + displayName: + data.displayName.present ? data.displayName.value : this.displayName, + createTime: + data.createTime.present ? data.createTime.value : this.createTime, + updateTime: + data.updateTime.present ? data.updateTime.value : this.updateTime, + deleteTime: + data.deleteTime.present ? data.deleteTime.value : this.deleteTime, + annotations: + data.annotations.present ? data.annotations.value : this.annotations, + reconciling: + data.reconciling.present ? data.reconciling.value : this.reconciling, + etag: data.etag.present ? data.etag.value : this.etag, + ); + } + + @override + String toString() { + return (StringBuffer('ProjectEnvironmentsData(') + ..write('id: $id, ') + ..write('parentType: $parentType, ') + ..write('parentId: $parentId, ') + ..write('projectEnvironmentId: $projectEnvironmentId, ') + ..write('state: $state, ') + ..write('displayName: $displayName, ') + ..write('createTime: $createTime, ') + ..write('updateTime: $updateTime, ') + ..write('deleteTime: $deleteTime, ') + ..write('annotations: $annotations, ') + ..write('reconciling: $reconciling, ') + ..write('etag: $etag') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + id, + parentType, + parentId, + projectEnvironmentId, + state, + displayName, + createTime, + updateTime, + deleteTime, + annotations, + reconciling, + etag, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is ProjectEnvironmentsData && + other.id == this.id && + other.parentType == this.parentType && + other.parentId == this.parentId && + other.projectEnvironmentId == this.projectEnvironmentId && + other.state == this.state && + other.displayName == this.displayName && + other.createTime == this.createTime && + other.updateTime == this.updateTime && + other.deleteTime == this.deleteTime && + other.annotations == this.annotations && + other.reconciling == this.reconciling && + other.etag == this.etag); +} + +class ProjectEnvironmentsCompanion + extends UpdateCompanion { + final Value id; + final Value parentType; + final Value parentId; + final Value projectEnvironmentId; + final Value state; + final Value displayName; + final Value createTime; + final Value updateTime; + final Value deleteTime; + final Value annotations; + final Value reconciling; + final Value etag; + final Value rowid; + const ProjectEnvironmentsCompanion({ + this.id = const Value.absent(), + this.parentType = const Value.absent(), + this.parentId = const Value.absent(), + this.projectEnvironmentId = const Value.absent(), + this.state = const Value.absent(), + this.displayName = const Value.absent(), + this.createTime = const Value.absent(), + this.updateTime = const Value.absent(), + this.deleteTime = const Value.absent(), + this.annotations = const Value.absent(), + this.reconciling = const Value.absent(), + this.etag = const Value.absent(), + this.rowid = const Value.absent(), + }); + ProjectEnvironmentsCompanion.insert({ + required String id, + required String parentType, + required String parentId, + required String projectEnvironmentId, + this.state = const Value.absent(), + this.displayName = const Value.absent(), + this.createTime = const Value.absent(), + this.updateTime = const Value.absent(), + this.deleteTime = const Value.absent(), + this.annotations = const Value.absent(), + required bool reconciling, + required String etag, + this.rowid = const Value.absent(), + }) : id = Value(id), + parentType = Value(parentType), + parentId = Value(parentId), + projectEnvironmentId = Value(projectEnvironmentId), + reconciling = Value(reconciling), + etag = Value(etag); + static Insertable custom({ + Expression? id, + Expression? parentType, + Expression? parentId, + Expression? projectEnvironmentId, + Expression? state, + Expression? displayName, + Expression? createTime, + Expression? updateTime, + Expression? deleteTime, + Expression? annotations, + Expression? reconciling, + Expression? etag, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (parentType != null) 'parent_type': parentType, + if (parentId != null) 'parent_id': parentId, + if (projectEnvironmentId != null) + 'project_environment_id': projectEnvironmentId, + if (state != null) 'state': state, + if (displayName != null) 'display_name': displayName, + if (createTime != null) 'create_time': createTime, + if (updateTime != null) 'update_time': updateTime, + if (deleteTime != null) 'delete_time': deleteTime, + if (annotations != null) 'annotations': annotations, + if (reconciling != null) 'reconciling': reconciling, + if (etag != null) 'etag': etag, + if (rowid != null) 'rowid': rowid, + }); + } + + ProjectEnvironmentsCompanion copyWith({ + Value? id, + Value? parentType, + Value? parentId, + Value? projectEnvironmentId, + Value? state, + Value? displayName, + Value? createTime, + Value? updateTime, + Value? deleteTime, + Value? annotations, + Value? reconciling, + Value? etag, + Value? rowid, + }) { + return ProjectEnvironmentsCompanion( + id: id ?? this.id, + parentType: parentType ?? this.parentType, + parentId: parentId ?? this.parentId, + projectEnvironmentId: projectEnvironmentId ?? this.projectEnvironmentId, + state: state ?? this.state, + displayName: displayName ?? this.displayName, + createTime: createTime ?? this.createTime, + updateTime: updateTime ?? this.updateTime, + deleteTime: deleteTime ?? this.deleteTime, + annotations: annotations ?? this.annotations, + reconciling: reconciling ?? this.reconciling, + etag: etag ?? this.etag, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (parentType.present) { + map['parent_type'] = Variable(parentType.value); + } + if (parentId.present) { + map['parent_id'] = Variable(parentId.value); + } + if (projectEnvironmentId.present) { + map['project_environment_id'] = Variable( + projectEnvironmentId.value, + ); + } + if (state.present) { + map['state'] = Variable(state.value); + } + if (displayName.present) { + map['display_name'] = Variable(displayName.value); + } + if (createTime.present) { + map['create_time'] = Variable(createTime.value); + } + if (updateTime.present) { + map['update_time'] = Variable(updateTime.value); + } + if (deleteTime.present) { + map['delete_time'] = Variable(deleteTime.value); + } + if (annotations.present) { + map['annotations'] = Variable(annotations.value); + } + if (reconciling.present) { + map['reconciling'] = Variable(reconciling.value); + } + if (etag.present) { + map['etag'] = Variable(etag.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('ProjectEnvironmentsCompanion(') + ..write('id: $id, ') + ..write('parentType: $parentType, ') + ..write('parentId: $parentId, ') + ..write('projectEnvironmentId: $projectEnvironmentId, ') + ..write('state: $state, ') + ..write('displayName: $displayName, ') + ..write('createTime: $createTime, ') + ..write('updateTime: $updateTime, ') + ..write('deleteTime: $deleteTime, ') + ..write('annotations: $annotations, ') + ..write('reconciling: $reconciling, ') + ..write('etag: $etag, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +class ProjectEnvironmentAsts extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + ProjectEnvironmentAsts(this.attachedDatabase, [this._alias]); + late final GeneratedColumn projectEnvironmentId = + GeneratedColumn( + 'project_environment_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); + late final GeneratedColumn ast = GeneratedColumn( + 'ast', + aliasedName, + false, + type: DriftSqlType.blob, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn version = GeneratedColumn( + 'version', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn digest = GeneratedColumn( + 'digest', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL GENERATED ALWAYS AS (hex(md5(ast))) STORED', + ); + @override + List get $columns => [ + projectEnvironmentId, + ast, + version, + digest, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'project_environment_asts'; + @override + Set get $primaryKey => {projectEnvironmentId}; + @override + ProjectEnvironmentAstsData map( + Map data, { + String? tablePrefix, + }) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return ProjectEnvironmentAstsData( + projectEnvironmentId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}project_environment_id'], + )!, + ast: + attachedDatabase.typeMapping.read( + DriftSqlType.blob, + data['${effectivePrefix}ast'], + )!, + version: + attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}version'], + )!, + digest: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}digest'], + )!, + ); + } + + @override + ProjectEnvironmentAsts createAlias(String alias) { + return ProjectEnvironmentAsts(attachedDatabase, alias); + } + + @override + bool get withoutRowId => true; + @override + List get customConstraints => const [ + 'CONSTRAINT fk_environment_metadata_project_environment_id FOREIGN KEY(project_environment_id)REFERENCES project_environments(id)ON UPDATE CASCADE ON DELETE CASCADE', + ]; + @override + bool get dontWriteConstraints => true; +} + +class ProjectEnvironmentAstsData extends DataClass + implements Insertable { + final String projectEnvironmentId; + final Uint8List ast; + final int version; + final String digest; + const ProjectEnvironmentAstsData({ + required this.projectEnvironmentId, + required this.ast, + required this.version, + required this.digest, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['project_environment_id'] = Variable(projectEnvironmentId); + map['ast'] = Variable(ast); + map['version'] = Variable(version); + map['digest'] = Variable(digest); + return map; + } + + ProjectEnvironmentAstsCompanion toCompanion(bool nullToAbsent) { + return ProjectEnvironmentAstsCompanion( + projectEnvironmentId: Value(projectEnvironmentId), + ast: Value(ast), + version: Value(version), + digest: Value(digest), + ); + } + + factory ProjectEnvironmentAstsData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return ProjectEnvironmentAstsData( + projectEnvironmentId: serializer.fromJson( + json['projectEnvironmentId'], + ), + ast: serializer.fromJson(json['ast']), + version: serializer.fromJson(json['version']), + digest: serializer.fromJson(json['digest']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'projectEnvironmentId': serializer.toJson(projectEnvironmentId), + 'ast': serializer.toJson(ast), + 'version': serializer.toJson(version), + 'digest': serializer.toJson(digest), + }; + } + + ProjectEnvironmentAstsData copyWith({ + String? projectEnvironmentId, + Uint8List? ast, + int? version, + String? digest, + }) => ProjectEnvironmentAstsData( + projectEnvironmentId: projectEnvironmentId ?? this.projectEnvironmentId, + ast: ast ?? this.ast, + version: version ?? this.version, + digest: digest ?? this.digest, + ); + ProjectEnvironmentAstsData copyWithCompanion( + ProjectEnvironmentAstsCompanion data, + ) { + return ProjectEnvironmentAstsData( + projectEnvironmentId: + data.projectEnvironmentId.present + ? data.projectEnvironmentId.value + : this.projectEnvironmentId, + ast: data.ast.present ? data.ast.value : this.ast, + version: data.version.present ? data.version.value : this.version, + digest: data.digest.present ? data.digest.value : this.digest, + ); + } + + @override + String toString() { + return (StringBuffer('ProjectEnvironmentAstsData(') + ..write('projectEnvironmentId: $projectEnvironmentId, ') + ..write('ast: $ast, ') + ..write('version: $version, ') + ..write('digest: $digest') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + projectEnvironmentId, + $driftBlobEquality.hash(ast), + version, + digest, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is ProjectEnvironmentAstsData && + other.projectEnvironmentId == this.projectEnvironmentId && + $driftBlobEquality.equals(other.ast, this.ast) && + other.version == this.version && + other.digest == this.digest); +} + +class ProjectEnvironmentAstsCompanion + extends UpdateCompanion { + final Value projectEnvironmentId; + final Value ast; + final Value version; + final Value digest; + const ProjectEnvironmentAstsCompanion({ + this.projectEnvironmentId = const Value.absent(), + this.ast = const Value.absent(), + this.version = const Value.absent(), + this.digest = const Value.absent(), + }); + ProjectEnvironmentAstsCompanion.insert({ + required String projectEnvironmentId, + required Uint8List ast, + required int version, + required String digest, + }) : projectEnvironmentId = Value(projectEnvironmentId), + ast = Value(ast), + version = Value(version), + digest = Value(digest); + static Insertable custom({ + Expression? projectEnvironmentId, + Expression? ast, + Expression? version, + Expression? digest, + }) { + return RawValuesInsertable({ + if (projectEnvironmentId != null) + 'project_environment_id': projectEnvironmentId, + if (ast != null) 'ast': ast, + if (version != null) 'version': version, + if (digest != null) 'digest': digest, + }); + } + + ProjectEnvironmentAstsCompanion copyWith({ + Value? projectEnvironmentId, + Value? ast, + Value? version, + Value? digest, + }) { + return ProjectEnvironmentAstsCompanion( + projectEnvironmentId: projectEnvironmentId ?? this.projectEnvironmentId, + ast: ast ?? this.ast, + version: version ?? this.version, + digest: digest ?? this.digest, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (projectEnvironmentId.present) { + map['project_environment_id'] = Variable( + projectEnvironmentId.value, + ); + } + if (ast.present) { + map['ast'] = Variable(ast.value); + } + if (version.present) { + map['version'] = Variable(version.value); + } + if (digest.present) { + map['digest'] = Variable(digest.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('ProjectEnvironmentAstsCompanion(') + ..write('projectEnvironmentId: $projectEnvironmentId, ') + ..write('ast: $ast, ') + ..write('version: $version, ') + ..write('digest: $digest') + ..write(')')) + .toString(); + } +} + +class ProjectEnvironmentAssets extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + ProjectEnvironmentAssets(this.attachedDatabase, [this._alias]); + late final GeneratedColumn projectEnvironmentId = + GeneratedColumn( + 'project_environment_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn type = GeneratedColumn( + 'type', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn bucket = GeneratedColumn( + 'bucket', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn name = GeneratedColumn( + 'name', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + late final GeneratedColumn etag = GeneratedColumn( + 'etag', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL', + ); + @override + List get $columns => [ + projectEnvironmentId, + type, + bucket, + name, + etag, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'project_environment_assets'; + @override + Set get $primaryKey => {projectEnvironmentId, name}; + @override + ProjectEnvironmentAssetsData map( + Map data, { + String? tablePrefix, + }) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return ProjectEnvironmentAssetsData( + projectEnvironmentId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}project_environment_id'], + )!, + type: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}type'], + )!, + bucket: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}bucket'], + )!, + name: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}name'], + )!, + etag: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}etag'], + )!, + ); + } + + @override + ProjectEnvironmentAssets createAlias(String alias) { + return ProjectEnvironmentAssets(attachedDatabase, alias); + } + + @override + bool get withoutRowId => true; + @override + List get customConstraints => const [ + 'PRIMARY KEY(project_environment_id, name)', + 'CONSTRAINT fk_environment_assets_project_environment_id FOREIGN KEY(project_environment_id)REFERENCES project_environments(id)ON UPDATE CASCADE ON DELETE CASCADE', + ]; + @override + bool get dontWriteConstraints => true; +} + +class ProjectEnvironmentAssetsData extends DataClass + implements Insertable { + final String projectEnvironmentId; + final String type; + final String bucket; + final String name; + final String etag; + const ProjectEnvironmentAssetsData({ + required this.projectEnvironmentId, + required this.type, + required this.bucket, + required this.name, + required this.etag, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['project_environment_id'] = Variable(projectEnvironmentId); + map['type'] = Variable(type); + map['bucket'] = Variable(bucket); + map['name'] = Variable(name); + map['etag'] = Variable(etag); + return map; + } + + ProjectEnvironmentAssetsCompanion toCompanion(bool nullToAbsent) { + return ProjectEnvironmentAssetsCompanion( + projectEnvironmentId: Value(projectEnvironmentId), + type: Value(type), + bucket: Value(bucket), + name: Value(name), + etag: Value(etag), + ); + } + + factory ProjectEnvironmentAssetsData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return ProjectEnvironmentAssetsData( + projectEnvironmentId: serializer.fromJson( + json['projectEnvironmentId'], + ), + type: serializer.fromJson(json['type']), + bucket: serializer.fromJson(json['bucket']), + name: serializer.fromJson(json['name']), + etag: serializer.fromJson(json['etag']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'projectEnvironmentId': serializer.toJson(projectEnvironmentId), + 'type': serializer.toJson(type), + 'bucket': serializer.toJson(bucket), + 'name': serializer.toJson(name), + 'etag': serializer.toJson(etag), + }; + } + + ProjectEnvironmentAssetsData copyWith({ + String? projectEnvironmentId, + String? type, + String? bucket, + String? name, + String? etag, + }) => ProjectEnvironmentAssetsData( + projectEnvironmentId: projectEnvironmentId ?? this.projectEnvironmentId, + type: type ?? this.type, + bucket: bucket ?? this.bucket, + name: name ?? this.name, + etag: etag ?? this.etag, + ); + ProjectEnvironmentAssetsData copyWithCompanion( + ProjectEnvironmentAssetsCompanion data, + ) { + return ProjectEnvironmentAssetsData( + projectEnvironmentId: + data.projectEnvironmentId.present + ? data.projectEnvironmentId.value + : this.projectEnvironmentId, + type: data.type.present ? data.type.value : this.type, + bucket: data.bucket.present ? data.bucket.value : this.bucket, + name: data.name.present ? data.name.value : this.name, + etag: data.etag.present ? data.etag.value : this.etag, + ); + } + + @override + String toString() { + return (StringBuffer('ProjectEnvironmentAssetsData(') + ..write('projectEnvironmentId: $projectEnvironmentId, ') + ..write('type: $type, ') + ..write('bucket: $bucket, ') + ..write('name: $name, ') + ..write('etag: $etag') + ..write(')')) + .toString(); + } + + @override + int get hashCode => + Object.hash(projectEnvironmentId, type, bucket, name, etag); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is ProjectEnvironmentAssetsData && + other.projectEnvironmentId == this.projectEnvironmentId && + other.type == this.type && + other.bucket == this.bucket && + other.name == this.name && + other.etag == this.etag); +} + +class ProjectEnvironmentAssetsCompanion + extends UpdateCompanion { + final Value projectEnvironmentId; + final Value type; + final Value bucket; + final Value name; + final Value etag; + const ProjectEnvironmentAssetsCompanion({ + this.projectEnvironmentId = const Value.absent(), + this.type = const Value.absent(), + this.bucket = const Value.absent(), + this.name = const Value.absent(), + this.etag = const Value.absent(), + }); + ProjectEnvironmentAssetsCompanion.insert({ + required String projectEnvironmentId, + required String type, + required String bucket, + required String name, + required String etag, + }) : projectEnvironmentId = Value(projectEnvironmentId), + type = Value(type), + bucket = Value(bucket), + name = Value(name), + etag = Value(etag); + static Insertable custom({ + Expression? projectEnvironmentId, + Expression? type, + Expression? bucket, + Expression? name, + Expression? etag, + }) { + return RawValuesInsertable({ + if (projectEnvironmentId != null) + 'project_environment_id': projectEnvironmentId, + if (type != null) 'type': type, + if (bucket != null) 'bucket': bucket, + if (name != null) 'name': name, + if (etag != null) 'etag': etag, + }); + } + + ProjectEnvironmentAssetsCompanion copyWith({ + Value? projectEnvironmentId, + Value? type, + Value? bucket, + Value? name, + Value? etag, + }) { + return ProjectEnvironmentAssetsCompanion( + projectEnvironmentId: projectEnvironmentId ?? this.projectEnvironmentId, + type: type ?? this.type, + bucket: bucket ?? this.bucket, + name: name ?? this.name, + etag: etag ?? this.etag, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (projectEnvironmentId.present) { + map['project_environment_id'] = Variable( + projectEnvironmentId.value, + ); + } + if (type.present) { + map['type'] = Variable(type.value); + } + if (bucket.present) { + map['bucket'] = Variable(bucket.value); + } + if (name.present) { + map['name'] = Variable(name.value); + } + if (etag.present) { + map['etag'] = Variable(etag.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('ProjectEnvironmentAssetsCompanion(') + ..write('projectEnvironmentId: $projectEnvironmentId, ') + ..write('type: $type, ') + ..write('bucket: $bucket, ') + ..write('name: $name, ') + ..write('etag: $etag') + ..write(')')) + .toString(); + } +} + +class ProjectEnvironmentStates extends Table + with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + ProjectEnvironmentStates(this.attachedDatabase, [this._alias]); + late final GeneratedColumn projectEnvironmentId = + GeneratedColumn( + 'project_environment_id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); + late final GeneratedColumn domainName = GeneratedColumn( + 'domain_name', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn flyAppName = GeneratedColumn( + 'fly_app_name', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn flyVolumeName = GeneratedColumn( + 'fly_volume_name', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn flyVolumeId = GeneratedColumn( + 'fly_volume_id', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + @override + List get $columns => [ + projectEnvironmentId, + domainName, + flyAppName, + flyVolumeName, + flyVolumeId, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'project_environment_states'; + @override + Set get $primaryKey => {projectEnvironmentId}; + @override + ProjectEnvironmentStatesData map( + Map data, { + String? tablePrefix, + }) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return ProjectEnvironmentStatesData( + projectEnvironmentId: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}project_environment_id'], + )!, + domainName: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}domain_name'], + ), + flyAppName: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}fly_app_name'], + ), + flyVolumeName: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}fly_volume_name'], + ), + flyVolumeId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}fly_volume_id'], + ), + ); + } + + @override + ProjectEnvironmentStates createAlias(String alias) { + return ProjectEnvironmentStates(attachedDatabase, alias); + } + + @override + bool get withoutRowId => true; + @override + List get customConstraints => const [ + 'CONSTRAINT fk_project_environment_state_project_environment_id FOREIGN KEY(project_environment_id)REFERENCES project_environments(id)ON UPDATE CASCADE ON DELETE CASCADE', + ]; + @override + bool get dontWriteConstraints => true; +} + +class ProjectEnvironmentStatesData extends DataClass + implements Insertable { + final String projectEnvironmentId; + final String? domainName; + final String? flyAppName; + final String? flyVolumeName; + final String? flyVolumeId; + const ProjectEnvironmentStatesData({ + required this.projectEnvironmentId, + this.domainName, + this.flyAppName, + this.flyVolumeName, + this.flyVolumeId, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['project_environment_id'] = Variable(projectEnvironmentId); + if (!nullToAbsent || domainName != null) { + map['domain_name'] = Variable(domainName); + } + if (!nullToAbsent || flyAppName != null) { + map['fly_app_name'] = Variable(flyAppName); + } + if (!nullToAbsent || flyVolumeName != null) { + map['fly_volume_name'] = Variable(flyVolumeName); + } + if (!nullToAbsent || flyVolumeId != null) { + map['fly_volume_id'] = Variable(flyVolumeId); + } + return map; + } + + ProjectEnvironmentStatesCompanion toCompanion(bool nullToAbsent) { + return ProjectEnvironmentStatesCompanion( + projectEnvironmentId: Value(projectEnvironmentId), + domainName: + domainName == null && nullToAbsent + ? const Value.absent() + : Value(domainName), + flyAppName: + flyAppName == null && nullToAbsent + ? const Value.absent() + : Value(flyAppName), + flyVolumeName: + flyVolumeName == null && nullToAbsent + ? const Value.absent() + : Value(flyVolumeName), + flyVolumeId: + flyVolumeId == null && nullToAbsent + ? const Value.absent() + : Value(flyVolumeId), + ); + } + + factory ProjectEnvironmentStatesData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return ProjectEnvironmentStatesData( + projectEnvironmentId: serializer.fromJson( + json['projectEnvironmentId'], + ), + domainName: serializer.fromJson(json['domainName']), + flyAppName: serializer.fromJson(json['flyAppName']), + flyVolumeName: serializer.fromJson(json['flyVolumeName']), + flyVolumeId: serializer.fromJson(json['flyVolumeId']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'projectEnvironmentId': serializer.toJson(projectEnvironmentId), + 'domainName': serializer.toJson(domainName), + 'flyAppName': serializer.toJson(flyAppName), + 'flyVolumeName': serializer.toJson(flyVolumeName), + 'flyVolumeId': serializer.toJson(flyVolumeId), + }; + } + + ProjectEnvironmentStatesData copyWith({ + String? projectEnvironmentId, + Value domainName = const Value.absent(), + Value flyAppName = const Value.absent(), + Value flyVolumeName = const Value.absent(), + Value flyVolumeId = const Value.absent(), + }) => ProjectEnvironmentStatesData( + projectEnvironmentId: projectEnvironmentId ?? this.projectEnvironmentId, + domainName: domainName.present ? domainName.value : this.domainName, + flyAppName: flyAppName.present ? flyAppName.value : this.flyAppName, + flyVolumeName: + flyVolumeName.present ? flyVolumeName.value : this.flyVolumeName, + flyVolumeId: flyVolumeId.present ? flyVolumeId.value : this.flyVolumeId, + ); + ProjectEnvironmentStatesData copyWithCompanion( + ProjectEnvironmentStatesCompanion data, + ) { + return ProjectEnvironmentStatesData( + projectEnvironmentId: + data.projectEnvironmentId.present + ? data.projectEnvironmentId.value + : this.projectEnvironmentId, + domainName: + data.domainName.present ? data.domainName.value : this.domainName, + flyAppName: + data.flyAppName.present ? data.flyAppName.value : this.flyAppName, + flyVolumeName: + data.flyVolumeName.present + ? data.flyVolumeName.value + : this.flyVolumeName, + flyVolumeId: + data.flyVolumeId.present ? data.flyVolumeId.value : this.flyVolumeId, + ); + } + + @override + String toString() { + return (StringBuffer('ProjectEnvironmentStatesData(') + ..write('projectEnvironmentId: $projectEnvironmentId, ') + ..write('domainName: $domainName, ') + ..write('flyAppName: $flyAppName, ') + ..write('flyVolumeName: $flyVolumeName, ') + ..write('flyVolumeId: $flyVolumeId') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + projectEnvironmentId, + domainName, + flyAppName, + flyVolumeName, + flyVolumeId, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is ProjectEnvironmentStatesData && + other.projectEnvironmentId == this.projectEnvironmentId && + other.domainName == this.domainName && + other.flyAppName == this.flyAppName && + other.flyVolumeName == this.flyVolumeName && + other.flyVolumeId == this.flyVolumeId); +} + +class ProjectEnvironmentStatesCompanion + extends UpdateCompanion { + final Value projectEnvironmentId; + final Value domainName; + final Value flyAppName; + final Value flyVolumeName; + final Value flyVolumeId; + const ProjectEnvironmentStatesCompanion({ + this.projectEnvironmentId = const Value.absent(), + this.domainName = const Value.absent(), + this.flyAppName = const Value.absent(), + this.flyVolumeName = const Value.absent(), + this.flyVolumeId = const Value.absent(), + }); + ProjectEnvironmentStatesCompanion.insert({ + required String projectEnvironmentId, + this.domainName = const Value.absent(), + this.flyAppName = const Value.absent(), + this.flyVolumeName = const Value.absent(), + this.flyVolumeId = const Value.absent(), + }) : projectEnvironmentId = Value(projectEnvironmentId); + static Insertable custom({ + Expression? projectEnvironmentId, + Expression? domainName, + Expression? flyAppName, + Expression? flyVolumeName, + Expression? flyVolumeId, + }) { + return RawValuesInsertable({ + if (projectEnvironmentId != null) + 'project_environment_id': projectEnvironmentId, + if (domainName != null) 'domain_name': domainName, + if (flyAppName != null) 'fly_app_name': flyAppName, + if (flyVolumeName != null) 'fly_volume_name': flyVolumeName, + if (flyVolumeId != null) 'fly_volume_id': flyVolumeId, + }); + } + + ProjectEnvironmentStatesCompanion copyWith({ + Value? projectEnvironmentId, + Value? domainName, + Value? flyAppName, + Value? flyVolumeName, + Value? flyVolumeId, + }) { + return ProjectEnvironmentStatesCompanion( + projectEnvironmentId: projectEnvironmentId ?? this.projectEnvironmentId, + domainName: domainName ?? this.domainName, + flyAppName: flyAppName ?? this.flyAppName, + flyVolumeName: flyVolumeName ?? this.flyVolumeName, + flyVolumeId: flyVolumeId ?? this.flyVolumeId, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (projectEnvironmentId.present) { + map['project_environment_id'] = Variable( + projectEnvironmentId.value, + ); + } + if (domainName.present) { + map['domain_name'] = Variable(domainName.value); + } + if (flyAppName.present) { + map['fly_app_name'] = Variable(flyAppName.value); + } + if (flyVolumeName.present) { + map['fly_volume_name'] = Variable(flyVolumeName.value); + } + if (flyVolumeId.present) { + map['fly_volume_id'] = Variable(flyVolumeId.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('ProjectEnvironmentStatesCompanion(') + ..write('projectEnvironmentId: $projectEnvironmentId, ') + ..write('domainName: $domainName, ') + ..write('flyAppName: $flyAppName, ') + ..write('flyVolumeName: $flyVolumeName, ') + ..write('flyVolumeId: $flyVolumeId') + ..write(')')) + .toString(); + } +} + +class Operations extends Table with TableInfo { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + Operations(this.attachedDatabase, [this._alias]); + late final GeneratedColumn id = GeneratedColumn( + 'id', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: true, + $customConstraints: 'NOT NULL PRIMARY KEY', + ); + late final GeneratedColumn metadata = GeneratedColumn( + 'metadata', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn response = GeneratedColumn( + 'response', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn error = GeneratedColumn( + 'error', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn done = GeneratedColumn( + 'done', + aliasedName, + false, + type: DriftSqlType.bool, + requiredDuringInsert: true, + $customConstraints: + 'NOT NULL GENERATED ALWAYS AS (response IS NOT NULL OR error IS NOT NULL) VIRTUAL', + ); + late final GeneratedColumn createTime = GeneratedColumn( + 'create_time', + aliasedName, + false, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + $customConstraints: 'NOT NULL DEFAULT (unixepoch(\'now\', \'subsec\'))', + defaultValue: const CustomExpression('unixepoch(\'now\', \'subsec\')'), + ); + late final GeneratedColumn fullResourceName = GeneratedColumn( + 'full_resource_name', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn ownerType = GeneratedColumn( + 'owner_type', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn ownerId = GeneratedColumn( + 'owner_id', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn resourceType = GeneratedColumn( + 'resource_type', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + late final GeneratedColumn resourceId = GeneratedColumn( + 'resource_id', + aliasedName, + true, + type: DriftSqlType.string, + requiredDuringInsert: false, + $customConstraints: '', + ); + @override + List get $columns => [ + id, + metadata, + response, + error, + done, + createTime, + fullResourceName, + ownerType, + ownerId, + resourceType, + resourceId, + ]; + @override + String get aliasedName => _alias ?? actualTableName; + @override + String get actualTableName => $name; + static const String $name = 'operations'; + @override + Set get $primaryKey => {id}; + @override + OperationsData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return OperationsData( + id: + attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}id'], + )!, + metadata: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}metadata'], + ), + response: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}response'], + ), + error: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}error'], + ), + done: + attachedDatabase.typeMapping.read( + DriftSqlType.bool, + data['${effectivePrefix}done'], + )!, + createTime: + attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}create_time'], + )!, + fullResourceName: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}full_resource_name'], + ), + ownerType: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}owner_type'], + ), + ownerId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}owner_id'], + ), + resourceType: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}resource_type'], + ), + resourceId: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}resource_id'], + ), + ); + } + + @override + Operations createAlias(String alias) { + return Operations(attachedDatabase, alias); + } + + @override + bool get dontWriteConstraints => true; +} + +class OperationsData extends DataClass implements Insertable { + final String id; + final String? metadata; + final String? response; + final String? error; + final bool done; + final DateTime createTime; + final String? fullResourceName; + final String? ownerType; + final String? ownerId; + final String? resourceType; + final String? resourceId; + const OperationsData({ + required this.id, + this.metadata, + this.response, + this.error, + required this.done, + required this.createTime, + this.fullResourceName, + this.ownerType, + this.ownerId, + this.resourceType, + this.resourceId, + }); + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + if (!nullToAbsent || metadata != null) { + map['metadata'] = Variable(metadata); + } + if (!nullToAbsent || response != null) { + map['response'] = Variable(response); + } + if (!nullToAbsent || error != null) { + map['error'] = Variable(error); + } + map['done'] = Variable(done); + map['create_time'] = Variable(createTime); + if (!nullToAbsent || fullResourceName != null) { + map['full_resource_name'] = Variable(fullResourceName); + } + if (!nullToAbsent || ownerType != null) { + map['owner_type'] = Variable(ownerType); + } + if (!nullToAbsent || ownerId != null) { + map['owner_id'] = Variable(ownerId); + } + if (!nullToAbsent || resourceType != null) { + map['resource_type'] = Variable(resourceType); + } + if (!nullToAbsent || resourceId != null) { + map['resource_id'] = Variable(resourceId); + } + return map; + } + + OperationsCompanion toCompanion(bool nullToAbsent) { + return OperationsCompanion( + id: Value(id), + metadata: + metadata == null && nullToAbsent + ? const Value.absent() + : Value(metadata), + response: + response == null && nullToAbsent + ? const Value.absent() + : Value(response), + error: + error == null && nullToAbsent ? const Value.absent() : Value(error), + done: Value(done), + createTime: Value(createTime), + fullResourceName: + fullResourceName == null && nullToAbsent + ? const Value.absent() + : Value(fullResourceName), + ownerType: + ownerType == null && nullToAbsent + ? const Value.absent() + : Value(ownerType), + ownerId: + ownerId == null && nullToAbsent + ? const Value.absent() + : Value(ownerId), + resourceType: + resourceType == null && nullToAbsent + ? const Value.absent() + : Value(resourceType), + resourceId: + resourceId == null && nullToAbsent + ? const Value.absent() + : Value(resourceId), + ); + } + + factory OperationsData.fromJson( + Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return OperationsData( + id: serializer.fromJson(json['id']), + metadata: serializer.fromJson(json['metadata']), + response: serializer.fromJson(json['response']), + error: serializer.fromJson(json['error']), + done: serializer.fromJson(json['done']), + createTime: serializer.fromJson(json['createTime']), + fullResourceName: serializer.fromJson(json['fullResourceName']), + ownerType: serializer.fromJson(json['ownerType']), + ownerId: serializer.fromJson(json['ownerId']), + resourceType: serializer.fromJson(json['resourceType']), + resourceId: serializer.fromJson(json['resourceId']), + ); + } + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'metadata': serializer.toJson(metadata), + 'response': serializer.toJson(response), + 'error': serializer.toJson(error), + 'done': serializer.toJson(done), + 'createTime': serializer.toJson(createTime), + 'fullResourceName': serializer.toJson(fullResourceName), + 'ownerType': serializer.toJson(ownerType), + 'ownerId': serializer.toJson(ownerId), + 'resourceType': serializer.toJson(resourceType), + 'resourceId': serializer.toJson(resourceId), + }; + } + + OperationsData copyWith({ + String? id, + Value metadata = const Value.absent(), + Value response = const Value.absent(), + Value error = const Value.absent(), + bool? done, + DateTime? createTime, + Value fullResourceName = const Value.absent(), + Value ownerType = const Value.absent(), + Value ownerId = const Value.absent(), + Value resourceType = const Value.absent(), + Value resourceId = const Value.absent(), + }) => OperationsData( + id: id ?? this.id, + metadata: metadata.present ? metadata.value : this.metadata, + response: response.present ? response.value : this.response, + error: error.present ? error.value : this.error, + done: done ?? this.done, + createTime: createTime ?? this.createTime, + fullResourceName: + fullResourceName.present + ? fullResourceName.value + : this.fullResourceName, + ownerType: ownerType.present ? ownerType.value : this.ownerType, + ownerId: ownerId.present ? ownerId.value : this.ownerId, + resourceType: resourceType.present ? resourceType.value : this.resourceType, + resourceId: resourceId.present ? resourceId.value : this.resourceId, + ); + OperationsData copyWithCompanion(OperationsCompanion data) { + return OperationsData( + id: data.id.present ? data.id.value : this.id, + metadata: data.metadata.present ? data.metadata.value : this.metadata, + response: data.response.present ? data.response.value : this.response, + error: data.error.present ? data.error.value : this.error, + done: data.done.present ? data.done.value : this.done, + createTime: + data.createTime.present ? data.createTime.value : this.createTime, + fullResourceName: + data.fullResourceName.present + ? data.fullResourceName.value + : this.fullResourceName, + ownerType: data.ownerType.present ? data.ownerType.value : this.ownerType, + ownerId: data.ownerId.present ? data.ownerId.value : this.ownerId, + resourceType: + data.resourceType.present + ? data.resourceType.value + : this.resourceType, + resourceId: + data.resourceId.present ? data.resourceId.value : this.resourceId, + ); + } + + @override + String toString() { + return (StringBuffer('OperationsData(') + ..write('id: $id, ') + ..write('metadata: $metadata, ') + ..write('response: $response, ') + ..write('error: $error, ') + ..write('done: $done, ') + ..write('createTime: $createTime, ') + ..write('fullResourceName: $fullResourceName, ') + ..write('ownerType: $ownerType, ') + ..write('ownerId: $ownerId, ') + ..write('resourceType: $resourceType, ') + ..write('resourceId: $resourceId') + ..write(')')) + .toString(); + } + + @override + int get hashCode => Object.hash( + id, + metadata, + response, + error, + done, + createTime, + fullResourceName, + ownerType, + ownerId, + resourceType, + resourceId, + ); + @override + bool operator ==(Object other) => + identical(this, other) || + (other is OperationsData && + other.id == this.id && + other.metadata == this.metadata && + other.response == this.response && + other.error == this.error && + other.done == this.done && + other.createTime == this.createTime && + other.fullResourceName == this.fullResourceName && + other.ownerType == this.ownerType && + other.ownerId == this.ownerId && + other.resourceType == this.resourceType && + other.resourceId == this.resourceId); +} + +class OperationsCompanion extends UpdateCompanion { + final Value id; + final Value metadata; + final Value response; + final Value error; + final Value done; + final Value createTime; + final Value fullResourceName; + final Value ownerType; + final Value ownerId; + final Value resourceType; + final Value resourceId; + final Value rowid; + const OperationsCompanion({ + this.id = const Value.absent(), + this.metadata = const Value.absent(), + this.response = const Value.absent(), + this.error = const Value.absent(), + this.done = const Value.absent(), + this.createTime = const Value.absent(), + this.fullResourceName = const Value.absent(), + this.ownerType = const Value.absent(), + this.ownerId = const Value.absent(), + this.resourceType = const Value.absent(), + this.resourceId = const Value.absent(), + this.rowid = const Value.absent(), + }); + OperationsCompanion.insert({ + required String id, + this.metadata = const Value.absent(), + this.response = const Value.absent(), + this.error = const Value.absent(), + required bool done, + this.createTime = const Value.absent(), + this.fullResourceName = const Value.absent(), + this.ownerType = const Value.absent(), + this.ownerId = const Value.absent(), + this.resourceType = const Value.absent(), + this.resourceId = const Value.absent(), + this.rowid = const Value.absent(), + }) : id = Value(id), + done = Value(done); + static Insertable custom({ + Expression? id, + Expression? metadata, + Expression? response, + Expression? error, + Expression? done, + Expression? createTime, + Expression? fullResourceName, + Expression? ownerType, + Expression? ownerId, + Expression? resourceType, + Expression? resourceId, + Expression? rowid, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (metadata != null) 'metadata': metadata, + if (response != null) 'response': response, + if (error != null) 'error': error, + if (done != null) 'done': done, + if (createTime != null) 'create_time': createTime, + if (fullResourceName != null) 'full_resource_name': fullResourceName, + if (ownerType != null) 'owner_type': ownerType, + if (ownerId != null) 'owner_id': ownerId, + if (resourceType != null) 'resource_type': resourceType, + if (resourceId != null) 'resource_id': resourceId, + if (rowid != null) 'rowid': rowid, + }); + } + + OperationsCompanion copyWith({ + Value? id, + Value? metadata, + Value? response, + Value? error, + Value? done, + Value? createTime, + Value? fullResourceName, + Value? ownerType, + Value? ownerId, + Value? resourceType, + Value? resourceId, + Value? rowid, + }) { + return OperationsCompanion( + id: id ?? this.id, + metadata: metadata ?? this.metadata, + response: response ?? this.response, + error: error ?? this.error, + done: done ?? this.done, + createTime: createTime ?? this.createTime, + fullResourceName: fullResourceName ?? this.fullResourceName, + ownerType: ownerType ?? this.ownerType, + ownerId: ownerId ?? this.ownerId, + resourceType: resourceType ?? this.resourceType, + resourceId: resourceId ?? this.resourceId, + rowid: rowid ?? this.rowid, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (metadata.present) { + map['metadata'] = Variable(metadata.value); + } + if (response.present) { + map['response'] = Variable(response.value); + } + if (error.present) { + map['error'] = Variable(error.value); + } + if (done.present) { + map['done'] = Variable(done.value); + } + if (createTime.present) { + map['create_time'] = Variable(createTime.value); + } + if (fullResourceName.present) { + map['full_resource_name'] = Variable(fullResourceName.value); + } + if (ownerType.present) { + map['owner_type'] = Variable(ownerType.value); + } + if (ownerId.present) { + map['owner_id'] = Variable(ownerId.value); + } + if (resourceType.present) { + map['resource_type'] = Variable(resourceType.value); + } + if (resourceId.present) { + map['resource_id'] = Variable(resourceId.value); + } + if (rowid.present) { + map['rowid'] = Variable(rowid.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('OperationsCompanion(') + ..write('id: $id, ') + ..write('metadata: $metadata, ') + ..write('response: $response, ') + ..write('error: $error, ') + ..write('done: $done, ') + ..write('createTime: $createTime, ') + ..write('fullResourceName: $fullResourceName, ') + ..write('ownerType: $ownerType, ') + ..write('ownerId: $ownerId, ') + ..write('resourceType: $resourceType, ') + ..write('resourceId: $resourceId, ') + ..write('rowid: $rowid') + ..write(')')) + .toString(); + } +} + +class DatabaseAtV2 extends GeneratedDatabase { + DatabaseAtV2(QueryExecutor e) : super(e); + late final CloudAuthUsers cloudAuthUsers = CloudAuthUsers(this); + late final CedarTypes cedarTypes = CedarTypes(this); + late final CedarEntities cedarEntities = CedarEntities(this); + late final Trigger cloudAuthUsersCreateTrg = Trigger( + 'CREATE TRIGGER IF NOT EXISTS cloud_auth_users_create_trg BEFORE INSERT ON cloud_auth_users BEGIN INSERT INTO cedar_entities (entity_type, entity_id) VALUES (\'Celest::User\', NEW.user_id);END', + 'cloud_auth_users_create_trg', + ); + late final CedarRelationships cedarRelationships = CedarRelationships(this); + late final Trigger cloudAuthUsersDeleteTrg = Trigger( + 'CREATE TRIGGER IF NOT EXISTS cloud_auth_users_delete_trg AFTER DELETE ON cloud_auth_users BEGIN DELETE FROM cedar_relationships WHERE(entity_type = \'Celest::User\' AND entity_id = OLD.user_id)OR(parent_type = \'Celest::User\' AND parent_id = OLD.user_id);DELETE FROM cedar_entities WHERE entity_id = OLD.user_id AND entity_type = \'Celest::User\';END', + 'cloud_auth_users_delete_trg', + ); + late final CloudAuthUserEmails cloudAuthUserEmails = CloudAuthUserEmails( + this, + ); + late final CloudAuthUserPhoneNumbers cloudAuthUserPhoneNumbers = + CloudAuthUserPhoneNumbers(this); + late final CloudAuthProjects cloudAuthProjects = CloudAuthProjects(this); + late final CloudAuthApis cloudAuthApis = CloudAuthApis(this); + late final Index cloudAuthApisProjectIdx = Index( + 'cloud_auth_apis_project_idx', + 'CREATE INDEX IF NOT EXISTS cloud_auth_apis_project_idx ON cloud_auth_apis (project_id)', + ); + late final Trigger cloudAuthApisCreateTrg = Trigger( + 'CREATE TRIGGER IF NOT EXISTS cloud_auth_apis_create_trg BEFORE INSERT ON cloud_auth_apis BEGIN INSERT INTO cedar_entities (entity_type, entity_id) VALUES (\'Celest::Api\', NEW.api_id);END', + 'cloud_auth_apis_create_trg', + ); + late final Trigger cloudAuthApisDeleteTrg = Trigger( + 'CREATE TRIGGER IF NOT EXISTS cloud_auth_apis_delete_trg AFTER DELETE ON cloud_auth_apis BEGIN DELETE FROM cedar_relationships WHERE entity_type = \'Celest::Api\' AND entity_id = OLD.api_id;DELETE FROM cedar_relationships WHERE parent_type = \'Celest::Api\' AND parent_id = OLD.api_id;DELETE FROM cedar_entities WHERE entity_type = \'Celest::Api\' AND entity_id = OLD.api_id;END', + 'cloud_auth_apis_delete_trg', + ); + late final CloudAuthFunctions cloudAuthFunctions = CloudAuthFunctions(this); + late final Index cloudAuthFunctionsApiIdx = Index( + 'cloud_auth_functions_api_idx', + 'CREATE INDEX IF NOT EXISTS cloud_auth_functions_api_idx ON cloud_auth_functions (api_id)', + ); + late final Trigger cloudAuthFunctionsCreateTrg = Trigger( + 'CREATE TRIGGER IF NOT EXISTS cloud_auth_functions_create_trg BEFORE INSERT ON cloud_auth_functions BEGIN INSERT INTO cedar_entities (entity_type, entity_id) VALUES (\'Celest::Function\', NEW.function_id);INSERT INTO cedar_relationships (entity_type, entity_id, parent_type, parent_id) VALUES (\'Celest::Function\', NEW.function_id, \'Celest::Api\', NEW.api_id);END', + 'cloud_auth_functions_create_trg', + ); + late final Trigger cloudAuthFunctionsDeleteTrg = Trigger( + 'CREATE TRIGGER IF NOT EXISTS cloud_auth_functions_delete_trg AFTER DELETE ON cloud_auth_functions BEGIN DELETE FROM cedar_relationships WHERE entity_type = \'Celest::Function\' AND entity_id = OLD.function_id;DELETE FROM cedar_relationships WHERE parent_type = \'Celest::Function\' AND parent_id = OLD.function_id;DELETE FROM cedar_entities WHERE entity_type = \'Celest::Function\' AND entity_id = OLD.function_id;END', + 'cloud_auth_functions_delete_trg', + ); + late final CloudAuthMeta cloudAuthMeta = CloudAuthMeta(this); + late final CloudAuthCryptoKeys cloudAuthCryptoKeys = CloudAuthCryptoKeys( + this, + ); + late final Index cloudAuthCryptoKeysExternalCryptoKeyIdIdx = Index( + 'cloud_auth_crypto_keys_external_crypto_key_id_idx', + 'CREATE INDEX IF NOT EXISTS cloud_auth_crypto_keys_external_crypto_key_id_idx ON cloud_auth_crypto_keys (external_crypto_key_id)', + ); + late final CloudAuthSessions cloudAuthSessions = CloudAuthSessions(this); + late final Index cloudAuthSessionsUserIdx = Index( + 'cloud_auth_sessions_user_idx', + 'CREATE INDEX IF NOT EXISTS cloud_auth_sessions_user_idx ON cloud_auth_sessions (user_id)', + ); + late final Index cloudAuthSessionsCryptoKeyIdx = Index( + 'cloud_auth_sessions_crypto_key_idx', + 'CREATE INDEX IF NOT EXISTS cloud_auth_sessions_crypto_key_idx ON cloud_auth_sessions (crypto_key_id)', + ); + late final Index cloudAuthSessionsExternalSessionIdIdx = Index( + 'cloud_auth_sessions_external_session_id_idx', + 'CREATE INDEX IF NOT EXISTS cloud_auth_sessions_external_session_id_idx ON cloud_auth_sessions (external_session_id)', + ); + late final Trigger cloudAuthSessionsUpdateTimeTrg = Trigger( + 'CREATE TRIGGER IF NOT EXISTS cloud_auth_sessions_update_time_trg AFTER UPDATE ON cloud_auth_sessions BEGIN UPDATE cloud_auth_sessions SET update_time = unixepoch(\'now\', \'subsec\') WHERE "rowid" = OLD."rowid";END', + 'cloud_auth_sessions_update_time_trg', + ); + late final CloudAuthOtpCodes cloudAuthOtpCodes = CloudAuthOtpCodes(this); + late final Index cloudAuthOtpCodesSessionIdIdx = Index( + 'cloud_auth_otp_codes_session_id_idx', + 'CREATE INDEX IF NOT EXISTS cloud_auth_otp_codes_session_id_idx ON cloud_auth_otp_codes (session_id)', + ); + late final CloudAuthCorks cloudAuthCorks = CloudAuthCorks(this); + late final Index cloudAuthCorksCryptoKeyIdx = Index( + 'cloud_auth_corks_crypto_key_idx', + 'CREATE INDEX IF NOT EXISTS cloud_auth_corks_crypto_key_idx ON cloud_auth_corks (crypto_key_id)', + ); + late final Index cloudAuthCorksBearerIdx = Index( + 'cloud_auth_corks_bearer_idx', + 'CREATE INDEX IF NOT EXISTS cloud_auth_corks_bearer_idx ON cloud_auth_corks (bearer_type, bearer_id)', + ); + late final Index cloudAuthCorksAudienceIdx = Index( + 'cloud_auth_corks_audience_idx', + 'CREATE INDEX IF NOT EXISTS cloud_auth_corks_audience_idx ON cloud_auth_corks (audience_type, audience_id)', + ); + late final Index cloudAuthCorksIssuerIdx = Index( + 'cloud_auth_corks_issuer_idx', + 'CREATE INDEX IF NOT EXISTS cloud_auth_corks_issuer_idx ON cloud_auth_corks (issuer_type, issuer_id)', + ); + late final Index cedarRelationshipsFkEntityIdx = Index( + 'cedar_relationships_fk_entity_idx', + 'CREATE INDEX IF NOT EXISTS cedar_relationships_fk_entity_idx ON cedar_relationships (entity_type, entity_id)', + ); + late final Index cedarRelationshipsFkParentIdx = Index( + 'cedar_relationships_fk_parent_idx', + 'CREATE INDEX IF NOT EXISTS cedar_relationships_fk_parent_idx ON cedar_relationships (parent_type, parent_id)', + ); + late final CedarPolicies cedarPolicies = CedarPolicies(this); + late final CedarPolicyTemplates cedarPolicyTemplates = CedarPolicyTemplates( + this, + ); + late final CedarPolicyTemplateLinks cedarPolicyTemplateLinks = + CedarPolicyTemplateLinks(this); + late final Index cedarPolicyTemplateLinksFkTemplateIdIdx = Index( + 'cedar_policy_template_links_fk_template_id_idx', + 'CREATE INDEX IF NOT EXISTS cedar_policy_template_links_fk_template_id_idx ON cedar_policy_template_links (template_id)', + ); + late final Index cedarPolicyTemplateLinksFkPrincipalIdx = Index( + 'cedar_policy_template_links_fk_principal_idx', + 'CREATE INDEX IF NOT EXISTS cedar_policy_template_links_fk_principal_idx ON cedar_policy_template_links (principal_type, principal_id)', + ); + late final Index cedarPolicyTemplateLinksFkResourceIdx = Index( + 'cedar_policy_template_links_fk_resource_idx', + 'CREATE INDEX IF NOT EXISTS cedar_policy_template_links_fk_resource_idx ON cedar_policy_template_links (resource_type, resource_id)', + ); + late final CedarAuthorizationLogs cedarAuthorizationLogs = + CedarAuthorizationLogs(this); + late final UserMemberships userMemberships = UserMemberships(this); + late final Index userMembershipsParentIdx = Index( + 'user_memberships_parent_idx', + 'CREATE INDEX IF NOT EXISTS user_memberships_parent_idx ON user_memberships (parent_type, parent_id)', + ); + late final Trigger userMembershipsCreateTrg = Trigger( + 'CREATE TRIGGER IF NOT EXISTS user_memberships_create_trg BEFORE INSERT ON user_memberships BEGIN INSERT INTO cedar_entities (entity_type, entity_id, attribute_json) VALUES (NEW.parent_type || \'::Member\', NEW.membership_id, json_object(\'role\', json_object(\'type\', \'Celest::Role\', \'id\', NEW.role), \'parent\', json_object(\'type\', NEW.parent_type, \'id\', NEW.parent_id)));INSERT INTO cedar_relationships (entity_type, entity_id, parent_type, parent_id) VALUES (\'Celest::User\', NEW.user_id, NEW.parent_type || \'::Member\', NEW.membership_id);END', + 'user_memberships_create_trg', + ); + late final Trigger userMembershipsUpdateTrg = Trigger( + 'CREATE TRIGGER IF NOT EXISTS user_memberships_update_trg AFTER UPDATE ON user_memberships BEGIN UPDATE cedar_entities SET attribute_json = json_object(\'role\', json_object(\'type\', \'Celest::Role\', \'id\', NEW.role), \'parent\', json_object(\'type\', OLD.parent_type, \'id\', OLD.parent_id)) WHERE entity_id = OLD.membership_id AND entity_type = OLD.parent_type || \'::Member\';UPDATE cedar_relationships SET parent_id = NEW.role WHERE entity_id = OLD.membership_id AND entity_type = OLD.parent_type || \'::Member\' AND parent_type = \'Celest::Role\';END', + 'user_memberships_update_trg', + ); + late final Trigger userMembershipsDeleteTrg = Trigger( + 'CREATE TRIGGER IF NOT EXISTS user_memberships_delete_trg AFTER DELETE ON user_memberships BEGIN DELETE FROM cedar_relationships WHERE entity_id = OLD.membership_id AND entity_type = OLD.parent_type || \'::Member\';DELETE FROM cedar_relationships WHERE parent_id = OLD.membership_id AND parent_type = OLD.parent_type || \'::Member\';DELETE FROM cedar_entities WHERE entity_id = OLD.membership_id AND entity_type = OLD.parent_type || \'::Member\';END', + 'user_memberships_delete_trg', + ); + late final Organizations organizations = Organizations(this); + late final Trigger organizationsDeleteUserMembershipsTrg = Trigger( + 'CREATE TRIGGER IF NOT EXISTS organizations_delete_user_memberships_trg AFTER DELETE ON organizations BEGIN DELETE FROM user_memberships WHERE parent_type = \'Celest::Organization\' AND parent_id = OLD.id;END', + 'organizations_delete_user_memberships_trg', + ); + late final Projects projects = Projects(this); + late final Trigger projectsDeleteUserMembershipsTrg = Trigger( + 'CREATE TRIGGER IF NOT EXISTS projects_delete_user_memberships_trg AFTER DELETE ON projects BEGIN DELETE FROM user_memberships WHERE parent_type = \'Celest::Project\' AND parent_id = OLD.id;END', + 'projects_delete_user_memberships_trg', + ); + late final ProjectEnvironments projectEnvironments = ProjectEnvironments( + this, + ); + late final Trigger projectEnvironmentsDeleteUserMembershipsTrg = Trigger( + 'CREATE TRIGGER IF NOT EXISTS project_environments_delete_user_memberships_trg AFTER DELETE ON project_environments BEGIN DELETE FROM user_memberships WHERE parent_type = \'Celest::Project::Environment\' AND parent_id = OLD.id;END', + 'project_environments_delete_user_memberships_trg', + ); + late final Index projectEnvironmentsParentIdx = Index( + 'project_environments_parent_idx', + 'CREATE INDEX IF NOT EXISTS project_environments_parent_idx ON project_environments (parent_type, parent_id)', + ); + late final Trigger projectEnvironmentsUpdateTimeTrg = Trigger( + 'CREATE TRIGGER IF NOT EXISTS project_environments_update_time_trg AFTER UPDATE ON project_environments BEGIN UPDATE project_environments SET update_time = unixepoch(\'now\', \'subsec\') WHERE id = OLD.id;END', + 'project_environments_update_time_trg', + ); + late final Trigger projectEnvironmentsCreateTrg = Trigger( + 'CREATE TRIGGER IF NOT EXISTS project_environments_create_trg BEFORE INSERT ON project_environments BEGIN INSERT INTO cedar_entities (entity_type, entity_id) VALUES (\'Celest::Project::Environment\', NEW.id);INSERT INTO cedar_relationships (entity_type, entity_id, parent_type, parent_id) VALUES (\'Celest::Project::Environment\', NEW.id, NEW.parent_type, NEW.parent_id);END', + 'project_environments_create_trg', + ); + late final Trigger projectEnvironmentsSetParentTrg = Trigger( + 'CREATE TRIGGER IF NOT EXISTS project_environments_set_parent_trg AFTER UPDATE OF parent_type, parent_id ON project_environments WHEN OLD.parent_type != NEW.parent_type OR OLD.parent_id != NEW.parent_id BEGIN UPDATE cedar_relationships SET parent_type = NEW.parent_type, parent_id = NEW.parent_id WHERE entity_id = OLD.id AND entity_type = \'Celest::Project::Environment\';END', + 'project_environments_set_parent_trg', + ); + late final Trigger projectEnvironmentsDeleteTrg = Trigger( + 'CREATE TRIGGER IF NOT EXISTS project_environments_delete_trg AFTER DELETE ON project_environments BEGIN DELETE FROM cedar_relationships WHERE entity_id = OLD.id AND entity_type = \'Celest::Project::Environment\';DELETE FROM cedar_entities WHERE entity_id = OLD.id AND entity_type = \'Celest::Project::Environment\';END', + 'project_environments_delete_trg', + ); + late final ProjectEnvironmentAsts projectEnvironmentAsts = + ProjectEnvironmentAsts(this); + late final ProjectEnvironmentAssets projectEnvironmentAssets = + ProjectEnvironmentAssets(this); + late final ProjectEnvironmentStates projectEnvironmentStates = + ProjectEnvironmentStates(this); + late final Index projectsFkParentIdx = Index( + 'projects_fk_parent_idx', + 'CREATE INDEX IF NOT EXISTS projects_fk_parent_idx ON projects (parent_type, parent_id)', + ); + late final Trigger projectsUpdateTimeTrg = Trigger( + 'CREATE TRIGGER IF NOT EXISTS projects_update_time_trg AFTER UPDATE ON projects BEGIN UPDATE projects SET update_time = unixepoch(\'now\', \'subsec\') WHERE id = OLD.id;END', + 'projects_update_time_trg', + ); + late final Trigger projectsCreateTrg = Trigger( + 'CREATE TRIGGER IF NOT EXISTS projects_create_trg BEFORE INSERT ON projects BEGIN INSERT INTO cedar_entities (entity_type, entity_id) VALUES (\'Celest::Project\', NEW.id);INSERT INTO cedar_relationships (entity_type, entity_id, parent_type, parent_id) VALUES (\'Celest::Project\', NEW.id, NEW.parent_type, NEW.parent_id);END', + 'projects_create_trg', + ); + late final Trigger projectsSetParentTrg = Trigger( + 'CREATE TRIGGER IF NOT EXISTS projects_set_parent_trg AFTER UPDATE OF parent_type, parent_id ON projects WHEN OLD.parent_type != NEW.parent_type OR OLD.parent_id != NEW.parent_id BEGIN UPDATE cedar_relationships SET parent_type = NEW.parent_type, parent_id = NEW.parent_id WHERE entity_id = OLD.id AND entity_type = \'Celest::Project\';END', + 'projects_set_parent_trg', + ); + late final Trigger projectsDeleteTrg = Trigger( + 'CREATE TRIGGER IF NOT EXISTS projects_delete_trg AFTER DELETE ON projects BEGIN DELETE FROM cedar_relationships WHERE entity_type = \'Celest::Project\' AND entity_id = OLD.id;DELETE FROM cedar_relationships WHERE parent_type = \'Celest::Project\' AND parent_id = OLD.id;DELETE FROM cedar_entities WHERE entity_id = OLD.id AND entity_type = \'Celest::Project\';END', + 'projects_delete_trg', + ); + late final Index organizationsParentIdx = Index( + 'organizations_parent_idx', + 'CREATE INDEX IF NOT EXISTS organizations_parent_idx ON organizations (parent_type, parent_id)', + ); + late final Trigger organizationsUpdateTime = Trigger( + 'CREATE TRIGGER IF NOT EXISTS organizations_update_time AFTER UPDATE ON organizations BEGIN UPDATE organizations SET update_time = unixepoch(\'now\', \'subsec\') WHERE id = OLD.id;END', + 'organizations_update_time', + ); + late final Trigger organizationsCreate = Trigger( + 'CREATE TRIGGER IF NOT EXISTS organizations_create BEFORE INSERT ON organizations BEGIN INSERT INTO cedar_entities (entity_type, entity_id) VALUES (\'Celest::Organization\', NEW.id);END', + 'organizations_create', + ); + late final Trigger organizationsCreateParent = Trigger( + 'CREATE TRIGGER IF NOT EXISTS organizations_create_parent AFTER INSERT ON organizations WHEN NEW.parent_id IS NOT NULL BEGIN INSERT INTO cedar_relationships (entity_type, entity_id, parent_type, parent_id) VALUES (\'Celest::Organization\', NEW.id, NEW.parent_type, NEW.parent_id);END', + 'organizations_create_parent', + ); + late final Trigger organizationsAddParent = Trigger( + 'CREATE TRIGGER IF NOT EXISTS organizations_add_parent AFTER UPDATE OF parent_id ON organizations WHEN OLD.parent_id IS NULL AND NEW.parent_id IS NOT NULL BEGIN INSERT INTO cedar_relationships (entity_type, entity_id, parent_type, parent_id) VALUES (\'Celest::Organization\', NEW.id, NEW.parent_type, NEW.parent_id);END', + 'organizations_add_parent', + ); + late final Trigger organizationsSetParent = Trigger( + 'CREATE TRIGGER IF NOT EXISTS organizations_set_parent AFTER UPDATE OF parent_type, parent_id ON organizations WHEN(OLD.parent_type != NEW.parent_type OR OLD.parent_id != NEW.parent_id)AND NEW.parent_id IS NOT NULL BEGIN UPDATE cedar_relationships SET parent_type = NEW.parent_type, parent_id = NEW.parent_id WHERE entity_id = OLD.id AND entity_type = \'Celest::Organization\';END', + 'organizations_set_parent', + ); + late final Trigger organizationsRemoveParent = Trigger( + 'CREATE TRIGGER IF NOT EXISTS organizations_remove_parent AFTER UPDATE OF parent_id ON organizations WHEN OLD.parent_id IS NOT NULL AND NEW.parent_id IS NULL BEGIN DELETE FROM cedar_relationships WHERE entity_id = OLD.id AND entity_type = \'Celest::Organization\' AND parent_id = OLD.parent_id AND parent_type = OLD.parent_type;END', + 'organizations_remove_parent', + ); + late final Trigger organizationsDelete = Trigger( + 'CREATE TRIGGER IF NOT EXISTS organizations_delete AFTER DELETE ON organizations BEGIN DELETE FROM cedar_relationships WHERE entity_type = \'Celest::Organization\' AND entity_id = OLD.id;DELETE FROM cedar_relationships WHERE parent_type = \'Celest::Organization\' AND parent_id = OLD.id;DELETE FROM cedar_entities WHERE entity_type = \'Celest::Organization\' AND entity_id = OLD.id;END', + 'organizations_delete', + ); + late final Operations operations = Operations(this); + late final Index operationsFkOwnerIdx = Index( + 'operations_fk_owner_idx', + 'CREATE INDEX IF NOT EXISTS operations_fk_owner_idx ON operations (owner_type, owner_id)', + ); + late final Index operationsFkResourceIdx = Index( + 'operations_fk_resource_idx', + 'CREATE INDEX IF NOT EXISTS operations_fk_resource_idx ON operations (resource_type, resource_id)', + ); + late final Trigger operationsTriggerCreate = Trigger( + 'CREATE TRIGGER IF NOT EXISTS operations_trigger_create BEFORE INSERT ON operations BEGIN INSERT INTO cedar_entities (entity_type, entity_id) VALUES (\'Celest::Operation\', NEW.id);END', + 'operations_trigger_create', + ); + late final Trigger operationsTriggerCreateOwner = Trigger( + 'CREATE TRIGGER IF NOT EXISTS operations_trigger_create_owner AFTER INSERT ON operations WHEN NEW.owner_id IS NOT NULL BEGIN INSERT INTO cedar_relationships (entity_type, entity_id, parent_type, parent_id) VALUES (\'Celest::Operation\', NEW.id, NEW.owner_type, NEW.owner_id);END', + 'operations_trigger_create_owner', + ); + late final Trigger operationsTriggerCreateResource = Trigger( + 'CREATE TRIGGER IF NOT EXISTS operations_trigger_create_resource AFTER INSERT ON operations WHEN NEW.resource_id IS NOT NULL BEGIN INSERT INTO cedar_relationships (entity_type, entity_id, parent_type, parent_id) VALUES (\'Celest::Operation\', NEW.id, NEW.resource_type, NEW.resource_id);END', + 'operations_trigger_create_resource', + ); + late final Trigger operationsTriggerAddOwner = Trigger( + 'CREATE TRIGGER IF NOT EXISTS operations_trigger_add_owner AFTER UPDATE OF owner_id ON operations WHEN OLD.owner_id IS NULL AND NEW.owner_id IS NOT NULL BEGIN INSERT INTO cedar_relationships (entity_type, entity_id, parent_type, parent_id) VALUES (\'Celest::Operation\', NEW.id, NEW.owner_type, NEW.owner_id);END', + 'operations_trigger_add_owner', + ); + late final Trigger operationsTriggerAddResource = Trigger( + 'CREATE TRIGGER IF NOT EXISTS operations_trigger_add_resource AFTER UPDATE OF resource_id ON operations WHEN OLD.resource_id IS NULL AND NEW.resource_id IS NOT NULL BEGIN INSERT INTO cedar_relationships (entity_type, entity_id, parent_type, parent_id) VALUES (\'Celest::Operation\', NEW.id, NEW.resource_type, NEW.resource_id);END', + 'operations_trigger_add_resource', + ); + late final Trigger operationsTriggerSetOwner = Trigger( + 'CREATE TRIGGER IF NOT EXISTS operations_trigger_set_owner AFTER UPDATE OF owner_type, owner_id ON operations WHEN(OLD.owner_type != NEW.owner_type OR OLD.owner_id != NEW.owner_id)AND OLD.owner_id IS NOT NULL AND NEW.owner_id IS NOT NULL BEGIN UPDATE cedar_relationships SET parent_type = NEW.owner_type, parent_id = NEW.owner_id WHERE entity_id = OLD.id AND entity_type = \'Celest::Operation\' AND parent_type = OLD.owner_type AND parent_id = OLD.owner_id;END', + 'operations_trigger_set_owner', + ); + late final Trigger operationsTriggerSetResource = Trigger( + 'CREATE TRIGGER IF NOT EXISTS operations_trigger_set_resource AFTER UPDATE OF resource_type, resource_id ON operations WHEN(OLD.resource_type != NEW.resource_type OR OLD.resource_id != NEW.resource_id)AND OLD.resource_id IS NOT NULL AND NEW.resource_id IS NOT NULL BEGIN UPDATE cedar_relationships SET parent_type = NEW.resource_type, parent_id = NEW.resource_id WHERE entity_id = OLD.id AND entity_type = \'Celest::Operation\' AND parent_type = OLD.resource_type AND parent_id = OLD.resource_id;END', + 'operations_trigger_set_resource', + ); + late final Trigger operationsTriggerDelete = Trigger( + 'CREATE TRIGGER IF NOT EXISTS operations_trigger_delete AFTER DELETE ON operations BEGIN DELETE FROM cedar_relationships WHERE entity_id = OLD.id AND entity_type = \'Celest::Operation\';DELETE FROM cedar_entities WHERE entity_id = OLD.id AND entity_type = \'Celest::Operation\';END', + 'operations_trigger_delete', + ); + @override + Iterable> get allTables => + allSchemaEntities.whereType>(); + @override + List get allSchemaEntities => [ + cloudAuthUsers, + cedarTypes, + cedarEntities, + cloudAuthUsersCreateTrg, + cedarRelationships, + cloudAuthUsersDeleteTrg, + cloudAuthUserEmails, + cloudAuthUserPhoneNumbers, + cloudAuthProjects, + cloudAuthApis, + cloudAuthApisProjectIdx, + cloudAuthApisCreateTrg, + cloudAuthApisDeleteTrg, + cloudAuthFunctions, + cloudAuthFunctionsApiIdx, + cloudAuthFunctionsCreateTrg, + cloudAuthFunctionsDeleteTrg, + cloudAuthMeta, + cloudAuthCryptoKeys, + cloudAuthCryptoKeysExternalCryptoKeyIdIdx, + cloudAuthSessions, + cloudAuthSessionsUserIdx, + cloudAuthSessionsCryptoKeyIdx, + cloudAuthSessionsExternalSessionIdIdx, + cloudAuthSessionsUpdateTimeTrg, + cloudAuthOtpCodes, + cloudAuthOtpCodesSessionIdIdx, + cloudAuthCorks, + cloudAuthCorksCryptoKeyIdx, + cloudAuthCorksBearerIdx, + cloudAuthCorksAudienceIdx, + cloudAuthCorksIssuerIdx, + cedarRelationshipsFkEntityIdx, + cedarRelationshipsFkParentIdx, + cedarPolicies, + cedarPolicyTemplates, + cedarPolicyTemplateLinks, + cedarPolicyTemplateLinksFkTemplateIdIdx, + cedarPolicyTemplateLinksFkPrincipalIdx, + cedarPolicyTemplateLinksFkResourceIdx, + cedarAuthorizationLogs, + userMemberships, + userMembershipsParentIdx, + userMembershipsCreateTrg, + userMembershipsUpdateTrg, + userMembershipsDeleteTrg, + organizations, + organizationsDeleteUserMembershipsTrg, + projects, + projectsDeleteUserMembershipsTrg, + projectEnvironments, + projectEnvironmentsDeleteUserMembershipsTrg, + projectEnvironmentsParentIdx, + projectEnvironmentsUpdateTimeTrg, + projectEnvironmentsCreateTrg, + projectEnvironmentsSetParentTrg, + projectEnvironmentsDeleteTrg, + projectEnvironmentAsts, + projectEnvironmentAssets, + projectEnvironmentStates, + projectsFkParentIdx, + projectsUpdateTimeTrg, + projectsCreateTrg, + projectsSetParentTrg, + projectsDeleteTrg, + organizationsParentIdx, + organizationsUpdateTime, + organizationsCreate, + organizationsCreateParent, + organizationsAddParent, + organizationsSetParent, + organizationsRemoveParent, + organizationsDelete, + operations, + operationsFkOwnerIdx, + operationsFkResourceIdx, + operationsTriggerCreate, + operationsTriggerCreateOwner, + operationsTriggerCreateResource, + operationsTriggerAddOwner, + operationsTriggerAddResource, + operationsTriggerSetOwner, + operationsTriggerSetResource, + operationsTriggerDelete, + ]; + @override + StreamQueryUpdateRules get streamUpdateRules => const StreamQueryUpdateRules([ + WritePropagation( + on: TableUpdateQuery.onTableName( + 'cloud_auth_users', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'cloud_auth_users', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'cloud_auth_apis', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'cloud_auth_apis', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'cloud_auth_functions', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'cloud_auth_functions', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'cloud_auth_sessions', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'user_memberships', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'user_memberships', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'user_memberships', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'organizations', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'projects', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'project_environments', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'project_environments', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'project_environments', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'project_environments', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'project_environments', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'projects', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'projects', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'projects', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'projects', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'organizations', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'organizations', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'organizations', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'organizations', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'organizations', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'organizations', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'organizations', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'operations', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'operations', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'operations', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'operations', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'operations', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'operations', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'operations', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + WritePropagation( + on: TableUpdateQuery.onTableName( + 'operations', + limitUpdateKind: UpdateKind.delete, + ), + result: [], + ), + ]); + @override + int get schemaVersion => 2; +} diff --git a/services/celest_cloud_hub/test/database/cloud_hub_database/migration_test.dart b/services/celest_cloud_hub/test/database/cloud_hub_database/migration_test.dart new file mode 100644 index 000000000..5fb6f4515 --- /dev/null +++ b/services/celest_cloud_hub/test/database/cloud_hub_database/migration_test.dart @@ -0,0 +1,49 @@ +// dart format width=80 +// ignore_for_file: unused_local_variable, unused_import +import 'package:celest_cloud_hub/src/context.dart'; +import 'package:celest_cloud_hub/src/database/cloud_hub_database.dart'; +import 'package:celest_cloud_hub/src/database/db_functions.dart'; +import 'package:celest_cloud_hub/src/project.dart'; +import 'package:drift/drift.dart'; +import 'package:drift_dev/api/migrations_native.dart'; +import 'package:logging/logging.dart'; +import 'package:test/test.dart'; + +import 'generated/schema.dart'; +import 'generated/schema_v1.dart' as v1; +import 'generated/schema_v2.dart' as v2; + +void main() { + driftRuntimeOptions.dontWarnAboutMultipleDatabases = true; + late SchemaVerifier verifier; + + Logger.root.level = Level.ALL; + Logger.root.onRecord.listen((record) { + print( + '[${record.loggerName.split('.').last}] ${record.level}: ${record.message}', + ); + }); + + setUpAll(() { + verifier = SchemaVerifier( + GeneratedHelper(), + setup: (db) => db.addHelperFunctions(), + ); + }); + + group('simple database migrations', () { + const versions = GeneratedHelper.versions; + for (final (i, fromVersion) in versions.indexed) { + group('from $fromVersion', () { + for (final toVersion in versions.skip(i + 1)) { + test('to $toVersion', () async { + final schema = await verifier.schemaAt(fromVersion); + final db = CloudHubDatabase(schema.newConnection()); + await verifier.migrateAndValidate(db, toVersion); + await db.close(); + }); + } + }); + } + }); +} diff --git a/services/celest_cloud_hub/test/deploy/fly_deployment_engine_test.dart b/services/celest_cloud_hub/test/deploy/fly_deployment_engine_test.dart new file mode 100644 index 000000000..05662ea14 --- /dev/null +++ b/services/celest_cloud_hub/test/deploy/fly_deployment_engine_test.dart @@ -0,0 +1,182 @@ +@Timeout.none +library; + +import 'dart:io'; + +import 'package:celest_ast/celest_ast.dart' as ast; +import 'package:celest_cli/src/sdk/sdk_finder.dart'; +import 'package:celest_cloud/celest_cloud.dart' show ProjectAsset_Type; +import 'package:celest_cloud_hub/src/context.dart'; +import 'package:celest_cloud_hub/src/database/cloud_hub_database.dart'; +import 'package:celest_cloud_hub/src/deploy/fly/fly_api.dart'; +import 'package:celest_cloud_hub/src/deploy/fly/fly_deployment_engine.dart'; +import 'package:celest_cloud_hub/src/services/service_mixin.dart'; +import 'package:crypto/crypto.dart'; +import 'package:file/local.dart'; +import 'package:logging/logging.dart'; +import 'package:process/process.dart'; +import 'package:pub_semver/pub_semver.dart'; +import 'package:test/test.dart'; + +void main() { + Logger.root.level = Level.ALL; + Logger.root.onRecord.listen((record) { + print( + '[${record.loggerName.split('.').last}] ${record.level}: ${record.message}', + ); + }); + + const processManager = LocalProcessManager(); + const fileSystem = LocalFileSystem(); + + final hasAccessToken = Platform.environment.containsKey('FLY_API_TOKEN'); + + test('FlyDeploymentEngine', skip: !hasAccessToken, () async { + addTearDown(context.httpClient.close); + + const sdkFinder = DartSdkFinder(); + final sdk = (await sdkFinder.findSdk()).sdk; + + const helloWorld = r''' +import 'dart:io'; + +Future main() async { + final port = int.parse(Platform.environment['PORT'] ?? '8080'); + final server = await HttpServer.bind(InternetAddress.anyIPv4, port); + print('Listening on http://localhost:$port'); + await for (final request in server) { + request.response.write('Hello, world!'); + await request.response.close(); + } +} +'''; + + final tmpDir = + fileSystem.systemTempDirectory.createTempSync('celest_').path; + await fileSystem + .directory(tmpDir) + .childFile('hello_world.dart') + .writeAsString(helloWorld); + addTearDown(() async { + try { + await fileSystem.directory(tmpDir).delete(recursive: true); + } on Object { + // OK + } + }); + + print('Compiling server'); + final res = await processManager.run([ + sdk.dartAotRuntime, + sdk.frontendServerAotSnapshot, + '--sdk-root', + sdk.sdkPath, + '--platform', + sdk.vmPlatformProductDill, + '--aot', + '--tfa', + '--no-support-mirrors', + '--link-platform', + '--target=vm', + '-Ddart.vm.product=true', + '--output-dill=$tmpDir/celest.aot.dill', + '$tmpDir/hello_world.dart', + ]); + if (res.exitCode != 0) { + fail('Failed to compile hello_world.dart:\n${res.stderr}'); + } + final bytes = + await fileSystem.file('$tmpDir/celest.aot.dill').readAsBytes(); + + final db = CloudHubDatabase.memory(); + addTearDown(db.close); + + print('Creating organization'); + final orgId = typeId('org'); + await db.organizationsDrift.createOrganization( + id: orgId, + organizationId: 'my-org', + state: 'ACTIVE', + displayName: 'My Organization', + ); + + print('Creating project'); + final projectId = typeId('prj'); + await db.projectsDrift.createProject( + id: projectId, + parentType: 'Celest::Organization', + parentId: orgId, + projectId: 'my-project', + state: 'ACTIVE', + regions: '', + ); + + print('Creating environment'); + final environmentId = typeId('env'); + final environment = + (await db.projectEnvironmentsDrift.createProjectEnvironment( + id: environmentId, + parentType: 'Celest::Project', + parentId: projectId, + projectEnvironmentId: 'production', + state: 'CREATING', + )).first; + + final deploymentEngine = FlyDeploymentEngine( + db: db, + projectAst: ast.ResolvedProject( + projectId: 'my-project', + environmentId: 'production', + sdkConfig: ast.SdkConfiguration( + celest: Version(1, 0, 9), + dart: ast.Sdk(type: ast.SdkType.dart, version: sdk.version), + ), + ), + environment: environment, + kernelAsset: ( + type: ProjectAsset_Type.DART_KERNEL, + inline: bytes, + filename: 'main.aot.dill', + etag: md5.convert(bytes).toString(), + ), + flutterAssetsBundle: null, + ); + + print('Deploying'); + final state = await deploymentEngine.deploy(); + + await expectLater( + context.fly.apps.show(appName: state.flyAppName!), + completion(isA()), + ); + await expectLater( + context.fly.volumes.getById( + appName: state.flyAppName!, + volumeId: state.flyVolumeId!, + ), + completion(isA()), + ); + + final uri = Uri.parse('https://${state.domainName}'); + final response = await context.httpClient.get(uri); + if (response.statusCode != 200) { + fail('Bad response: ${response.statusCode} ${response.body}'); + } + + await context.fly.apps.delete(appName: state.flyAppName!); + + print('Waiting for app to be deleted'); + await Future.delayed(const Duration(seconds: 10)); + await expectLater( + context.fly.apps.show(appName: state.flyAppName!), + throwsA(isA()), + ); + await expectLater( + context.fly.volumes.getById( + appName: state.flyAppName!, + volumeId: state.flyVolumeId!, + ), + throwsA(isA()), + ); + }); +} diff --git a/services/celest_cloud_hub/test/services/operations_service_e2e_test.dart b/services/celest_cloud_hub/test/services/operations_service_e2e_test.dart index ebecae659..e083850f0 100644 --- a/services/celest_cloud_hub/test/services/operations_service_e2e_test.dart +++ b/services/celest_cloud_hub/test/services/operations_service_e2e_test.dart @@ -1,3 +1,6 @@ +@Tags(['e2e']) +library; + import 'dart:async'; import 'dart:convert'; import 'dart:io'; diff --git a/services/celest_cloud_hub/test/services/operations_service_test.dart b/services/celest_cloud_hub/test/services/operations_service_test.dart index 8f36cd6fb..0fa702358 100644 --- a/services/celest_cloud_hub/test/services/operations_service_test.dart +++ b/services/celest_cloud_hub/test/services/operations_service_test.dart @@ -1,6 +1,5 @@ import 'dart:async'; import 'dart:convert'; -import 'dart:io'; import 'dart:typed_data'; import 'package:cedar/src/model/value.dart'; @@ -188,8 +187,7 @@ void main() { expect(result.hasNextPageToken(), isFalse); }); - // TODO(dnys1): Get working in CI - test('paginated', skip: Platform.environment.containsKey('CI'), () async { + test('paginated', timeout: Timeout.factor(2), () async { const numItems = 35; for (var i = 0; i < numItems; i++) { await database.operationsDrift.createOperation( diff --git a/services/celest_cloud_hub/test/services/organizations_service_e2e_test.dart b/services/celest_cloud_hub/test/services/organizations_service_e2e_test.dart index aeec472af..8eeb6d734 100644 --- a/services/celest_cloud_hub/test/services/organizations_service_e2e_test.dart +++ b/services/celest_cloud_hub/test/services/organizations_service_e2e_test.dart @@ -1,3 +1,6 @@ +@Tags(['e2e']) +library; + import 'dart:async'; import 'package:cedar/src/model/value.dart'; diff --git a/services/celest_cloud_hub/test/services/organizations_service_test.dart b/services/celest_cloud_hub/test/services/organizations_service_test.dart index 3e872a85a..f1ba5a154 100644 --- a/services/celest_cloud_hub/test/services/organizations_service_test.dart +++ b/services/celest_cloud_hub/test/services/organizations_service_test.dart @@ -180,7 +180,7 @@ void main() { expect(result.hasNextPageToken(), isFalse); }); - test('paginated', () async { + test('paginated', timeout: Timeout.factor(2), () async { const numItems = 35; for (var i = 0; i < numItems; i++) { await service.createOrganization( diff --git a/services/celest_cloud_hub/test/services/project_environments_service_e2e_test.dart b/services/celest_cloud_hub/test/services/project_environments_service_e2e_test.dart index b701df7c1..a5b8f8243 100644 --- a/services/celest_cloud_hub/test/services/project_environments_service_e2e_test.dart +++ b/services/celest_cloud_hub/test/services/project_environments_service_e2e_test.dart @@ -1,3 +1,6 @@ +@Tags(['e2e']) +library; + import 'dart:async'; import 'package:cedar/src/model/value.dart'; diff --git a/services/celest_cloud_hub/test/services/project_environments_service_test.dart b/services/celest_cloud_hub/test/services/project_environments_service_test.dart index 832ba51ac..1e4c3b769 100644 --- a/services/celest_cloud_hub/test/services/project_environments_service_test.dart +++ b/services/celest_cloud_hub/test/services/project_environments_service_test.dart @@ -247,7 +247,7 @@ void main() { expect(result.hasNextPageToken(), isFalse); }); - test('paginated', () async { + test('paginated', timeout: Timeout.factor(2), () async { const numItems = 35; for (var i = 0; i < numItems; i++) { await service.createProjectEnvironment( diff --git a/services/celest_cloud_hub/test/services/projects_service_e2e_test.dart b/services/celest_cloud_hub/test/services/projects_service_e2e_test.dart index 3f40fee69..d18980a9b 100644 --- a/services/celest_cloud_hub/test/services/projects_service_e2e_test.dart +++ b/services/celest_cloud_hub/test/services/projects_service_e2e_test.dart @@ -1,3 +1,6 @@ +@Tags(['e2e']) +library; + import 'dart:async'; import 'dart:convert'; diff --git a/services/celest_cloud_hub/test/services/projects_service_test.dart b/services/celest_cloud_hub/test/services/projects_service_test.dart index 094db039f..3f4f5a8ae 100644 --- a/services/celest_cloud_hub/test/services/projects_service_test.dart +++ b/services/celest_cloud_hub/test/services/projects_service_test.dart @@ -263,7 +263,7 @@ void main() { expect(result.hasNextPageToken(), isFalse); }); - test('paginated', () async { + test('paginated', timeout: Timeout.factor(2), () async { // First create an organization final orgRequest = CreateOrganizationRequest( organizationId: 'test-org',