Skip to content

Commit 8ac6ade

Browse files
Remove InteractableTypeFeature feature flag
1 parent b3b73de commit 8ac6ade

27 files changed

Lines changed: 183 additions & 645 deletions

app-modules/interaction/database/factories/InteractionDriverFactory.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838

3939
use AdvisingApp\Interaction\Enums\InteractableType;
4040
use AdvisingApp\Interaction\Models\InteractionDriver;
41-
use App\Features\InteractableTypeFeature;
4241
use Illuminate\Database\Eloquent\Factories\Factory;
4342

4443
/**
@@ -51,7 +50,7 @@ public function definition(): array
5150
return [
5251
'name' => $this->faker->unique()->sentence(),
5352
'is_default' => false,
54-
...(InteractableTypeFeature::active() ? ['interactable_type' => $this->faker->randomElement(InteractableType::cases())] : []),
53+
'interactable_type' => $this->faker->randomElement(InteractableType::cases()),
5554
];
5655
}
5756
}

app-modules/interaction/database/factories/InteractionInitiativeFactory.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838

3939
use AdvisingApp\Interaction\Enums\InteractableType;
4040
use AdvisingApp\Interaction\Models\InteractionInitiative;
41-
use App\Features\InteractableTypeFeature;
4241
use Illuminate\Database\Eloquent\Factories\Factory;
4342

4443
/**
@@ -51,7 +50,7 @@ public function definition(): array
5150
return [
5251
'name' => $this->faker->unique()->sentence(),
5352
'is_default' => false,
54-
...(InteractableTypeFeature::active() ? ['interactable_type' => $this->faker->randomElement(InteractableType::cases())] : []),
53+
'interactable_type' => $this->faker->randomElement(InteractableType::cases()),
5554
];
5655
}
5756
}

app-modules/interaction/database/factories/InteractionOutcomeFactory.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838

3939
use AdvisingApp\Interaction\Enums\InteractableType;
4040
use AdvisingApp\Interaction\Models\InteractionOutcome;
41-
use App\Features\InteractableTypeFeature;
4241
use Illuminate\Database\Eloquent\Factories\Factory;
4342

4443
/**
@@ -51,7 +50,7 @@ public function definition(): array
5150
return [
5251
'name' => $this->faker->unique()->sentence(),
5352
'is_default' => false,
54-
...(InteractableTypeFeature::active() ? ['interactable_type' => $this->faker->randomElement(InteractableType::cases())] : []),
53+
'interactable_type' => $this->faker->randomElement(InteractableType::cases()),
5554
];
5655
}
5756
}

app-modules/interaction/database/factories/InteractionRelationFactory.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838

3939
use AdvisingApp\Interaction\Enums\InteractableType;
4040
use AdvisingApp\Interaction\Models\InteractionRelation;
41-
use App\Features\InteractableTypeFeature;
4241
use Illuminate\Database\Eloquent\Factories\Factory;
4342

4443
/**
@@ -51,7 +50,7 @@ public function definition(): array
5150
return [
5251
'name' => $this->faker->unique()->sentence(),
5352
'is_default' => false,
54-
...(InteractableTypeFeature::active() ? ['interactable_type' => $this->faker->randomElement(InteractableType::cases())] : []),
53+
'interactable_type' => $this->faker->randomElement(InteractableType::cases()),
5554
];
5655
}
5756
}

app-modules/interaction/database/factories/InteractionStatusFactory.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
use AdvisingApp\CaseManagement\Enums\ColumnColorOptions;
4040
use AdvisingApp\Interaction\Enums\InteractableType;
4141
use AdvisingApp\Interaction\Models\InteractionStatus;
42-
use App\Features\InteractableTypeFeature;
4342
use Illuminate\Database\Eloquent\Factories\Factory;
4443

4544
/**
@@ -53,7 +52,7 @@ public function definition(): array
5352
'name' => $this->faker->unique()->sentence(),
5453
'color' => $this->faker->randomElement(ColumnColorOptions::cases())->value,
5554
'is_default' => false,
56-
...(InteractableTypeFeature::active() ? ['interactable_type' => $this->faker->randomElement(InteractableType::cases())] : []),
55+
'interactable_type' => $this->faker->randomElement(InteractableType::cases()),
5756
];
5857
}
5958
}

app-modules/interaction/database/factories/InteractionTypeFactory.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838

3939
use AdvisingApp\Interaction\Enums\InteractableType;
4040
use AdvisingApp\Interaction\Models\InteractionType;
41-
use App\Features\InteractableTypeFeature;
4241
use Illuminate\Database\Eloquent\Factories\Factory;
4342

4443
/**
@@ -51,7 +50,7 @@ public function definition(): array
5150
return [
5251
'name' => $this->faker->unique()->sentence(),
5352
'is_default' => false,
54-
...(InteractableTypeFeature::active() ? ['interactable_type' => $this->faker->randomElement(InteractableType::cases())] : []),
53+
'interactable_type' => $this->faker->randomElement(InteractableType::cases()),
5554
];
5655
}
5756
}

app-modules/interaction/database/migrations/2025_12_24_002713_data_add_interactable_type_to_interactions.php

Lines changed: 0 additions & 202 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,9 @@
3535
*/
3636

3737
use AdvisingApp\Interaction\Models\Interaction;
38-
use AdvisingApp\Interaction\Models\InteractionDriver;
39-
use App\Features\InteractableTypeFeature;
4038
use Illuminate\Database\Migrations\Migration;
4139
use Illuminate\Support\Collection;
4240
use Illuminate\Support\Facades\DB;
43-
use Illuminate\Support\Str;
4441
use Tpetry\PostgresqlEnhanced\Schema\Blueprint;
4542
use Tpetry\PostgresqlEnhanced\Support\Facades\Schema;
4643

@@ -82,201 +79,6 @@ public function up(): void
8279
$table->string('interactable_type')->nullable();
8380
});
8481

85-
// TODO: InteractableTypeFeature cleanup, remove this section (lines 82-173)
86-
//Duplicate existing records and set as prospect type, set originals as student type
87-
DB::table('interaction_statuses')
88-
->chunkById(100, function (Collection $interactionStatuses) {
89-
foreach ($interactionStatuses as $interactionStatus) {
90-
DB::table('interaction_statuses')->insert([
91-
'id' => Str::orderedUuid(),
92-
'name' => $interactionStatus->name,
93-
'color' => $interactionStatus->color,
94-
'is_default' => $interactionStatus->is_default,
95-
'interactable_type' => 'prospect',
96-
]);
97-
98-
DB::table('interaction_statuses')
99-
->where('id', $interactionStatus->id)
100-
->update(['interactable_type' => 'student']);
101-
}
102-
});
103-
104-
DB::table('interaction_types')
105-
->chunkById(100, function (Collection $interactionTypes) {
106-
foreach ($interactionTypes as $interactionType) {
107-
DB::table('interaction_types')->insert([
108-
'id' => Str::orderedUuid(),
109-
'name' => $interactionType->name,
110-
'is_default' => $interactionType->is_default,
111-
'interactable_type' => 'prospect',
112-
]);
113-
114-
DB::table('interaction_types')
115-
->where('id', $interactionType->id)
116-
->update(['interactable_type' => 'student']);
117-
}
118-
});
119-
120-
DB::table('interaction_outcomes')
121-
->chunkById(100, function (Collection $interactionOutcomes) {
122-
foreach ($interactionOutcomes as $interactionOutcome) {
123-
DB::table('interaction_outcomes')->insert([
124-
'id' => Str::orderedUuid(),
125-
'name' => $interactionOutcome->name,
126-
'is_default' => $interactionOutcome->is_default,
127-
'interactable_type' => 'prospect',
128-
]);
129-
130-
DB::table('interaction_outcomes')
131-
->where('id', $interactionOutcome->id)
132-
->update(['interactable_type' => 'student']);
133-
}
134-
});
135-
136-
DB::table('interaction_relations')
137-
->chunkById(100, function (Collection $interactionRelations) {
138-
foreach ($interactionRelations as $interactionRelation) {
139-
DB::table('interaction_relations')->insert([
140-
'id' => Str::orderedUuid(),
141-
'name' => $interactionRelation->name,
142-
'is_default' => $interactionRelation->is_default,
143-
'interactable_type' => 'prospect',
144-
]);
145-
146-
DB::table('interaction_relations')
147-
->where('id', $interactionRelation->id)
148-
->update(['interactable_type' => 'student']);
149-
}
150-
});
151-
152-
DB::table('interaction_drivers')
153-
->chunkById(100, function (Collection $interactionDrivers) {
154-
foreach ($interactionDrivers as $interactionDriver) {
155-
// There was a bug in interaction drivers where in a seeder we had accidentlly created duplicates for "Fast Track Certificates"
156-
// This now needs to be addressed in order for the unique index to be applied properly later in this migration
157-
$drivers = InteractionDriver::query()->where('name', 'Fast Track Certificates')->get();
158-
159-
if ($drivers->count() > 1) {
160-
// Keep the first one, delete the rest
161-
$keptDriver = $drivers->shift();
162-
163-
foreach ($drivers as $duplicateDriver) {
164-
Interaction::query()
165-
->where('interaction_driver_id', $duplicateDriver->id)
166-
->update(['interaction_driver_id' => $keptDriver->id]);
167-
168-
$duplicateDriver->forceDelete();
169-
}
170-
}
171-
172-
DB::table('interaction_drivers')->insert([
173-
'id' => Str::orderedUuid(),
174-
'name' => $interactionDriver->name,
175-
'is_default' => $interactionDriver->is_default,
176-
'interactable_type' => 'prospect',
177-
]);
178-
179-
DB::table('interaction_drivers')
180-
->where('id', $interactionDriver->id)
181-
->update(['interactable_type' => 'student']);
182-
}
183-
});
184-
185-
DB::table('interaction_initiatives')
186-
->chunkById(100, function (Collection $interactionInitiatives) {
187-
foreach ($interactionInitiatives as $interactionInitiative) {
188-
DB::table('interaction_initiatives')->insert([
189-
'id' => Str::orderedUuid(),
190-
'name' => $interactionInitiative->name,
191-
'is_default' => $interactionInitiative->is_default,
192-
'interactable_type' => 'prospect',
193-
]);
194-
195-
DB::table('interaction_initiatives')
196-
->where('id', $interactionInitiative->id)
197-
->update(['interactable_type' => 'student']);
198-
}
199-
});
200-
201-
// TODO: InteractableTypeFeature cleanup, remove this section (lines 175-252)
202-
//Ensure interactions now have the correct foriegn key
203-
DB::table('interactions')
204-
->chunkById(100, function (Collection $interactions) {
205-
foreach ($interactions as $interaction) {
206-
$interactionStatus = DB::table('interaction_statuses')->where('id', $interaction->interaction_status_id)->first();
207-
208-
if (! is_null($interactionStatus) && $interaction->interactable_type !== $interactionStatus->interactable_type) {
209-
$newStatusId = DB::table('interaction_statuses')
210-
->where('name', $interactionStatus->name)
211-
->where('interactable_type', $interaction->interactable_type)
212-
->value('id');
213-
DB::table('interactions')
214-
->where('id', $interaction->id)
215-
->update(['interaction_status_id' => $newStatusId]);
216-
}
217-
218-
$interactionType = DB::table('interaction_types')->where('id', $interaction->interaction_type_id)->first();
219-
220-
if (! is_null($interactionType) && $interaction->interactable_type !== $interactionType->interactable_type) {
221-
$newTypeId = DB::table('interaction_types')
222-
->where('name', $interactionType->name)
223-
->where('interactable_type', $interaction->interactable_type)
224-
->value('id');
225-
DB::table('interactions')
226-
->where('id', $interaction->id)
227-
->update(['interaction_type_id' => $newTypeId]);
228-
}
229-
230-
$interactionOutcome = DB::table('interaction_outcomes')->where('id', $interaction->interaction_outcome_id)->first();
231-
232-
if (! is_null($interactionOutcome) && $interaction->interactable_type !== $interactionOutcome->interactable_type) {
233-
$newOutcomeId = DB::table('interaction_outcomes')
234-
->where('name', $interactionOutcome->name)
235-
->where('interactable_type', $interaction->interactable_type)
236-
->value('id');
237-
DB::table('interactions')
238-
->where('id', $interaction->id)
239-
->update(['interaction_outcome_id' => $newOutcomeId]);
240-
}
241-
242-
$interactionRelation = DB::table('interaction_relations')->where('id', $interaction->interaction_relation_id)->first();
243-
244-
if (! is_null($interactionRelation) && $interaction->interactable_type !== $interactionRelation->interactable_type) {
245-
$newRelationId = DB::table('interaction_relations')
246-
->where('name', $interactionRelation->name)
247-
->where('interactable_type', $interaction->interactable_type)
248-
->value('id');
249-
DB::table('interactions')
250-
->where('id', $interaction->id)
251-
->update(['interaction_relation_id' => $newRelationId]);
252-
}
253-
254-
$interactionDriver = DB::table('interaction_drivers')->where('id', $interaction->interaction_driver_id)->first();
255-
256-
if (! is_null($interactionDriver) && $interaction->interactable_type !== $interactionDriver->interactable_type) {
257-
$newDriverId = DB::table('interaction_drivers')
258-
->where('name', $interactionDriver->name)
259-
->where('interactable_type', $interaction->interactable_type)
260-
->value('id');
261-
DB::table('interactions')
262-
->where('id', $interaction->id)
263-
->update(['interaction_driver_id' => $newDriverId]);
264-
}
265-
266-
$interactionInitiative = DB::table('interaction_initiatives')->where('id', $interaction->interaction_initiative_id)->first();
267-
268-
if (! is_null($interactionInitiative) && $interaction->interactable_type !== $interactionInitiative->interactable_type) {
269-
$newInitiativeId = DB::table('interaction_initiatives')
270-
->where('name', $interactionInitiative->name)
271-
->where('interactable_type', $interaction->interactable_type)
272-
->value('id');
273-
DB::table('interactions')
274-
->where('id', $interaction->id)
275-
->update(['interaction_initiative_id' => $newInitiativeId]);
276-
}
277-
}
278-
});
279-
28082
//Make interactable_type non nullable, add unique index
28183
Schema::table('interaction_statuses', function (Blueprint $table) {
28284
$table->string('interactable_type')->nullable(false)->change();
@@ -337,8 +139,6 @@ public function up(): void
337139
WHERE is_default = true AND deleted_at IS NULL;
338140
');
339141
});
340-
341-
InteractableTypeFeature::activate();
342142
});
343143
}
344144

@@ -538,8 +338,6 @@ public function down(): void
538338
$table->dropColumn('interactable_type');
539339
$table->unique('name');
540340
});
541-
542-
InteractableTypeFeature::deactivate();
543341
});
544342
}
545343
};

app-modules/interaction/src/Filament/Concerns/HasManyMorphedInteractionsTrait.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
use AdvisingApp\Interaction\Settings\InteractionManagementSettings;
4343
use AdvisingApp\Prospect\Models\Prospect;
4444
use AdvisingApp\StudentDataModel\Models\Student;
45-
use App\Features\InteractableTypeFeature;
4645
use Carbon\CarbonInterface;
4746
use Filament\Actions\CreateAction;
4847
use Filament\Actions\DeleteAction;
@@ -216,10 +215,6 @@ public function table(Table $table): Table
216215
'initiative',
217216
'name',
218217
function (Builder $query) use ($ownerRecord) {
219-
if (! InteractableTypeFeature::active()) {
220-
return $query;
221-
}
222-
223218
$type = $ownerRecord->getMorphClass();
224219

225220
if ($ownerRecord instanceof CaseModel) {
@@ -237,10 +232,6 @@ function (Builder $query) use ($ownerRecord) {
237232
'driver',
238233
'name',
239234
function (Builder $query) use ($ownerRecord) {
240-
if (! InteractableTypeFeature::active()) {
241-
return $query;
242-
}
243-
244235
$type = $ownerRecord->getMorphClass();
245236

246237
if ($ownerRecord instanceof CaseModel) {
@@ -259,10 +250,6 @@ function (Builder $query) use ($ownerRecord) {
259250
'type',
260251
'name',
261252
function (Builder $query) use ($ownerRecord) {
262-
if (! InteractableTypeFeature::active()) {
263-
return $query;
264-
}
265-
266253
$type = $ownerRecord->getMorphClass();
267254

268255
if ($ownerRecord instanceof CaseModel) {
@@ -279,10 +266,6 @@ function (Builder $query) use ($ownerRecord) {
279266
'status',
280267
'name',
281268
function (Builder $query) use ($ownerRecord) {
282-
if (! InteractableTypeFeature::active()) {
283-
return $query;
284-
}
285-
286269
$type = $ownerRecord->getMorphClass();
287270

288271
if ($ownerRecord instanceof CaseModel) {

0 commit comments

Comments
 (0)