Emma wants to create a simple Go program to manage active and inactive user accounts. She needs to create a new in-memory SQLite database with the users and roles tables.
The users table should have the following columns:
| users | |
|---|---|
id |
INTEGER |
created_at |
DATETIME |
updated_at |
DATETIME |
deleted_at |
DATETIME |
name |
TEXT UNIQUE NOT NULL |
email |
TEXT INDEX |
is_active |
BOOL |
And the roles table should have the following columns:
| roles | |
|---|---|
id |
INTEGER |
created_at |
DATETIME |
updated_at |
DATETIME |
deleted_at |
DATETIME |
name |
TEXT UNIQUE NOT NULL |
description |
TEXT |
Your task is to help Emma write the required code to declare the User and Role models, using the gorm.Model struct. Apart from that, use appropriate GORM struct tags to ensure the special constraints that the name and email columns should have.
This problem uses the
reflect package and the hidden function checkModels() to check if you correctly declared the User and Role models.