public function requireDefaultRecords()
    {
        if (!$this->owner) {
            return;
        }
        // Migration for Group.SubsiteID data from when Groups only had a single subsite
        $schema = DataObject::getSchema();
        $groupTable = Convert::raw2sql($schema->tableName(Group::class));
        $groupFields = DB::field_list($groupTable);

        // Detection of SubsiteID field is the trigger for old-style-subsiteID migration
        if (isset($groupFields['SubsiteID'])) {
            // Migrate subsite-specific data
            DB::query('INSERT INTO "Group_Subsites" ("GroupID", "SubsiteID")
				SELECT "ID", "SubsiteID" FROM "' . $groupTable . '" WHERE "SubsiteID" > 0');

            // Migrate global-access data
            DB::query('UPDATE "' . $groupTable . '" SET "AccessAllSubsites" = 1 WHERE "SubsiteID" = 0');

            // Move the field out of the way so that this migration doesn't get executed again
            DB::get_schema()->renameField($groupTable, 'SubsiteID', '_obsolete_SubsiteID');

            // No subsite access on anything means that we've just installed the subsites module.
            // Make all previous groups global-access groups
        } else {
            if (!DB::query('SELECT "Group"."ID" FROM "' . $groupTable . '"
			LEFT JOIN "Group_Subsites" ON "Group_Subsites"."GroupID" = "Group"."ID" AND "Group_Subsites"."SubsiteID" > 0
			WHERE "AccessAllSubsites" = 1
			OR "Group_Subsites"."GroupID" IS NOT NULL ')->value()
            ) {
                DB::query('UPDATE "' . $groupTable . '" SET "AccessAllSubsites" = 1');
            }
        }
    }
public function requireDefaultRecords()
    {
        if (!$this->owner) {
            return;
        }
        // Migration for Group.SubsiteID data from when Groups only had a single subsite
        $schema = DataObject::getSchema();
        $groupTable = Convert::raw2sql($schema->tableName(Group::class));
        $groupFields = DB::field_list($groupTable);

        // Detection of SubsiteID field is the trigger for old-style-subsiteID migration
        if (isset($groupFields['SubsiteID'])) {
            // Migrate subsite-specific data
            DB::query('INSERT INTO "Group_Subsites" ("GroupID", "SubsiteID")
				SELECT "ID", "SubsiteID" FROM "' . $groupTable . '" WHERE "SubsiteID" > 0');

            // Migrate global-access data
            DB::query('UPDATE "' . $groupTable . '" SET "AccessAllSubsites" = 1 WHERE "SubsiteID" = 0');

            // Move the field out of the way so that this migration doesn't get executed again
            DB::get_schema()->renameField($groupTable, 'SubsiteID', '_obsolete_SubsiteID');

            // No subsite access on anything means that we've just installed the subsites module.
            // Make all previous groups global-access groups
        } else {
            if (!DB::query('SELECT "Group"."ID" FROM "' . $groupTable . '"
			LEFT JOIN "Group_Subsites" ON "Group_Subsites"."GroupID" = "Group"."ID" AND "Group_Subsites"."SubsiteID" > 0
			WHERE "AccessAllSubsites" = 1
			OR "Group_Subsites"."GroupID" IS NOT NULL ')->value()
            ) {
                DB::query('UPDATE "' . $groupTable . '" SET "AccessAllSubsites" = 1');
            }
        }
    }
public function requireDefaultRecords ( ) { if ( ! $ this -> owner ) { return ; } // Migration for Group.SubsiteID data from when Groups only had a single subsite $ schema = DataObject :: getSchema ( ) ; $ groupTable = Convert :: raw2sql ( $ schema -> tableName ( Group :: class ) ) ; $ groupFields = DB :: field_list ( $ groupTable ) ; // Detection of SubsiteID field is the trigger for old-style-subsiteID migration if ( isset ( $ groupFields [ 'SubsiteID' ] ) ) { // Migrate subsite-specific data DB :: query ( 'INSERT INTO "Group_Subsites" ("GroupID", "SubsiteID")
				SELECT "ID", "SubsiteID" FROM "' . $ groupTable . '" WHERE "SubsiteID" > 0' ) ; // Migrate global-access data DB :: query ( 'UPDATE "' . $ groupTable . '" SET "AccessAllSubsites" = 1 WHERE "SubsiteID" = 0' ) ; // Move the field out of the way so that this migration doesn't get executed again DB :: get_schema ( ) -> renameField ( $ groupTable , 'SubsiteID' , '_obsolete_SubsiteID' ) ; // No subsite access on anything means that we've just installed the subsites module. // Make all previous groups global-access groups } else { if ( ! DB :: query ( 'SELECT "Group"."ID" FROM "' . $ groupTable . '"
			LEFT JOIN "Group_Subsites" ON "Group_Subsites"."GroupID" = "Group"."ID" AND "Group_Subsites"."SubsiteID" > 0
			WHERE "AccessAllSubsites" = 1
			OR "Group_Subsites"."GroupID" IS NOT NULL ' ) -> value ( ) ) { DB :: query ( 'UPDATE "' . $ groupTable . '" SET "AccessAllSubsites" = 1' ) ; } } }
Migrations for GroupSubsites data.
Migrations for GroupSubsites data .