├── .editorconfig ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ └── tests.yml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── composer.json ├── phpunit.xml.dist ├── ruleset.xml ├── src └── SQLiteFluentDropForeignServiceProvider.php └── tests ├── Integration ├── ExampleTest.php └── TestCase.php └── Unit ├── ExampleTest.php └── UnitTestCase.php /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | insert_final_newline = true 7 | indent_style = space 8 | indent_size = 4 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | 14 | [*.{yml,yaml}] 15 | indent_size = 2 16 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | # Description 2 | 3 | Please include a summary of the change and which issue is fixed. 4 | Please also include relevant motivation and context. 5 | List any dependencies that are required for this change. 6 | 7 | Fixes # (issue) 8 | 9 | ## Type of change 10 | 11 | Please delete options that are not relevant. 12 | 13 | - [ ] Bug fix (non-breaking change which fixes an issue) 14 | - [ ] New feature (non-breaking change which adds functionality) 15 | - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) 16 | - [ ] This change requires a documentation update 17 | 18 | # How Has This Been Tested? 19 | 20 | Please describe the tests that you ran to verify your changes. 21 | Provide instructions so we can reproduce. 22 | Please also list any relevant details for your test configuration. 23 | Please delete options that are not relevant. 24 | 25 | - [ ] Test A 26 | - [ ] Test B 27 | 28 | **Test Configuration**: 29 | * Firmware version: 30 | * Hardware: 31 | * Toolchain: 32 | * SDK: 33 | 34 | # Checklist: 35 | 36 | - [ ] My code follows the style guidelines of this project 37 | - [ ] I have performed a self-review of my own code 38 | - [ ] I have commented my code, particularly in hard-to-understand areas 39 | - [ ] I have made corresponding changes to the documentation 40 | - [ ] My changes generate no new warnings 41 | - [ ] I have added tests that prove my fix is effective or that my feature works 42 | - [ ] New and existing unit tests pass locally with my changes 43 | - [ ] Any dependent changes have been merged and published in downstream modules 44 | -------------------------------------------------------------------------------- /.github/workflows/tests.yml: -------------------------------------------------------------------------------- 1 | name: tests 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | tests: 7 | runs-on: ubuntu-latest 8 | 9 | strategy: 10 | fail-fast: true 11 | matrix: 12 | php: [8.2, 8.3, 8.4] 13 | laravel: [11.*, 12.*] 14 | dependency-version: [prefer-lowest, prefer-stable] 15 | include: 16 | - laravel: 11.* 17 | testbench: 9.* 18 | - laravel: 12.* 19 | testbench: 10.* 20 | 21 | name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} 22 | 23 | steps: 24 | - name: Checkout code 25 | uses: actions/checkout@v4 26 | 27 | - name: Setup PHP 28 | uses: shivammathur/setup-php@v2 29 | with: 30 | php-version: ${{ matrix.php }} 31 | extensions: json, dom, curl, libxml, mbstring 32 | coverage: none 33 | 34 | - name: Install dependencies 35 | run: | 36 | composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update 37 | composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction 38 | 39 | - name: Execute tests 40 | run: composer test 41 | 42 | - name: Execute lint 43 | run: composer lint 44 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor 2 | composer.phar 3 | composer.lock 4 | .DS_Store 5 | .idea/ 6 | .phpunit.result.cache 7 | phpunit.xml 8 | Thumbs.db 9 | .phpstorm.meta.php 10 | .php_cs.cache 11 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 6 | 7 | ## Our Standards 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | * Using welcoming and inclusive language 12 | * Being respectful of differing viewpoints and experiences 13 | * Gracefully accepting constructive criticism 14 | * Focusing on what is best for the community 15 | * Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | * Trolling, insulting/derogatory comments, and personal or political attacks 21 | * Public or private harassment 22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | * Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 28 | 29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | ## Scope 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 34 | 35 | ## Enforcement 36 | 37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at info@exolnet.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 38 | 39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 40 | 41 | ## Attribution 42 | 43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 44 | 45 | [homepage]: http://contributor-covenant.org 46 | [version]: http://contributor-covenant.org/version/1/4/ 47 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Contributions are **welcome** and will be fully **credited**. 4 | 5 | We accept contributions via Pull Requests on [Github](https://github.com/eXolnet/laravel-sqlite-fluent-drop-foreign). 6 | 7 | 8 | ## Pull Requests 9 | 10 | - **[PSR-12 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-12-extended-coding-style-guide.md)** - Check the code style with ``$ composer lint`` and fix it with ``$ composer lint-fix``. 11 | 12 | - **Add tests!** - Your patch won't be accepted if it doesn't have tests. 13 | 14 | - **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. 15 | 16 | - **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option. 17 | 18 | - **Create feature branches** - Don't ask us to pull from your master branch. 19 | 20 | - **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. 21 | 22 | - **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. 23 | 24 | 25 | ## Running Tests 26 | 27 | ``` bash 28 | $ composer test 29 | ``` 30 | 31 | **Happy coding**! 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2019-present eXolnet 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # laravel-sqlite-fluent-drop-foreign 2 | 3 | [![Latest Stable Version](https://poser.pugx.org/eXolnet/laravel-sqlite-fluent-drop-foreign/v/stable?format=flat-square)](https://packagist.org/packages/eXolnet/laravel-sqlite-fluent-drop-foreign) 4 | [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) 5 | [![Build Status](https://img.shields.io/github/actions/workflow/status/eXolnet/laravel-sqlite-fluent-drop-foreign/tests.yml?label=tests&style=flat-square)](https://github.com/eXolnet/laravel-sqlite-fluent-drop-foreign/actions?query=workflow%3Atests) 6 | [![Total Downloads](https://img.shields.io/packagist/dt/eXolnet/laravel-sqlite-fluent-drop-foreign.svg?style=flat-square)](https://packagist.org/packages/eXolnet/laravel-sqlite-fluent-drop-foreign) 7 | 8 | Make dropForeign fluent when using an SQLite database. 9 | 10 | ## Installation 11 | 12 | Require this package with composer: 13 | 14 | ``` 15 | composer require exolnet/laravel-sqlite-fluent-drop-foreign 16 | ``` 17 | 18 | If you don't use package auto-discovery, add the service provider to the ``providers`` array in `config/app.php`: 19 | 20 | ``` 21 | Exolnet\SQLiteFluentDropForeign\SQLiteFluentDropForeignServiceProvider::class 22 | ``` 23 | 24 | ## Usage 25 | 26 | After the package is installed, all the call to `dropForeign` on a `sqlite` connection will return a `new Fluent()` in 27 | order to avoid getting the `SQLite doesn't support dropping foreign keys (you would need to re-create the table).` 28 | error. 29 | 30 | ## Testing 31 | 32 | To run the phpUnit tests, please use: 33 | 34 | ``` bash 35 | composer test 36 | ``` 37 | 38 | ## Contributing 39 | 40 | Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE OF CONDUCT](CODE_OF_CONDUCT.md) for details. 41 | 42 | ## Security 43 | 44 | If you discover any security related issues, please email security@exolnet.com instead of using the issue tracker. 45 | 46 | ## Credits 47 | 48 | - [Simon Gaudreau](https://github.com/Gandhi11) 49 | - [All Contributors](../../contributors) 50 | 51 | ## License 52 | 53 | Copyright © [eXolnet](https://www.exolnet.com). All rights reserved. 54 | 55 | This code is licensed under the [MIT license](http://choosealicense.com/licenses/mit/). 56 | Please see the [license file](LICENSE) for more information. 57 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "exolnet/laravel-sqlite-fluent-drop-foreign", 3 | "description": "Add a fluent dropForeign when using sqlite database", 4 | "keywords": [ 5 | "exolnet", 6 | "laravel", 7 | "laravel-sqlite-fluent-drop-foreign" 8 | ], 9 | "homepage": "https://github.com/eXolnet/laravel-sqlite-fluent-drop-foreign", 10 | "license": "MIT", 11 | "authors": [ 12 | { 13 | "name": "Simon Gaudreau", 14 | "homepage": "https://www.exolnet.com", 15 | "role": "Developer" 16 | } 17 | ], 18 | "require": { 19 | "php": "^8.2", 20 | "illuminate/database": "^11.0|^12.0", 21 | "illuminate/support": "^11.0|^12.0" 22 | }, 23 | "require-dev": { 24 | "exolnet/phpcs-config": "^1.0", 25 | "orchestra/testbench": "^9.0|^10.0", 26 | "phpunit/phpunit": "^11.5.3", 27 | "squizlabs/php_codesniffer": "^3.6" 28 | }, 29 | "autoload": { 30 | "psr-4": { 31 | "Exolnet\\SQLiteFluentDropForeign\\": "src/" 32 | } 33 | }, 34 | "autoload-dev": { 35 | "psr-4": { 36 | "Exolnet\\SQLiteFluentDropForeign\\Tests\\": "tests" 37 | } 38 | }, 39 | "scripts": { 40 | "lint": "vendor/bin/phpcs -p -s --standard=ruleset.xml", 41 | "lint:fix": "vendor/bin/phpcbf -p --standard=ruleset.xml", 42 | "test": "vendor/bin/phpunit", 43 | "test:coverage": "vendor/bin/phpunit --coverage-html coverage" 44 | }, 45 | "config": { 46 | "sort-packages": true 47 | }, 48 | "extra": { 49 | "laravel": { 50 | "providers": [ 51 | "Exolnet\\SQLiteFluentDropForeign\\SQLiteFluentDropForeignServiceProvider" 52 | ] 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | tests 10 | 11 | 12 | 13 | 14 | src/ 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /ruleset.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | src 4 | tests 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/SQLiteFluentDropForeignServiceProvider.php: -------------------------------------------------------------------------------- 1 | schemaGrammar === null) { 26 | $this->useDefaultSchemaGrammar(); 27 | } 28 | return new class($this) extends SQLiteBuilder 29 | { 30 | protected function createBlueprint($table, ?Closure $callback = null) 31 | { 32 | return new class($table, $callback) extends Blueprint 33 | { 34 | public function dropForeign($index) 35 | { 36 | if (!is_array($index)) { 37 | $foreign = ' ' . $index; 38 | } else { 39 | $foreign = ' on ' . $index[0]; 40 | } 41 | 42 | fwrite( 43 | STDERR, 44 | "You are using drop foreign" . $foreign . 45 | " in your migration which is not supported in sqlite.\n" 46 | ); 47 | 48 | return new Fluent(); 49 | } 50 | }; 51 | } 52 | }; 53 | } 54 | }; 55 | }); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /tests/Integration/ExampleTest.php: -------------------------------------------------------------------------------- 1 | assertTrue(true); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /tests/Integration/TestCase.php: -------------------------------------------------------------------------------- 1 | assertTrue(true); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /tests/Unit/UnitTestCase.php: -------------------------------------------------------------------------------- 1 |