Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laravel Autoincrement

Laravel Autoincrement Laravel Package

rorecek/laravel-autoincrement

A small Laravel utility for working with auto-increment IDs, offering helpers to inspect and manage increment values on Eloquent models and tables.

View on GitHub
Deep Wiki
Context7

Set table AUTO_INCREMENT values in your Laravel application

Frequently asked questions about Laravel Autoincrement
How do I install rorecek/laravel-autoincrement in a Laravel application?
Install it with Composer using composer require rorecek/laravel-autoincrement, then check the package composer.json for the supported Laravel and PHP version constraints before running it against a real schema. Because the package is small and has a low install base, pin an explicit version in composer.json rather than floating on a wildcard constraint. Most teams only need it available in deployment or migration tooling, so confirm whether it must be installed in production at all. Run a quick migration and rollback test on a schema clone before relying on it.
Which database engines does laravel-autoincrement support?
The package targets tables that use MySQL-style AUTO_INCREMENT, which in practice means MySQL and MariaDB. AUTO_INCREMENT is not portable: PostgreSQL manages sequences with setval, and SQLite uses rowid and AUTOINCREMENT semantics that behave differently. If your application supports multiple drivers, do not assume the helper works everywhere and verify each engine explicitly. For PostgreSQL, a small internal helper around setval is usually the safer choice.
Can I set a table AUTO_INCREMENT value inside a Laravel migration?
Yes, migrations are the intended use case, since setting a starting ID is a schema operation that belongs alongside table creation. Put the call in the up method and consider what the down method should do, because rollback behaviour is often a gap in thin schema utilities. Review the SQL the package generates before merging, and test the migration plus rollback against a production-like schema. Avoid calling it from request-path code, controllers, or model events.
Does laravel-autoincrement support Laravel 11 and Laravel 12 and PHP 8.x?
Support depends entirely on the version constraints declared in the package composer.json, so read those first rather than assuming. The package has a very small footprint and a low star count, which means framework compatibility updates may lag behind new Laravel releases. Test the install on the exact Laravel and PHP versions you deploy, ideally in a throwaway branch with your real migrations. If constraints block a current Laravel version, a two-line DB::statement is a reasonable substitute.
How do I reset the AUTO_INCREMENT value after a data import or seeder run?
Point the helper at the table and pass the next ID you want allocated, typically the highest existing ID plus one. Setting a value lower than the current maximum ID will not take effect in MySQL, since the engine always allocates above the highest existing row. Run the reset after the import completes and verify the next inserted record receives the expected ID. Document which tables and ID ranges the operation touches so future deployments do not silently collide.
Is it safe to change AUTO_INCREMENT on a large production table?
Changing the auto-increment counter is a DDL operation, and on large tables it can take a metadata lock and extend deploy duration, so schedule it in a maintenance window with operations sign-off. The database user needs ALTER privileges on the table, which application users often do not have. Test against a production-like schema clone with foreign keys and existing data to see the actual locking behaviour. Do not introduce this during a high-risk release.
Does laravel-autoincrement protect against SQL injection in table names?
Table and column names cannot be bound as parameters in DDL, so any package that builds ALTER TABLE statements must quote and validate identifiers itself. The safe pattern is to pass literal table names from your own code and never interpolate user input, request data, or tenant-supplied strings. Review how the helper builds identifiers before use, and wrap it behind an internal function if you need a single audited entry point. If you cannot confirm quoting behaviour, use raw SQL you have reviewed instead.
What happens if the table does not exist or the database user lacks ALTER privileges?
Expect a database exception from the underlying query rather than a silent no-op, since the package ultimately issues DDL against a named table. That means deployment scripts should fail loudly and stop rather than continuing with a partially applied schema state. Check for the table's existence and required grants before calling the helper in automated pipelines. Keep a documented manual SQL fallback for operators when privileges are restricted.
Is rorecek/laravel-autoincrement actively maintained and tested?
The package has a small public following and appears to be a single-maintainer utility, so treat ecosystem confidence as low and community support as GitHub-only with no vendor SLA. Look for a test suite and CI configuration in the repository before adopting, since DDL behaviour across drivers is easy to get wrong. Monitor upstream activity and Laravel compatibility, and be prepared to fork or replace it with an internal migration helper. Its low code footprint makes replacement cheap if it goes stale.
What are the alternatives to using this package for auto-increment management?
The most common alternative is a single DB::statement with ALTER TABLE your_table AUTO_INCREMENT = value placed in a migration or deployment script that your team has reviewed. For PostgreSQL, an internal helper calling setval on the relevant sequence is the equivalent. Many teams add a small private helper class behind a flag so the logic is testable and easy to swap out. Given the package's size, an in-house helper often costs less than carrying an unmaintained dependency.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console