Skip to content

Commit

Permalink
CONTENTBOX-1501 #roles
Browse files Browse the repository at this point in the history
Init migration needs to verify permissions and roles separately to make sure it passes on created dbs
  • Loading branch information
lmajano committed Jan 15, 2024
1 parent f7d2e5e commit 890f0fa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
1 change: 0 additions & 1 deletion box-site.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"contentbox:migrate" : "migrate up manager=contentbox",
"contentbox:migrate:up" : "run-script contentbox:migrate",
"contentbox:migrate:down" : "migrate down manager=contentbox",
"install:2021":"!cfpm install zip,orm,mysql,postgresql,sqlserver,document,feed",
"format":"cfformat run config/,handlers/,models/,modules_app/**/*.cfc,Application.cfc --overwrite",
"format:watch":"cfformat watch config/,handlers/,models/,modules_app/**/*.cfc,Application.cfc ./.cfformat.json",
"format:check":"cfformat check config/**/*.cfc,modules_app/**/*.cfc,modules/contentbox/**/*.cfc,tests/**/*.cfc,Application.cfc"
Expand Down
26 changes: 13 additions & 13 deletions modules/contentbox/migrations/2020_01_01_150933_init.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -48,32 +48,32 @@ component {
];

systemOutput( "Starting to initialize the ContentBox Database, this will take a while...", true );
var newDB = false;

migrations.each( ( migration, record ) => {
systemOutput( "Migrating [#migration#]...", true );

if ( !schema.hasTable( record.table ) ) {
newDB = true;
systemOutput( "- Table doesn't exist (#record.table#) creating it...", true );
new "init.create_#migration#"( ).up( schema, query );

// Seeding Permissions
if( migration == "permissions" ){
systemOutput( "- Seeding permissions...", true );
new init.seed_permissions().seed( schema, query );
}

// Seeding Roles
if( migration == "roles" ){
systemOutput( "- Seeding roles...", true );
new init.seed_roles().seed( schema, query );
}

} else {
systemOutput( "√ Table (#record.table#) already exists, skipping...", true );
}
} );

systemOutput( "√ Database structure complete", true );

// Seed the database only if we created the tables
// This protects agains seeding an already ran migration
if ( newDB ) {
systemOutput( "- Database seeding required, starting...", true );

new init.seed_permissions().seed( schema, query );
new init.seed_roles().seed( schema, query );

systemOutput( "√ Database seeding completed", true );
}
}

function down( schema, query ){
Expand Down

0 comments on commit 890f0fa

Please sign in to comment.