Skip to content

Commit 7587bfd

Browse files
committed
initial commit - adding EVERYTHING
0 parents commit 7587bfd

File tree

13 files changed

+548
-0
lines changed

13 files changed

+548
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/vendor
2+
composer.lock

.styleci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
preset: laravel

changelog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changelog
2+
3+
All notable changes to `SqlViews` will be documented in this file.
4+
5+
## Version 1.0
6+
7+
### Added
8+
- Everything

composer.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name": "stats4sd/sqlviews",
3+
"description": ":A small package to help automate the creation and updating of MySQL views.",
4+
"license": "MIT",
5+
"authors": [
6+
{
7+
"name": "Stats4SD",
8+
"email": "support@stats4sd.org",
9+
"homepage": "https://stats4sd.org"
10+
}
11+
],
12+
"homepage": "https://github.com/stats4sd/sqlviews",
13+
"keywords": ["Laravel", "Sql"],
14+
"require": {
15+
"illuminate/support": "~5|~6|~7"
16+
},
17+
"require-dev": {
18+
"phpunit/phpunit": "^8.0",
19+
"mockery/mockery": "^1.1",
20+
"orchestra/testbench": "~3|~4",
21+
"sempro/phpunit-pretty-print": "^1.0"
22+
},
23+
"autoload": {
24+
"psr-4": {
25+
"Stats4SD\\SqlViews\\": "src/"
26+
}
27+
},
28+
"extra": {
29+
"laravel": {
30+
"providers": [
31+
"Stats4SD\\SqlViews\\SqlViewsServiceProvider"
32+
],
33+
"aliases": {
34+
"SqlViews": "Stats4SD\\SqlViews\\Facades\\SqlViews"
35+
}
36+
}
37+
},
38+
"minimum-stability": "dev",
39+
"prefer-stable": true
40+
}

config/sqlviews.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
return [
4+
'mysql_views_path' => 'database/views'
5+
];

contributing.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Contributing
2+
3+
Contributions are welcome and will be fully credited. Also please fork this for use in your own work!
4+
5+
Contributions are accepted via Pull Requests on [Github](https://github.com/stats4sd/sqlviews).
6+
7+
8+
## Pull Requests
9+
10+
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
11+
12+
- **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.
13+
14+
**Happy coding**!

license.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Statistics for Sustainable Development
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.

readme.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# SqlViews
2+
3+
[![Latest Version on Packagist][ico-version]][link-packagist]
4+
[![Total Downloads][ico-downloads]][link-downloads]
5+
[![StyleCI][ico-styleci]][link-styleci]
6+
7+
A small package to help automate the creation and updating of MySQL views.
8+
9+
This package lets you store the query definition for every MySQL view you need within your Laravel codebase, and lets you edit the SQL query strings directly instead of using migration files. This is useful when:
10+
11+
- You regularly create or update SQL views with real data, e.g. as part of a data analysis workflow.
12+
- You have a set of complex queries that would involve you basically writing out the raw query within a migration file anyway.
13+
14+
15+
## Installation
16+
17+
Via Composer
18+
19+
``` bash
20+
$ composer require stats4sd/sqlviews
21+
```
22+
23+
## Usage
24+
25+
The package includes a single console command that will create or update the SQL views in your database based on the files within your `database/views` directory. It will create a view for every `.sql` file it finds, using the filename as the view name and the contents as the query definition.
26+
27+
To use:
28+
1. Place your query definitions within .sql files inside your `database/views` directory. You need 1 file per view. Do not include the "CREATE OR REPLACE VIEW" segment, just include the query definition itself.
29+
2. Run the command with `php artisan updatesql`.
30+
31+
32+
It will search the folder recursively, so you can organise your views into subfolders if you wish.
33+
34+
The packge comes with a tiny config file.
35+
36+
37+
38+
39+
## Change log
40+
41+
Please see the [changelog](changelog.md) for more information on what has changed recently.
42+
43+
44+
## Contributing
45+
46+
Please see [contributing.md](contributing.md) for details and a todolist.
47+
48+
## Security
49+
50+
If you discover any security related issues, please email author email instead of using the issue tracker.
51+
52+
## Credits
53+
54+
- [Dave Mills][https://github.com/dave-mills]
55+
- [Stats4SD][https://stats4sd.org]
56+
57+
## License
58+
59+
MIT license. Please see the [license file](license.md) for more information.
60+
61+
[ico-version]: https://img.shields.io/packagist/v/stats4sd/sqlviews.svg?style=flat-square
62+
[ico-downloads]: https://img.shields.io/packagist/dt/stats4sd/sqlviews.svg?style=flat-square
63+
64+
[ico-styleci]: https://styleci.io/repos/12345678/shield
65+
66+
[link-packagist]: https://packagist.org/packages/stats4sd/sqlviews
67+
[link-downloads]: https://packagist.org/packages/stats4sd/sqlviews
68+
[link-styleci]: https://styleci.io/repos/12345678
69+
[link-author]: https://github.com/stats4sd
70+
[link-contributors]: ../../contributors

0 commit comments

Comments
 (0)