column-definition.vala 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. namespace InvercargillSql.Orm {
  2. /**
  3. * Represents a column definition for both ORM mapping and migrations.
  4. *
  5. * ColumnDefinition contains the column name and type for runtime mapping,
  6. * as well as schema metadata used by the migrations system for DDL generation.
  7. *
  8. * When using the ORM with schema introspection (register_with_schema), the
  9. * schema metadata properties are discovered from the database rather than
  10. * being configured explicitly.
  11. */
  12. public class ColumnDefinition : Object {
  13. /**
  14. * The name of the column in the database.
  15. */
  16. public string name { get; set; }
  17. /**
  18. * The column type used for type conversion.
  19. */
  20. public ColumnType column_type { get; set; }
  21. /**
  22. * Whether this column is the primary key.
  23. * Used by migrations for DDL generation.
  24. * Discovered via introspection when using register_with_schema.
  25. */
  26. public bool is_primary_key { get; set; }
  27. /**
  28. * Whether this column auto-increments.
  29. * Used by migrations for DDL generation.
  30. * Discovered via introspection when using register_with_schema.
  31. */
  32. public bool auto_increment { get; set; }
  33. /**
  34. * Whether this column is required (NOT NULL).
  35. * Used by migrations for DDL generation.
  36. * Discovered via introspection when using register_with_schema.
  37. */
  38. public bool is_required { get; set; }
  39. /**
  40. * Whether this column has a unique constraint.
  41. * Used by migrations for DDL generation.
  42. */
  43. public bool is_unique { get; set; }
  44. /**
  45. * Whether this column has an index.
  46. * Used by migrations for DDL generation.
  47. */
  48. public bool has_index { get; set; }
  49. /**
  50. * Default value for this column.
  51. * Used by migrations for DDL generation.
  52. */
  53. public Invercargill.Element? default_value { get; set; }
  54. /**
  55. * Whether this column defaults to the current timestamp.
  56. * Used by migrations for DDL generation.
  57. */
  58. public bool default_now { get; set; }
  59. }
  60. }