dbml icon indicating copy to clipboard operation
dbml copied to clipboard

Proposal: DBML Tag

Open phuongduyphan opened this issue 6 years ago • 0 comments

DBML Tag

Concept

  • Support metadata tag/label for DBML element (table, schema,...)
  • Each element can have multiple tags associated.
  • Each tag can be associated with multiple elements.

Syntax

Define the tag block separately.

Tag v1.0 {
  note: 'version 1.0'
  tables: [users, cities, countries]
}

Tag transaction {
  note: 'transaction tables'
  tables: [users, orders]
}

Table orders {
  id int [pk]
  user_id int [ref: > users.id]
  status order_status
  created_at datetime
}
...
  • All the tag's attributes (note, associated tables) can be declared in the long-form format.

Define tag inside element

Table orders [tags: [transaction, v1.0]] {
  id int [pk]
  user_id int [ref: > users.id]
  status order_status
  created_at datetime
}

// or

Table orders {
  id int [pk]
  user_id [ref: > users.id]
  status order_status
  created_at datetime

  Tags {
    v1.0
    transaction
  }
}

phuongduyphan avatar Jan 07 '20 07:01 phuongduyphan