nathanheffley / laravel-watermelon

Easily set up a sync endpoint to support Watermelon DB in your Laravel projects.
MIT License
44 stars 13 forks source link

Migrations support #8

Open rafwell opened 9 months ago

rafwell commented 9 months ago

Hi!

This package support migrations implementation? I did a test here but the new columns who I've added aren't pulled then sync.

nathanheffley commented 9 months ago

Did you update your model's $watermelonAttributes?

class Task extends Model
{
    use SoftDeletes, Watermelon;

    protected array $watermelonAttributes = [
        'content',
        'is_completed',
    ];
}
rafwell commented 7 months ago

Hi!

Yes. I think it really was missing in this package. Take a look on my implementation: https://github.com/rafwell/laravel-watermelon/commit/01dd6bf38be0ada2524e116cdd0912434f4e2f0f

I'm basing on this https://watermelondb.dev/docs/Sync/Backend#implementing-pull-endpoint who said 6. If migration is not null, you MUST include records needed to get a consistent view after a local database migration Now i'm getting the new columns when columns has change by migration. I think the same must be did for new tables, if you like I can do it via PR.

nathanheffley commented 7 months ago

Ohhh yes I see. Yes if you opened a PR that would be fantastic. Would you also be able to add a feature test where it demonstrates pulling records when there is a column that has been migrated?