EnAccess / EnAccess/micropowermanager

[Feature Request]: Make all migrations that modify schema deterministic

Open
#1,191 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
PHP
Stars
27
Forks
19
Avg merge
1d 18h
Merged PRs (30d)
27

Description

### Preflight Checklist

- [x] I have read the [Contributing Guidelines](https://github.com/EnAccess/micropowermanager/blob/main/CONTRIBUTING.md) for this project, if it exists.
- [x] I agree to follow the [Code of Conduct](https://github.com/EnAccess/micropowermanager/blob/main/CODE_OF_CONDUCT.md) that this project adheres to.
- [x] I have searched the [issue tracker](https://github.com/EnAccess/micropowermanager/issues) for a feature request that matches the one I want to file, without success.

### Problem Description

Currently, some of our migrations that modify schema are non-deterministic. I.e. they have different results depending on the environment they are run in.

Two examples of that are

- Using `config` object to create tables in Laravel Permissions
- Using `if (Schema::connection('tenant')->hasTable(....))`

This has various downsides. For example it prevents ever changing the value of `config` that is used in the migration. Also, can produce inconsistencies when migrations are silently not running or running twice.

### Proposed Solution

Please change all migration that modify schema to be deterministic. I.e. have a reproducible output.

- Remove all `if (Schema::connection('tenant')->hasTable(....))` constructs
- Hardcode any values that are currently read from config.

### Alternatives Considered

N/A

### Additional Information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.