Add migrations
Last updated
Last updated
At this point, you could add the Resource Types, Actions and Policies by hand, but we'll do it migrations for two reasons:
It's easier for this tutorial, and
For real apps, that change over time, this is best practice anyway.
Add these two files to a folder called 'cerberusmigrations' under 'backend/go':
Don't worry too much about the details of these files for now. Suffice it to say they act like normal database migrations, creating or deleting data for each migration version.
We always need four things:
Resource Types
Actions
Policies
Actions linked to Policies
The precise details of these four elements will depend on your domain and how you want to set up permissions in your product.
Add the following line to the top of the 'go.mod' file:
Next, add the following imports to 'cmd/api/api.go':
And the following code to the main function in the same file:
Run the app again:
The console should report that the migration has run, and on the dashboard you should see one migration, and all the created Resource Types, Actions and Policies:
It's accomplished with a DSL (domain specific language) detailed in