Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
208 commits
Select commit Hold shift + click to select a range
4f170f4
add support for taxonomies
May 19, 2021
b166029
add db support for globals
May 19, 2021
19830ac
rename terms table
May 19, 2021
9a21d89
fix taxonomy id
May 19, 2021
3d5e4f1
add migrations
May 19, 2021
f4559d9
update readme
May 19, 2021
b1988f4
allow taxonomy to be null
May 27, 2021
b34be34
bring back global transform
May 27, 2021
7bc9d42
add db support for navigations
May 27, 2021
68bafd2
add db support for collections
May 27, 2021
ece0fcc
multisite notice
May 27, 2021
7b57aab
cleanup
May 28, 2021
300c05f
add collections migration
May 28, 2021
2665601
fix collection structure field and cleanup
May 28, 2021
743e376
ingore .php_cs.cache
May 31, 2021
b6d5085
fix code style
May 31, 2021
8344245
make tree model semi polymorph and move files to appropriate folder
May 31, 2021
00db449
add support for collection tree
May 31, 2021
f02b53a
Fix NavTree Model
May 31, 2021
40186dc
Fix sites type on collections
Jun 1, 2021
7b5f662
multisite navigations
benaja Jul 6, 2021
71851fb
add multisite functionality to taxonomies
benaja Jul 6, 2021
9402bc6
localize taxonomies
benaja Jul 6, 2021
d9d9255
ability to customize entry
benaja Jul 12, 2021
dc29b47
get collection tree by site
benaja Jul 13, 2021
58b5971
return localized field when fetching terms by site
benaja Jul 27, 2021
6be137c
optional return
benaja Jul 27, 2021
0ee57a1
only use updated_at from database column and don't track more than once
Jul 27, 2021
528e1fc
save sites to taxonomy and add fallback for terms
Aug 3, 2021
5b826fe
Merge remote-tracking branch 'upstream/master' into feature/support-a…
Oct 20, 2021
440c58e
Provider requires entry contract
ryanmitchell Feb 14, 2022
6167949
Forms
ryanmitchell Feb 15, 2022
9df4a5c
All table names to be prefixed
ryanmitchell Feb 15, 2022
3eb504b
Simplify collections table structure
ryanmitchell Feb 15, 2022
d538874
Use contracts and simplify config
ryanmitchell Feb 15, 2022
5feddc1
Asset containers
ryanmitchell Feb 15, 2022
9e77076
Bring back migrations
ryanmitchell Feb 15, 2022
2ef3bac
Update migration readme
ryanmitchell Feb 15, 2022
a0107bc
Lost table_prefix somewhere along the way
ryanmitchell Feb 15, 2022
81743c1
Remove id from fill
ryanmitchell Feb 15, 2022
f0125a1
Missed a model reference
ryanmitchell Feb 15, 2022
15748fb
Add test
ryanmitchell Feb 15, 2022
399baec
Fix migration publishing
ryanmitchell Feb 17, 2022
ebd112c
Add blueprints and fieldsets
ryanmitchell Feb 17, 2022
f7253e5
Add imports for assets, blueprints, collections and amend entries
ryanmitchell Feb 17, 2022
92d8139
Implement remaining imports
ryanmitchell Feb 17, 2022
9ba12fb
Merge remote-tracking branch 'upstream/master' into fixes-to-all-mode…
ryanmitchell Feb 17, 2022
c5f8b21
Missing asset containers migration
ryanmitchell Feb 25, 2022
4cbb3c2
Add assets_meta to database
ryanmitchell Feb 25, 2022
ba58f31
Make sure form submissions happens after forms
ryanmitchell Feb 28, 2022
b53676a
Add revisions
ryanmitchell Feb 28, 2022
e187cb3
Add config and migration for revisions
ryanmitchell Feb 28, 2022
9b6e987
Handle WorkingCopy more elegantly
ryanmitchell Mar 1, 2022
3d563df
Make sure we store/set everything on entries and collections
ryanmitchell Mar 1, 2022
c9f31d6
Enforced orderBy on migration
ryanmitchell Mar 22, 2022
58916e2
Missing prefix
ryanmitchell Mar 22, 2022
4c722ef
Allow connection to be specified in config
ryanmitchell Mar 23, 2022
e08d122
Fix install bugs
ryanmitchell Mar 28, 2022
0f9979d
Structure, not structureContents
ryanmitchell Mar 28, 2022
f118df6
Fix bug in revisions
ryanmitchell Mar 29, 2022
21b6913
Fix bug in forms
ryanmitchell Apr 1, 2022
7b6e336
Global variables need origins
ryanmitchell Apr 1, 2022
c2a7004
Fix bug when creating a nav
ryanmitchell Apr 1, 2022
7a1d17b
Dont need to get/set structure
ryanmitchell Apr 1, 2022
5d4a7b9
We do need structureContents()
ryanmitchell Apr 1, 2022
c29ea59
Null structureContents when empty for fluent get/set
ryanmitchell Apr 4, 2022
337d813
Update collections
ryanmitchell Apr 5, 2022
1445bdc
Ensure blueprint section order is preserved
ryanmitchell Apr 5, 2022
9773960
Handle empty sections
ryanmitchell Apr 5, 2022
958dc04
Handle WorkingCopy delete
ryanmitchell Apr 6, 2022
42c36ca
BaseMigration class to allow connection to be specified
ryanmitchell Apr 7, 2022
a42d51d
Make a CollectionStructure for new ordered collections
ryanmitchell Apr 7, 2022
9f65873
Performance improvements to reduce database calls
ryanmitchell Apr 8, 2022
409fa72
Some more caching
ryanmitchell Apr 8, 2022
fe7295b
Blueprint errors and regressions
ryanmitchell Apr 8, 2022
49858af
Taxonomy term improvements
ryanmitchell Apr 8, 2022
08a694e
More term refinements
ryanmitchell Apr 8, 2022
9f052a4
Support nested queries in QueryBuilders
ryanmitchell Apr 8, 2022
1474bfc
Fix bug in collection creation
ryanmitchell Apr 8, 2022
fab15c1
Tidy up terms to ensure taxonomy tags work
ryanmitchell Apr 8, 2022
e0bda6c
Reverse check on column
ryanmitchell Apr 8, 2022
63b3e2f
Add and apply .editorconfig
ryanmitchell Apr 8, 2022
8e12d2a
Allow entry slugs to be null
ryanmitchell Apr 12, 2022
d77aee4
Revert "Allow entry slugs to be null"
ryanmitchell Apr 12, 2022
4665002
Add nullable to initial migrations
ryanmitchell Apr 12, 2022
4f08953
snake_case configs
ryanmitchell Apr 14, 2022
3ee6a67
Update composer PHP version
ryanmitchell Apr 14, 2022
2ae88a0
Update testbench
ryanmitchell Apr 14, 2022
7d18971
v2
jasonvarga Apr 14, 2022
3cafc13
eloquent-driver to eloquent_driver
ryanmitchell Apr 15, 2022
d86933f
We want the migrations to publish with a fixed date for tests
ryanmitchell Apr 15, 2022
3ecb832
Tests working locally
ryanmitchell Apr 15, 2022
8158905
Try to get Github tests working
ryanmitchell Apr 15, 2022
1043f7b
Remove things we dont need to test with this package
ryanmitchell Apr 15, 2022
a32ea88
See if this fixes Github actions
ryanmitchell Apr 15, 2022
2f777c9
Revert "See if this fixes Github actions"
ryanmitchell Apr 15, 2022
9b742a3
Statamic 3.3 and up
ryanmitchell Apr 15, 2022
612c4e7
Refactor migration setup and copy over some tests
ryanmitchell Apr 15, 2022
89f64e3
Make sure we return the right builder
ryanmitchell Apr 15, 2022
063955b
TermQB tests
ryanmitchell Apr 15, 2022
4e81478
Fix a few more tests on TermQB
ryanmitchell Apr 15, 2022
180f5f0
Add factories
ryanmitchell Apr 15, 2022
bafaf07
Fix up some TermQB test bugs
ryanmitchell Apr 15, 2022
08af971
Some repository tests
ryanmitchell Apr 15, 2022
7440751
NavigationRepository tests
ryanmitchell Apr 15, 2022
25c96d3
Blink models not the taxonomies
ryanmitchell Apr 17, 2022
4ac8a53
TaxonomyRepository tests
ryanmitchell Apr 17, 2022
0905f63
Change of approach on Entry origins
ryanmitchell Apr 19, 2022
98ad77d
Further changes on origins
ryanmitchell Apr 19, 2022
c9ca274
submissions_model not form model
ryanmitchell Apr 19, 2022
382c793
Use correct class name in config
ryanmitchell Apr 19, 2022
2cb233b
Fix origin issue in variables
ryanmitchell Apr 19, 2022
00563fe
Bug on globals origins
ryanmitchell Apr 20, 2022
8c01cf0
Bug in taxonomy->findbyUri
ryanmitchell Apr 20, 2022
3d9147b
Bug when deleting form submissions
ryanmitchell Apr 27, 2022
71dbb51
StyleCI
ryanmitchell Apr 27, 2022
5867849
Minimise fieldset queries (get all then filter)
ryanmitchell Apr 28, 2022
d9ecde0
Define the parent relationship on entries
ryanmitchell May 6, 2022
ffb59d4
Define the author relationship on entries
ryanmitchell May 6, 2022
810cc9c
Bug in AssetContainer delete
ryanmitchell May 9, 2022
8f00e25
Match paginate in core
ryanmitchell May 19, 2022
020905b
Fix bugs in revisions
ryanmitchell May 19, 2022
e0d587b
Lets always remove any pre-existing working copies
ryanmitchell May 20, 2022
275efc4
Only delete working copies
ryanmitchell May 20, 2022
b42dcab
Remoce comments on revisions driver config
ryanmitchell May 30, 2022
8b788c3
Fix bug in TermQueryBuilder
ryanmitchell May 30, 2022
9d67fb8
Fix some bugs in taxonomy term views
ryanmitchell Jun 7, 2022
c13116b
Fix bug on taxonomy term view routes
ryanmitchell Jun 8, 2022
bd80c0c
Return Terms not LocalizedTerms
ryanmitchell Jun 14, 2022
65fb82d
Add separate config for terms
mauricewijnia Jun 28, 2022
ae371ec
Merge pull request #2 from mauricewijnia/feature/separate-term-config
ryanmitchell Jun 30, 2022
f444073
Fixed various unit tests
FrittenKeeZ Jul 13, 2022
c64e6cc
Removed unnecessary collection change migration for new installs
FrittenKeeZ Jul 13, 2022
93ef911
Added Pint config and cleanup
FrittenKeeZ Jul 13, 2022
62e8bf2
DRY
FrittenKeeZ Jul 13, 2022
6a227fa
Added `composer test` script for `vendor\bin\phpunit`
FrittenKeeZ Jul 13, 2022
dab7aba
Readability and consistency
FrittenKeeZ Jul 13, 2022
6a59d3e
Inlining
FrittenKeeZ Jul 13, 2022
9d290a1
Database column naming consistency
FrittenKeeZ Jul 13, 2022
6be4364
Added AssetContainer::fillFromModel method to reduce code duplication
FrittenKeeZ Jul 13, 2022
c89a2a2
Merge pull request #3 from FrittenKeeZ/unit-tests-and-cleanup
ryanmitchell Jul 13, 2022
9552a07
Merge remote-tracking branch 'upstream/master' into fixes-to-all-mode…
ryanmitchell Jul 14, 2022
91ff2f8
Added indexes to all tables
FrittenKeeZ Jul 15, 2022
df2fae8
Updated entries constraints
FrittenKeeZ Jul 15, 2022
9a3dac5
Bug fix on findTaxonomyHandleByUri
ryanmitchell Jul 25, 2022
89f8418
Some missed column name changes
ryanmitchell Jul 28, 2022
de02ee5
Revert "Some missed column name changes"
ryanmitchell Jul 28, 2022
cccf60a
fix typo in config name
Jul 29, 2022
49d105e
allow to publish migrations to prevent interference with existing mig…
Jul 29, 2022
ec2f21d
Fixed foreign reference table
FrittenKeeZ Aug 3, 2022
e6332bd
Missing blueprint facade on import
ryanmitchell Aug 3, 2022
e8f468f
Merge pull request #5 from teamnovu/bugfix/config-name-for-table-prefix
ryanmitchell Aug 4, 2022
308462b
Merge pull request #6 from teamnovu/feature/make-migrations-publishable
ryanmitchell Aug 4, 2022
b7ae423
Fix form import
ryanmitchell Aug 7, 2022
2696798
Simplify
ryanmitchell Aug 7, 2022
9f91d21
Update collection import
ryanmitchell Aug 7, 2022
8e392fe
Fix blueprint import
ryanmitchell Aug 7, 2022
c5c2eb6
Fix navs import
ryanmitchell Aug 7, 2022
0a319f2
Fix Terms import
ryanmitchell Aug 7, 2022
6765e46
Bug fixes
ryanmitchell Aug 7, 2022
6812122
Missed one instanceOf change
ryanmitchell Aug 7, 2022
893de90
Use imported name
ryanmitchell Aug 8, 2022
1b3f05c
Merge branch 'fixes-to-all-models-pr' into migration-optimizations
FrittenKeeZ Aug 8, 2022
53cd8db
Various import and performance fixes
FrittenKeeZ Aug 9, 2022
031a40b
Fixed fieldset repository loading
FrittenKeeZ Aug 9, 2022
1f32829
Combined optional fields to settings
FrittenKeeZ Aug 9, 2022
a8a6b4a
Merge pull request #4 from FrittenKeeZ/migration-optimizations
ryanmitchell Aug 9, 2022
7f55c5d
Added import of assets metadata
FrittenKeeZ Aug 10, 2022
af8b230
Use imports where possible
FrittenKeeZ Aug 10, 2022
774ee2a
Remove redundant attributes
FrittenKeeZ Aug 10, 2022
cb82064
Added import for revisions
FrittenKeeZ Aug 10, 2022
ae04896
Ensure imported blueprint sections are ordered correctly
FrittenKeeZ Aug 10, 2022
e3191f1
Merge pull request #9 from FrittenKeeZ/import-updates
ryanmitchell Aug 10, 2022
4e5f57f
Set imported asset timestamps according to last modified
FrittenKeeZ Aug 11, 2022
0eeaba9
Merge branch 'fixes-to-all-models-pr' into import-timestamps
FrittenKeeZ Aug 11, 2022
bd3c9e4
Use file last modified as timestamps for imports
FrittenKeeZ Aug 11, 2022
1e33341
Fix event firing bug
ryanmitchell Aug 11, 2022
4e05347
Added microtime precision to form submissions
FrittenKeeZ Aug 11, 2022
785c4a9
Added missing sync calls
FrittenKeeZ Aug 11, 2022
67f452e
Merge pull request #10 from FrittenKeeZ/import-timestamps
ryanmitchell Aug 11, 2022
8a078d4
Revert "Fix event firing bug"
ryanmitchell Aug 11, 2022
a39d053
Apply pagination params properly in Entry Query Builder
ryanmitchell Aug 12, 2022
46de559
Fix issues on TermQueryBuilder
ryanmitchell Aug 12, 2022
681d20d
Bug fixes from test suite
ryanmitchell Aug 12, 2022
5de1bc2
Initial try at supporting whereCollection() in term query builder
ryanmitchell Aug 12, 2022
5cd7644
Wrong namespace
ryanmitchell Aug 15, 2022
b63cb15
Wrong model being called
ryanmitchell Aug 15, 2022
a92aa22
Fixes from taxonomy tests
ryanmitchell Aug 17, 2022
5f5dba5
Get substitute tests working
ryanmitchell Aug 17, 2022
90e0f18
Add a bit more detail to the readme file
ryanmitchell Aug 19, 2022
2284c0b
Typo
ryanmitchell Aug 19, 2022
86ca38b
Better wording
ryanmitchell Aug 19, 2022
3f7ed06
Bug in Entry->find
ryanmitchell Aug 21, 2022
4a6e45a
Allow nulling of models
ryanmitchell Aug 21, 2022
d5c5bec
Handle find() method in query builders
ryanmitchell Aug 21, 2022
4113272
More changes to get test suite passing
ryanmitchell Aug 21, 2022
5f5183f
Skip JSON tests on sqlite
ryanmitchell Aug 21, 2022
339aa08
We need Statamic 3.3.31+
ryanmitchell Aug 21, 2022
dcdb763
Revert change
ryanmitchell Aug 22, 2022
040bfea
Bug fix
ryanmitchell Aug 29, 2022
540fac4
Update readme
ryanmitchell Sep 1, 2022
928e39a
Cleanup
ryanmitchell Sep 1, 2022
25480a0
Bug fix
ryanmitchell Sep 1, 2022
8ac7467
Handle last modified so its available on entries/terms
ryanmitchell Sep 1, 2022
d202ffd
Test fix
ryanmitchell Sep 1, 2022
7284dbb
Bug fixes in substitutions
ryanmitchell Sep 1, 2022
f838c82
eloquent_driver --> eloquent-driver
ryanmitchell Sep 1, 2022
2378c64
Update tests config path
ryanmitchell Sep 1, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_size = 2
10 changes: 7 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ jobs:

strategy:
matrix:
php: [7.4, 7.3]
laravel: [8.*]
php: [8.0, 8.1]
laravel: [8.*, 9.*]
dependency-version: [prefer-lowest, prefer-stable]

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }}
Expand All @@ -23,12 +23,16 @@ jobs:
uses: actions/checkout@v1

- name: Setup PHP
uses: shivammathur/setup-php@v1
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extension-csv: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick
coverage: none

- name: Set PHP 8.1 Testbench
run: composer require "orchestra/testbench ^6.22.0" --no-interaction --no-update
if: matrix.laravel == '8.*' && matrix.php >= 8.1

- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
composer.lock
vendor
.phpunit.result.cache
.php_cs.cache
33 changes: 28 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

This package provides support for storing your Statamic data in a database rather than the filesystem.

This driver currently supports entries but not taxonomies, navigations, globals, or form submissions. We'll be working on those in the future.

## Installation

Install using Composer:
Expand All @@ -26,18 +24,43 @@ If you're starting from scratch, we can use traditional incrementing integers fo

- Delete `content/collections/pages/home.md`
- Change the structure `tree` in `content/collections/pages.yaml` to `{}`.
- Run `php artisan vendor:publish --provider="Statamic\Eloquent\ServiceProvider" --tag=migrations"`.
- Run `php artisan vendor:publish --tag="statamic-eloquent-entries-table"`.
- Run `php artisan migrate`.

### Starting from an existing site (using UUIDs)

If you're planning to use existing content, we can use the existing UUIDs. This will prevent you from needing to update any data or relationships.

- In the `config/statamic/eloquent-driver.php` file, change `model` to `UuidEntryModel`.
- In the `config/statamic/eloquent-driver.php` file, change `model` to `\Statamic\Eloquent\Entries\UuidEntryModel`.
- Run `php artisan vendor:publish --provider="Statamic\Eloquent\ServiceProvider" --tag=migrations"`.
- Run `php artisan vendor:publish --tag="statamic-eloquent-entries-table-with-string-ids"`.
- Run `php artisan migrate`.
- Import entries into database with `php please eloquent:import-entries`.

## Configuration

The configuration file (`statamic.eloquent-driver`) allows you to choose which repositories you want to be driven by eloquent. By default, all are selected, but if you want to opt out simply change `driver` from `eloquent` to `file` for that repository.

You may also specify your own models for each repository, should you wish to use something different from the one provided.

## Importing existing file based content

We have provided imports from file based content for each repository, which can be run as follows:

- Assets: `php please eloquent:import-assets`
- Blueprints and Fieldsets: `php please eloquent:import-blueprints`
- Collections: `php please eloquent:import-collections`
- Entries: `php please eloquent:import-entries`
- Forms: `php please eloquent:import-forms`
- Globals: `php please eloquent:import-globals`
- Navs: `php please eloquent:import-navs`
- Revisions: `php please eloquent:import-revisions`
- Taxonomies: `php please eloquent:import-taxonomies`

## Storing Users in a Database

Statamic has a[ built-in users eloquent driver](https://statamic.dev/tips/storing-users-in-a-database) if you'd like to cross that bridge too.
Statamic has a [built-in users eloquent driver](https://statamic.dev/tips/storing-users-in-a-database) if you'd like to cross that bridge too.

## Mixed driver entries and collections

This driver **does not** make it possible to have some collections/entries file driven and some eloquent driven. If that is your requirement you may want to look into using [Runway](https://statamic.com/addons/duncanmcclean/runway).
8 changes: 7 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,17 @@
}
},
"require": {
"statamic/cms": "^3.0"
"php": "^8.0",
"statamic/cms": "^3.3.31"
},
"require-dev": {
"doctrine/dbal": "^3.3",
"orchestra/testbench": "^6.7.0 || ^7.0",
"phpunit/phpunit": "^9.4"
},
"scripts": {
"test": "phpunit"
},
"config": {
"allow-plugins": {
"pixelfear/composer-dist-plugin": true
Expand Down
57 changes: 57 additions & 0 deletions config/eloquent-driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,65 @@

return [

'connection' => env('STATAMIC_ELOQUENT_CONNECTION', ''),
'table_prefix' => env('STATAMIC_ELOQUENT_PREFIX', ''),

'assets' => [
'driver' => 'eloquent',
'container_model' => \Statamic\Eloquent\Assets\AssetContainerModel::class,
'model' => \Statamic\Eloquent\Assets\AssetModel::class,
],

'blueprints' => [
'driver' => 'eloquent',
'blueprint_model' => \Statamic\Eloquent\Fields\BlueprintModel::class,
'fieldset_model' => \Statamic\Eloquent\Fields\FieldsetModel::class,
],

'collections' => [
'driver' => 'eloquent',
'model' => \Statamic\Eloquent\Collections\CollectionModel::class,
'tree' => \Statamic\Eloquent\Structures\CollectionTree::class,
'tree_model' => \Statamic\Eloquent\Structures\TreeModel::class,
],

'entries' => [
'driver' => 'eloquent',
'model' => \Statamic\Eloquent\Entries\EntryModel::class,
'entry' => \Statamic\Eloquent\Entries\Entry::class,
],

'forms' => [
'driver' => 'eloquent',
'model' => \Statamic\Eloquent\Forms\FormModel::class,
'submission_model' => \Statamic\Eloquent\Forms\SubmissionModel::class,
],

'global_sets' => [
'driver' => 'eloquent',
'model' => \Statamic\Eloquent\Globals\GlobalSetModel::class,
'variables_model' => \Statamic\Eloquent\Globals\VariablesModel::class,
],

'navigations' => [
'driver' => 'eloquent',
'model' => \Statamic\Eloquent\Structures\NavModel::class,
'tree' => \Statamic\Eloquent\Structures\NavTree::class,
'tree_model' => \Statamic\Eloquent\Structures\TreeModel::class,
],

'revisions' => [
'driver' => 'eloquent',
'model' => \Statamic\Eloquent\Revisions\RevisionModel::class,
],

'taxonomies' => [
'driver' => 'eloquent',
'model' => \Statamic\Eloquent\Taxonomies\TaxonomyModel::class,
],

'terms' => [
'driver' => 'eloquent',
'model' => \Statamic\Eloquent\Taxonomies\TermModel::class,
],
];
24 changes: 24 additions & 0 deletions database/migrations/create_asset_containers_table.php.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Statamic\Eloquent\Database\BaseMigration as Migration;

return new class extends Migration {
public function up()
{
Schema::create($this->prefix('asset_containers'), function (Blueprint $table) {
$table->id();
$table->string('handle')->unique();
$table->string('title');
$table->string('disk');
$table->json('settings')->nullable();
$table->timestamps();
});
}

public function down()
{
Schema::dropIfExists($this->prefix('asset_containers'));
}
};
23 changes: 23 additions & 0 deletions database/migrations/create_asset_table.php.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Statamic\Eloquent\Database\BaseMigration as Migration;

return new class extends Migration {
public function up()
{
Schema::create($this->prefix('assets_meta'), function (Blueprint $table) {
$table->id();
$table->string('handle')->index();
$table->json('data')->nullable();
$table->timestamps();
});
}


public function down()
{
Schema::dropIfExists($this->prefix('assets_meta'));
}
};
73 changes: 73 additions & 0 deletions database/migrations/create_blueprints_table.php.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Schema;
use Statamic\Eloquent\Database\BaseMigration as Migration;

return new class extends Migration {
public function up()
{
Schema::create($this->prefix('blueprints'), function (Blueprint $table) {
$table->id();
$table->string('namespace')->nullable()->default(null)->index();
$table->string('handle');
$table->json('data');
$table->timestamps();

$table->unique(['handle', 'namespace']);
});

$this->seedDefaultBlueprint();
}

public function down()
{
Schema::dropIfExists($this->prefix('blueprints'));
}

public function seedDefaultBlueprint()
{
try {
$config = json_encode([
'fields' => [
[
'field' => [
'type' => 'markdown',
'display' => 'Content',
'localizable' => true,
],
'handle' => 'content',
],
[
'field' => [
'type' => 'users',
'display' => 'Author',
'default' => 'current',
'localizable' => true,
'max_items' => 1,
],
'handle' => 'author',
],
[
'field' => [
'type' => 'template',
'display' => 'Template',
'localizable' => true,
],
'handle' => 'template',
],
],
]);
} catch (\JsonException $e) {
$config = '[]';
}

DB::table($this->prefix('blueprints'))->insert([
'namespace' => null,
'handle' => 'default',
'data' => $config,
'created_at' => Carbon::now(),
]);
}
};
23 changes: 23 additions & 0 deletions database/migrations/create_collections_table.php.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Statamic\Eloquent\Database\BaseMigration as Migration;

return new class extends Migration {
public function up()
{
Schema::create($this->prefix('collections'), function (Blueprint $table) {
$table->id();
$table->string('handle')->unique();
$table->string('title');
$table->json('settings')->nullable();
$table->timestamps();
});
}

public function down()
{
Schema::dropIfExists($this->prefix('collections'));
}
};
40 changes: 0 additions & 40 deletions database/migrations/create_entries_table.php

This file was deleted.

Loading