Implemented Epic 1 core kernel and infrastructure stories: Story 1.1: Enhanced DI Container - Added providers for database, health, metrics, and error bus - Extended CoreModule to include all core services Story 1.2: Database Layer with Ent ORM - Created Ent schema for User, Role, Permission, AuditLog entities - Implemented many-to-many relationships (User-Role, Role-Permission) - Created database client wrapper with connection pooling - Added database provider to DI container with migration support Story 1.3: Health Monitoring and Metrics System - Implemented health check registry and interface - Added database health checker - Created Prometheus metrics system with HTTP instrumentation - Added health and metrics providers to DI container Story 1.4: Error Handling and Error Bus - Implemented channel-based error bus - Created ErrorPublisher interface - Added error bus provider with lifecycle management Story 1.5: HTTP Server Foundation - Created HTTP server with Gin framework - Implemented comprehensive middleware stack: - Request ID generation - Structured logging - Panic recovery with error bus integration - Prometheus metrics collection - CORS support - Registered core routes: /healthz, /ready, /metrics - Integrated with FX lifecycle for graceful shutdown All components are integrated via DI container and ready for use.
188 lines
6.4 KiB
Go
188 lines
6.4 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package migrate
|
|
|
|
import (
|
|
"entgo.io/ent/dialect/sql/schema"
|
|
"entgo.io/ent/schema/field"
|
|
)
|
|
|
|
var (
|
|
// AuditLogsColumns holds the columns for the "audit_logs" table.
|
|
AuditLogsColumns = []*schema.Column{
|
|
{Name: "id", Type: field.TypeString, Unique: true},
|
|
{Name: "actor_id", Type: field.TypeString},
|
|
{Name: "action", Type: field.TypeString},
|
|
{Name: "target_id", Type: field.TypeString, Nullable: true},
|
|
{Name: "metadata", Type: field.TypeJSON, Nullable: true},
|
|
{Name: "timestamp", Type: field.TypeTime},
|
|
}
|
|
// AuditLogsTable holds the schema information for the "audit_logs" table.
|
|
AuditLogsTable = &schema.Table{
|
|
Name: "audit_logs",
|
|
Columns: AuditLogsColumns,
|
|
PrimaryKey: []*schema.Column{AuditLogsColumns[0]},
|
|
Indexes: []*schema.Index{
|
|
{
|
|
Name: "auditlog_actor_id",
|
|
Unique: false,
|
|
Columns: []*schema.Column{AuditLogsColumns[1]},
|
|
},
|
|
{
|
|
Name: "auditlog_target_id",
|
|
Unique: false,
|
|
Columns: []*schema.Column{AuditLogsColumns[3]},
|
|
},
|
|
{
|
|
Name: "auditlog_timestamp",
|
|
Unique: false,
|
|
Columns: []*schema.Column{AuditLogsColumns[5]},
|
|
},
|
|
{
|
|
Name: "auditlog_action",
|
|
Unique: false,
|
|
Columns: []*schema.Column{AuditLogsColumns[2]},
|
|
},
|
|
},
|
|
}
|
|
// PermissionsColumns holds the columns for the "permissions" table.
|
|
PermissionsColumns = []*schema.Column{
|
|
{Name: "id", Type: field.TypeString, Unique: true},
|
|
{Name: "name", Type: field.TypeString, Unique: true},
|
|
}
|
|
// PermissionsTable holds the schema information for the "permissions" table.
|
|
PermissionsTable = &schema.Table{
|
|
Name: "permissions",
|
|
Columns: PermissionsColumns,
|
|
PrimaryKey: []*schema.Column{PermissionsColumns[0]},
|
|
}
|
|
// RolesColumns holds the columns for the "roles" table.
|
|
RolesColumns = []*schema.Column{
|
|
{Name: "id", Type: field.TypeString, Unique: true},
|
|
{Name: "name", Type: field.TypeString, Unique: true},
|
|
{Name: "description", Type: field.TypeString, Nullable: true},
|
|
{Name: "created_at", Type: field.TypeTime},
|
|
}
|
|
// RolesTable holds the schema information for the "roles" table.
|
|
RolesTable = &schema.Table{
|
|
Name: "roles",
|
|
Columns: RolesColumns,
|
|
PrimaryKey: []*schema.Column{RolesColumns[0]},
|
|
}
|
|
// RolePermissionsColumns holds the columns for the "role_permissions" table.
|
|
RolePermissionsColumns = []*schema.Column{
|
|
{Name: "id", Type: field.TypeInt, Increment: true},
|
|
{Name: "permission_role_permissions", Type: field.TypeString, Nullable: true},
|
|
{Name: "role_role_permissions", Type: field.TypeString, Nullable: true},
|
|
{Name: "role_id", Type: field.TypeString},
|
|
{Name: "permission_id", Type: field.TypeString},
|
|
}
|
|
// RolePermissionsTable holds the schema information for the "role_permissions" table.
|
|
RolePermissionsTable = &schema.Table{
|
|
Name: "role_permissions",
|
|
Columns: RolePermissionsColumns,
|
|
PrimaryKey: []*schema.Column{RolePermissionsColumns[0]},
|
|
ForeignKeys: []*schema.ForeignKey{
|
|
{
|
|
Symbol: "role_permissions_permissions_role_permissions",
|
|
Columns: []*schema.Column{RolePermissionsColumns[1]},
|
|
RefColumns: []*schema.Column{PermissionsColumns[0]},
|
|
OnDelete: schema.SetNull,
|
|
},
|
|
{
|
|
Symbol: "role_permissions_roles_role_permissions",
|
|
Columns: []*schema.Column{RolePermissionsColumns[2]},
|
|
RefColumns: []*schema.Column{RolesColumns[0]},
|
|
OnDelete: schema.SetNull,
|
|
},
|
|
{
|
|
Symbol: "role_permissions_roles_role",
|
|
Columns: []*schema.Column{RolePermissionsColumns[3]},
|
|
RefColumns: []*schema.Column{RolesColumns[0]},
|
|
OnDelete: schema.NoAction,
|
|
},
|
|
{
|
|
Symbol: "role_permissions_permissions_permission",
|
|
Columns: []*schema.Column{RolePermissionsColumns[4]},
|
|
RefColumns: []*schema.Column{PermissionsColumns[0]},
|
|
OnDelete: schema.NoAction,
|
|
},
|
|
},
|
|
}
|
|
// UsersColumns holds the columns for the "users" table.
|
|
UsersColumns = []*schema.Column{
|
|
{Name: "id", Type: field.TypeString, Unique: true},
|
|
{Name: "email", Type: field.TypeString, Unique: true},
|
|
{Name: "password_hash", Type: field.TypeString},
|
|
{Name: "verified", Type: field.TypeBool, Default: false},
|
|
{Name: "created_at", Type: field.TypeTime},
|
|
{Name: "updated_at", Type: field.TypeTime},
|
|
}
|
|
// UsersTable holds the schema information for the "users" table.
|
|
UsersTable = &schema.Table{
|
|
Name: "users",
|
|
Columns: UsersColumns,
|
|
PrimaryKey: []*schema.Column{UsersColumns[0]},
|
|
}
|
|
// UserRolesColumns holds the columns for the "user_roles" table.
|
|
UserRolesColumns = []*schema.Column{
|
|
{Name: "id", Type: field.TypeInt, Increment: true},
|
|
{Name: "role_user_roles", Type: field.TypeString, Nullable: true},
|
|
{Name: "user_user_roles", Type: field.TypeString, Nullable: true},
|
|
{Name: "user_id", Type: field.TypeString},
|
|
{Name: "role_id", Type: field.TypeString},
|
|
}
|
|
// UserRolesTable holds the schema information for the "user_roles" table.
|
|
UserRolesTable = &schema.Table{
|
|
Name: "user_roles",
|
|
Columns: UserRolesColumns,
|
|
PrimaryKey: []*schema.Column{UserRolesColumns[0]},
|
|
ForeignKeys: []*schema.ForeignKey{
|
|
{
|
|
Symbol: "user_roles_roles_user_roles",
|
|
Columns: []*schema.Column{UserRolesColumns[1]},
|
|
RefColumns: []*schema.Column{RolesColumns[0]},
|
|
OnDelete: schema.SetNull,
|
|
},
|
|
{
|
|
Symbol: "user_roles_users_user_roles",
|
|
Columns: []*schema.Column{UserRolesColumns[2]},
|
|
RefColumns: []*schema.Column{UsersColumns[0]},
|
|
OnDelete: schema.SetNull,
|
|
},
|
|
{
|
|
Symbol: "user_roles_users_user",
|
|
Columns: []*schema.Column{UserRolesColumns[3]},
|
|
RefColumns: []*schema.Column{UsersColumns[0]},
|
|
OnDelete: schema.NoAction,
|
|
},
|
|
{
|
|
Symbol: "user_roles_roles_role",
|
|
Columns: []*schema.Column{UserRolesColumns[4]},
|
|
RefColumns: []*schema.Column{RolesColumns[0]},
|
|
OnDelete: schema.NoAction,
|
|
},
|
|
},
|
|
}
|
|
// Tables holds all the tables in the schema.
|
|
Tables = []*schema.Table{
|
|
AuditLogsTable,
|
|
PermissionsTable,
|
|
RolesTable,
|
|
RolePermissionsTable,
|
|
UsersTable,
|
|
UserRolesTable,
|
|
}
|
|
)
|
|
|
|
func init() {
|
|
RolePermissionsTable.ForeignKeys[0].RefTable = PermissionsTable
|
|
RolePermissionsTable.ForeignKeys[1].RefTable = RolesTable
|
|
RolePermissionsTable.ForeignKeys[2].RefTable = RolesTable
|
|
RolePermissionsTable.ForeignKeys[3].RefTable = PermissionsTable
|
|
UserRolesTable.ForeignKeys[0].RefTable = RolesTable
|
|
UserRolesTable.ForeignKeys[1].RefTable = UsersTable
|
|
UserRolesTable.ForeignKeys[2].RefTable = UsersTable
|
|
UserRolesTable.ForeignKeys[3].RefTable = RolesTable
|
|
}
|