From 46c08323ad9eb066cf38b12341e209df3f6b4d2c Mon Sep 17 00:00:00 2001 From: Kylesoda <249518290+kylesoda@users.noreply.github.com> Date: Sat, 4 Apr 2026 09:30:07 -0500 Subject: [PATCH] feat: add ColumnType struct and associated methods for database column metadata --- cmd/go_migrate/colum-type.go | 40 ++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 cmd/go_migrate/colum-type.go diff --git a/cmd/go_migrate/colum-type.go b/cmd/go_migrate/colum-type.go new file mode 100644 index 0000000..1288e15 --- /dev/null +++ b/cmd/go_migrate/colum-type.go @@ -0,0 +1,40 @@ +package main + +type ColumnType struct { + name string + + hasNullable bool + hasMaxLength bool + hasPrecisionScale bool + + userType string + systemType string + nullable bool + maxLength int64 + precision int64 + scale int64 +} + +func (c *ColumnType) Name() string { + return c.name +} + +func (c *ColumnType) UserType() string { + return c.userType +} + +func (c *ColumnType) SystemType() string { + return c.systemType +} + +func (c *ColumnType) Length() (length int64, ok bool) { + return c.maxLength, c.hasMaxLength +} + +func (c *ColumnType) DecimalSize() (precision, scale int64, ok bool) { + return c.precision, c.scale, c.hasPrecisionScale +} + +func (c *ColumnType) Nullable() (nullable, ok bool) { + return c.nullable, c.hasNullable +}