Skip to content

Commit

Permalink
Merge pull request #18 from ibrasho-forks/fix-concurrent-models
Browse files Browse the repository at this point in the history
Update Model.php to prevent `$sqliteConnection` overrides when multiple models are booted
  • Loading branch information
danharrin authored Apr 26, 2021
2 parents 12199d4 + 627801b commit 3892c59
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/monorepo-split.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ jobs:
- id: previous-tag
uses: "WyriHaximus/github-action-get-previous-tag@master"
- name: Monorepo Split of ${{ matrix.package }}
uses: symplify/github-action-monorepo-split@master
uses: symplify/github-action-monorepo-split@main
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
with:
package-directory: 'packages/${{ matrix.package }}'
split-repository-organization: 'squirephp'
split-repository-name: '${{ matrix.package }}'
branch: main
tag: ${{ steps.previous-tag.outputs.tag }}
user-name: "Dan Harrin"
user-email: "dan@danharrin.com"
user-email: "dan@danharrin.com"
3 changes: 2 additions & 1 deletion packages/countries-en/resources/data.csv
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ gu,1671,Hagatna,gu,gum,oc,usd,🇬🇺,Guam
gw,245,Bissau,gw,gnb,af,xof,🇬🇼,Guinea-Bissau
gy,592,Georgetown,gy,guy,sa,gyd,🇬🇾,Guyana
hk,852,Hong Kong,hk,hkg,as,hkd,🇭🇰,Hong Kong
hm,672,,hm,hmd,oc,,🇦🇺,Heard Island and McDonald Islands
hn,504,Tegucigalpa,hn,hnd,na,hnl,🇭🇳,Honduras
hr,385,Zagreb,hr,hrv,eu,hrk,🇭🇷,Croatia
ht,509,Port-au-Prince,ht,hti,na,htg,🇭🇹,Haiti
Expand Down Expand Up @@ -247,4 +248,4 @@ ye,967,Sanaa,ye,yem,as,yer,🇾🇪,Yemen
yt,262,Mamoudzou,yt,myt,af,eur,🇾🇹,Mayotte
za,27,Pretoria,za,zaf,af,zar,🇿🇦,South Africa
zm,260,Lusaka,zm,zmb,af,zmk,🇿🇲,Zambia
zw,263,Harare,zw,zwe,af,zwl,🇿🇼,Zimbabwe
zw,263,Harare,zw,zwe,af,zwl,🇿🇼,Zimbabwe
8 changes: 4 additions & 4 deletions packages/model/src/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Model extends Eloquent\Model

public static $schema = [];

protected static $sqliteConnection;
protected static $sqliteConnections = [];

protected static function boot()
{
Expand Down Expand Up @@ -143,12 +143,12 @@ public static function migrate($locale = null)

public static function resolveConnection($connection = null)
{
return static::$sqliteConnection;
return static::$sqliteConnections[static::class];
}

protected static function setSqliteConnection($database)
{
static::$sqliteConnection = app(ConnectionFactory::class)->make([
static::$sqliteConnections[static::class] = app(ConnectionFactory::class)->make([
'driver' => 'sqlite',
'database' => $database,
]);
Expand All @@ -158,4 +158,4 @@ public function usesTimestamps()
{
return false;
}
}
}

0 comments on commit 3892c59

Please sign in to comment.