Skip to content

Commit 6b4715f

Browse files
committed
Alpha release
1 parent e16a2ce commit 6b4715f

File tree

90 files changed

+10345
-307
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+10345
-307
lines changed

.github/workflows/php-cs-fixer.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- name: Run PHP CS Fixer
1616
uses: docker://oskarstark/php-cs-fixer-ga
1717
with:
18-
args: --config=.php_cs.dist.php --allow-risky=yes
18+
args: --config=.php-cs-fixer.dist.php --allow-risky=yes
1919

2020
- name: Commit changes
2121
uses: stefanzweifel/git-auto-commit-action@v4

.github/workflows/run-tests.yml

+13-5
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ on:
99
jobs:
1010
test:
1111
runs-on: ${{ matrix.os }}
12+
1213
strategy:
13-
fail-fast: true
1414
matrix:
15-
os: [ubuntu-latest, windows-latest]
16-
php: [8.0]
15+
os: [ubuntu-latest]
16+
php: [8.0, 8.1]
1717
laravel: [8.*]
18-
stability: [prefer-lowest, prefer-stable]
18+
stability: [prefer-stable, prefer-lowest]
1919
include:
2020
- laravel: 8.*
2121
testbench: ^6.23
@@ -26,11 +26,15 @@ jobs:
2626
- name: Checkout code
2727
uses: actions/checkout@v2
2828

29+
- name: Run CockroachDB Service
30+
run: docker-compose up -d
31+
2932
- name: Setup PHP
3033
uses: shivammathur/setup-php@v2
3134
with:
3235
php-version: ${{ matrix.php }}
33-
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
36+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_pgsql
37+
tools: composer:v2
3438
coverage: none
3539

3640
- name: Setup problem matchers
@@ -43,5 +47,9 @@ jobs:
4347
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
4448
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
4549
50+
- name: Configure Database
51+
run: |
52+
php ./database.php
53+
4654
- name: Execute tests
4755
run: vendor/bin/pest
File renamed without changes.

CHANGELOG.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
All notable changes to `cockroachdb-laravel` will be documented in this file.
44

5-
## 1.0.0 - 202X-XX-XX
5+
## 0.1.0 - 2021-12-14
66

7-
- initial release
7+
- initial alpha release

README.md

+29-47
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,12 @@
11
# CockroachDB Driver for Laravel
22

3-
A driver/grammer for Laravel that works with CockroachDB.
4-
53
[![Latest Version on Packagist](https://img.shields.io/packagist/v/ylsideas/cockroachdb-laravel.svg?style=flat-square)](https://packagist.org/packages/ylsideas/cockroachdb-laravel)
64
[![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/ylsideas/cockroachdb-laravel/run-tests?label=tests)](https://github.com/ylsideas/cockroachdb-laravel/actions?query=workflow%3Arun-tests+branch%3Amain)
75
[![GitHub Code Style Action Status](https://img.shields.io/github/workflow/status/ylsideas/cockroachdb-laravel/Check%20&%20fix%20styling?label=code%20style)](https://github.com/ylsideas/cockroachdb-laravel/actions?query=workflow%3A"Check+%26+fix+styling"+branch%3Amain)
86
[![Total Downloads](https://img.shields.io/packagist/dt/ylsideas/cockroachdb-laravel.svg?style=flat-square)](https://packagist.org/packages/ylsideas/cockroachdb-laravel)
97

10-
---
11-
This repo can be used to scaffold a Laravel package. Follow these steps to get started:
12-
13-
1. Press the "Use template" button at the top of this repo to create a new repo with the contents of this cockroachdb-laravel
14-
2. Run "php ./configure.php" to run a script that will replace all placeholders throughout all the files
15-
3. Remove this block of text.
16-
4. Have fun creating your package.
17-
5. If you need help creating a package, consider picking up our <a href="https://laravelpackage.training">Laravel Package Training</a> video course.
18-
---
19-
20-
This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.
21-
22-
## Support us
23-
24-
[<img src="https://github-ads.s3.eu-central-1.amazonaws.com/cockroachdb-laravel.jpg?t=1" width="419px" />](https://spatie.be/github-ad-click/cockroachdb-laravel)
25-
26-
We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).
27-
28-
We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).
8+
A driver/grammar for Laravel that works with CockroachDB. This is currently an alpha.
9+
All tests pass, but you may run into bugs potentially going forward.
2910

3011
## Installation
3112

@@ -35,40 +16,41 @@ You can install the package via composer:
3516
composer require ylsideas/cockroachdb-laravel
3617
```
3718

38-
You can publish and run the migrations with:
39-
40-
```bash
41-
php artisan vendor:publish --tag="cockroachdb-laravel_without_prefix-migrations"
42-
php artisan migrate
43-
```
44-
45-
You can publish the config file with:
46-
```bash
47-
php artisan vendor:publish --tag="cockroachdb-laravel_without_prefix-config"
48-
```
49-
50-
Optionally, you can publish the views using
51-
52-
```bash
53-
php artisan vendor:publish --tag="example-views"
54-
```
55-
56-
This is the contents of the published config file:
57-
19+
You need to add the connection type to the database config:
5820
```php
59-
return [
60-
];
21+
'crdb' => [
22+
'driver' => 'crdb',
23+
'url' => env('DATABASE_URL'),
24+
'host' => env('DB_HOST', '127.0.0.1'),
25+
'port' => env('DB_PORT', '26257'),
26+
'database' => env('DB_DATABASE', 'forge'),
27+
'username' => env('DB_USERNAME', 'forge'),
28+
'password' => env('DB_PASSWORD', ''),
29+
'charset' => 'utf8',
30+
'prefix' => '',
31+
'prefix_indexes' => true,
32+
'schema' => 'public',
33+
'sslmode' => 'prefer',
34+
]
6135
```
6236

6337
## Usage
6438

65-
```php
66-
$cockroachdb-laravel = new YlsIdeas\CockroachDb();
67-
echo $cockroachdb-laravel->echoPhrase('Hello, YlsIdeas!');
68-
```
39+
To enable set `DB_CONNECTION=crdb` in your .env.
40+
41+
## Notes
42+
43+
CockroachDB does not support performing deletes using joins. If you wish to
44+
do something like this you will need to use a sub-query instead.
6945

7046
## Testing
7147

48+
The tests try to closely follow the same functionality of the grammar provided by Laravel
49+
by lifting the tests straight from laravel/framework. This does provide some complications.
50+
Namely, cockroachdb is designed to be distributed so primary keys do not occur in sequence.
51+
Also deletes with joins do not work compared to other Laravel supported databases so the
52+
delete with limit test uses a sub query instead.
53+
7254
```bash
7355
composer test
7456
```

composer.json

+3-5
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818
"require": {
1919
"php": "^8.0",
2020
"spatie/laravel-package-tools": "^1.9.2",
21-
"illuminate/contracts": "^8.73"
21+
"illuminate/contracts": "8.*"
2222
},
2323
"require-dev": {
24+
"doctrine/dbal": "^3.2",
2425
"nunomaduro/collision": "^5.10",
2526
"nunomaduro/larastan": "^1.0",
2627
"orchestra/testbench": "^6.22",
@@ -55,10 +56,7 @@
5556
"laravel": {
5657
"providers": [
5758
"YlsIdeas\\CockroachDb\\CockroachDbServiceProvider"
58-
],
59-
"aliases": {
60-
"CockroachDb": "YlsIdeas\\CockroachDb\\Facades\\CockroachDb"
61-
}
59+
]
6260
}
6361
},
6462
"minimum-stability": "dev",

0 commit comments

Comments
 (0)