Drizzle Schema Boolean

Hi everyone,
I'm trying to create a schema in Drizzle but my SQL knowledge is pretty limited.

I want to have a boolean like isProtected and if this is true then store some other information in other columns. I dont know how to handle a situation like this.

  isProtected: boolean('is_protected').default(false).notNull(),
  contentType: mysqlEnum('content_type', [
    'application/vnd.apple.mpegurl',
    'text/xml',
  ]),
  contentUrl: text('content_url'),



I want to have these contentType and contentUrl columns to contain value only when isProtected is true. Basically, Is there a way to make sure that when I set to isProtected true Typescript will force me to add other related columns ?
Solution
Generated columns are just made from combining data already in the table, https://stackoverflow.com/questions/10273750/sql-conditional-not-null-constraint should answer your question as far as i can tell
Stack Overflow
I am curious to know is it possible to create a conditional not null constraint in sql? In otherwords is it possible to create a constraint such that a column B can be null as long column A contain...
Was this page helpful?