feat(ui): add relationship management features in schema editor
- Implement functionality to create, update, delete, and view relationships between tables. - Introduce new UI screens for managing relationships, including forms for adding and editing relationships. - Enhance table editor with navigation to relationship management. - Ensure relationships are displayed in a structured table format for better usability.
This commit is contained in:
53
pkg/readers/doc.go
Normal file
53
pkg/readers/doc.go
Normal file
@@ -0,0 +1,53 @@
|
||||
// Package readers provides interfaces and implementations for reading database schemas
|
||||
// from various input formats and data sources.
|
||||
//
|
||||
// # Overview
|
||||
//
|
||||
// The readers package defines a common Reader interface that all format-specific readers
|
||||
// implement. This allows RelSpec to read database schemas from multiple sources including:
|
||||
// - Live databases (PostgreSQL, SQLite)
|
||||
// - Schema definition files (DBML, DCTX, DrawDB, GraphQL)
|
||||
// - ORM model files (GORM, Bun, Drizzle, Prisma, TypeORM)
|
||||
// - Data interchange formats (JSON, YAML)
|
||||
//
|
||||
// # Architecture
|
||||
//
|
||||
// Each reader implementation is located in its own subpackage (e.g., pkg/readers/dbml,
|
||||
// pkg/readers/pgsql) and implements the Reader interface, supporting three levels of
|
||||
// granularity:
|
||||
// - ReadDatabase() - Read complete database with all schemas
|
||||
// - ReadSchema() - Read single schema with all tables
|
||||
// - ReadTable() - Read single table with all columns and metadata
|
||||
//
|
||||
// # Usage
|
||||
//
|
||||
// Readers are instantiated with ReaderOptions containing source-specific configuration:
|
||||
//
|
||||
// // Read from file
|
||||
// reader := dbml.NewReader(&readers.ReaderOptions{
|
||||
// FilePath: "schema.dbml",
|
||||
// })
|
||||
// db, err := reader.ReadDatabase()
|
||||
//
|
||||
// // Read from database
|
||||
// reader := pgsql.NewReader(&readers.ReaderOptions{
|
||||
// ConnectionString: "postgres://user:pass@localhost/mydb",
|
||||
// })
|
||||
// db, err := reader.ReadDatabase()
|
||||
//
|
||||
// # Supported Formats
|
||||
//
|
||||
// - dbml: Database Markup Language files
|
||||
// - dctx: DCTX schema files
|
||||
// - drawdb: DrawDB JSON format
|
||||
// - graphql: GraphQL schema definition language
|
||||
// - json: JSON database schema
|
||||
// - yaml: YAML database schema
|
||||
// - gorm: Go GORM model structs
|
||||
// - bun: Go Bun model structs
|
||||
// - drizzle: TypeScript Drizzle ORM schemas
|
||||
// - prisma: Prisma schema language
|
||||
// - typeorm: TypeScript TypeORM entities
|
||||
// - pgsql: PostgreSQL live database introspection
|
||||
// - sqlite: SQLite database files
|
||||
package readers
|
||||
@@ -106,7 +106,7 @@ func (r *Reader) queryColumns(tableName string) (map[string]*models.Column, erro
|
||||
}
|
||||
|
||||
// Check for autoincrement (SQLite uses INTEGER PRIMARY KEY AUTOINCREMENT)
|
||||
if pk > 0 && strings.ToUpper(dataType) == "INTEGER" {
|
||||
if pk > 0 && strings.EqualFold(dataType, "INTEGER") {
|
||||
column.AutoIncrement = r.isAutoIncrement(tableName, name)
|
||||
}
|
||||
|
||||
|
||||
@@ -187,35 +187,35 @@ func (r *Reader) close() {
|
||||
func (r *Reader) mapDataType(sqliteType string) string {
|
||||
// SQLite has a flexible type system, but we map common types
|
||||
typeMap := map[string]string{
|
||||
"INTEGER": "int",
|
||||
"INT": "int",
|
||||
"TINYINT": "int8",
|
||||
"SMALLINT": "int16",
|
||||
"MEDIUMINT": "int",
|
||||
"BIGINT": "int64",
|
||||
"UNSIGNED BIG INT": "uint64",
|
||||
"INT2": "int16",
|
||||
"INT8": "int64",
|
||||
"REAL": "float64",
|
||||
"DOUBLE": "float64",
|
||||
"DOUBLE PRECISION": "float64",
|
||||
"FLOAT": "float32",
|
||||
"NUMERIC": "decimal",
|
||||
"DECIMAL": "decimal",
|
||||
"BOOLEAN": "bool",
|
||||
"BOOL": "bool",
|
||||
"DATE": "date",
|
||||
"DATETIME": "timestamp",
|
||||
"TIMESTAMP": "timestamp",
|
||||
"TEXT": "string",
|
||||
"VARCHAR": "string",
|
||||
"CHAR": "string",
|
||||
"CHARACTER": "string",
|
||||
"INTEGER": "int",
|
||||
"INT": "int",
|
||||
"TINYINT": "int8",
|
||||
"SMALLINT": "int16",
|
||||
"MEDIUMINT": "int",
|
||||
"BIGINT": "int64",
|
||||
"UNSIGNED BIG INT": "uint64",
|
||||
"INT2": "int16",
|
||||
"INT8": "int64",
|
||||
"REAL": "float64",
|
||||
"DOUBLE": "float64",
|
||||
"DOUBLE PRECISION": "float64",
|
||||
"FLOAT": "float32",
|
||||
"NUMERIC": "decimal",
|
||||
"DECIMAL": "decimal",
|
||||
"BOOLEAN": "bool",
|
||||
"BOOL": "bool",
|
||||
"DATE": "date",
|
||||
"DATETIME": "timestamp",
|
||||
"TIMESTAMP": "timestamp",
|
||||
"TEXT": "string",
|
||||
"VARCHAR": "string",
|
||||
"CHAR": "string",
|
||||
"CHARACTER": "string",
|
||||
"VARYING CHARACTER": "string",
|
||||
"NCHAR": "string",
|
||||
"NVARCHAR": "string",
|
||||
"CLOB": "text",
|
||||
"BLOB": "bytea",
|
||||
"NCHAR": "string",
|
||||
"NVARCHAR": "string",
|
||||
"CLOB": "text",
|
||||
"BLOB": "bytea",
|
||||
}
|
||||
|
||||
// Try exact match first
|
||||
|
||||
Reference in New Issue
Block a user