These are the errors - Exception trace:
PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name ''")
C:\wamp64\www\fyp\vendor\laravel\framework\src\Illuminate\Database\Connection.php:457
PDO::prepare("create table `
(idbigint unsigned not null auto_increment primary key,log_namevarchar(191) null,descriptiontext not null,subject_idbigint unsigned null,subject_typevarchar(191) null,causer_idbigint unsigned null,causer_typevarchar(191) null,propertiestext null,created_attimestamp null,updated_at` timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci'")
C:\wamp64\www\fyp\vendor\laravel\framework\src\Illuminate\Database\Connection.php:457
Hey,
seems like your table name isn't configured.
It's used in the migration.
https://github.com/spatie/laravel-activitylog/blob/0b16f4e5ac45c14312ffa8bf25db737d92de27cd/migrations/create_activity_log_table.php.stub#L14
how do I go about solving this issue thanks
Have you followed the installation instructions?
https://docs.spatie.be/laravel-activitylog/v3/installation-and-setup/
yes I have I'm even follwing the tutorial for activity log
Could you post your current config please?
migration
public function up()
{
Schema::connection(config('activitylog.database_connection'))->create(config('activity_log.table_name'), function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('log_name')->nullable();
$table->text('description');
$table->unsignedBigInteger('subject_id')->nullable();
$table->string('subject_type')->nullable();
$table->unsignedBigInteger('causer_id')->nullable();
$table->string('causer_type')->nullable();
$table->text('properties')->nullable();
$table->timestamps();
$table->index('log_name');
$table->index(['subject_id', 'subject_type'], 'subject');
$table->index(['causer_id', 'causer_type'], 'causer');
});
}
/**
* Reverse the migrations.
*/
public function down()
{
Schema::connection(config('activitylog.database_connection'))->dropIfExists(config('activitylog.table_name'));
}
config
return [
/*
* If set to false, no activities will be saved to the database.
*/
'enabled' => env('ACTIVITY_LOGGER_ENABLED', true),
/*
* When the clean-command is executed, all recording activities older than
* the number of days specified here will be deleted.
*/
'delete_records_older_than_days' => 365,
/*
* If no log name is passed to the activity() helper
* we use this default log name.
*/
'default_log_name' => 'default',
/*
* You can specify an auth driver here that gets user models.
* If this is null we'll use the default Laravel auth driver.
*/
'default_auth_driver' => null,
/*
* If set to true, the subject returns soft deleted models.
*/
'subject_returns_soft_deleted_models' => false,
/*
* This model will be used to log activity.
* It should be implements the Spatie\Activitylog\Contracts\Activity interface
* and extend Illuminate\Database\Eloquent\Model.
*/
'activity_model' => \Spatie\Activitylog\Models\Activity::class,
/*
* This is the name of the table that will be created by the migration and
* used by the Activity model shipped with this package.
*/
'table_name' => 'activity_log',
/*
* This is the database connection that will be used by the migration and
* the Activity model shipped with this package. In case it's not set
* Laravel database.default will be used instead.
*/
'database_connection' => env('ACTIVITY_LOGGER_DB_CONNECTION'),
];
terminal command - catch (Exception $e) {
669| throw new QueryException(
670| $query, $this->prepareBindings($bindings), $e
671| );
672| }
673|
Exception trace:
1 PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name ''")
C:\wamp64\www\fyp\vendor\laravel\framework\src\Illuminate\Database\Connection.php:457
2 PDO::prepare("create table `(idbigint unsigned not null auto_increment primary key,log_namevarchar(191) null,descriptiontext not null,subject_idbigint unsigned null,subject_typevarchar(191) null,causer_idbigint unsigned null,causer_typevarchar(191) null,propertiestext null,created_attimestamp null,updated_at` timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci'")
C:\wamp64\www\fyp\vendor\laravel\framework\src\Illuminate\Database\Connection.php:457
Please use the argument -v to see more details.
PS C:\wamp64\www\fyp> php artisan migrate
Hey, have spotted the issue.
There's an underscore in your config key name.
- Schema::connection(config('activitylog.database_connection'))->create(config('activity_log.table_name'), function (Blueprint $table) {
+ Schema::connection(config('activitylog.database_connection'))->create(config('activitylog.table_name'), function (Blueprint $table) {
There's still an underscore in the config key name.
This has to be changed everywhere you have it right now.
- config('activity_log.table_name')
+ config('activitylog.table_name')
Hi I've done that I'm still getting the same issue, I've changed it to activitylog in my config and migrations file
Exception trace:
1 PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name ''")
C:\wamp64\www\fyp\vendor\laravel\framework\src\Illuminate\Database\Connection.php:457
2 PDO::prepare("create table `(idbigint unsigned not null auto_increment primary key,log_namevarchar(191) null,descriptiontext not null,subject_idbigint unsigned null,subject_typevarchar(191) null,causer_idbigint unsigned null,causer_typevarchar(191) null,propertiestext null,created_attimestamp null,updated_at` timestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci'")
C:\wamp64\www\fyp\vendor\laravel\framework\src\Illuminate\Database\Connection.php:457
Could you please dump config('activitylog.table_name') in your migration file?
dd(config('activitylog.table_name'));
hi it comes as null
PS C:\wamp64\www\fyp> php artisan migrate
Migrating: 2020_02_24_133430_create_activitylog_table
null
And without the table_name - so the whole activitylog config.
dd(config('activitylog'));
And without the
table_name- so the wholeactivitylogconfig.
dd(config('activitylog'));
PS C:\wamp64\www\fyp> php artisan migrate
Migrating: 2020_02_24_133430_create_activitylog_table
null
same
In this case your config isn't named correctly or you develope with a cached config.
If it's the second: you should never cache the config or routes on your local machine during development.
php artisan config:clear
In this case your config isn't named correctly or you develope with a cached config.
If it's the second: you should never cache the config or routes on your local machine during development.php artisan config:clear
oh I've done that now I'm getting this error
1 array_key_exists([])
C:\wamp64\www\fyp\vendor\laravel\framework\src\Illuminate\Support\Arr.php:151
2 Illuminate\Support\Arr::exists([])
C:\wamp64\www\fyp\vendor\laravel\framework\src\Illuminate\Support\Arr.php:292
Please use the argument -v to see more details.
Could you run with -v for a verbose output and a full stack-trace?
It would be important to see where the Arr:xyz is called from. If it's even in this packages code or something totally different.
Could you run with
-vfor a verbose output and a full stack-trace?
It would be important to see where theArr:xyzis called from. If it's even in this packages code or something totally different.
hi i get this error
PS C:\wamp64\www\fyp> -v
-v : The term '-v' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the
name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
-v
~~
CategoryInfo : ObjectNotFound: (-v:String) [], CommandNotFoundException
FullyQualifiedErrorId : CommandNotFoundException
With with -v I meant with and not only. ๐
php artisan migrate -v
With
with -vI meant with and not only. ๐php artisan migrate -v
my bad, okay this is what i got
1 array_key_exists([])
C:\wamp64\www\fyp\vendor\laravel\framework\src\Illuminate\Support\Arr.php:151
2 Illuminate\Support\Arr::exists([])
C:\wamp64\www\fyp\vendor\laravel\framework\src\Illuminate\Support\Arr.php:292
3 Illuminate\Support\Arr::get([])
C:\wamp64\www\fyp\vendor\laravel\framework\src\Illuminate\Database\DatabaseManager.php:151
4 Illuminate\Database\DatabaseManager::configuration()
C:\wamp64\www\fyp\vendor\laravel\framework\src\Illuminate\Database\DatabaseManager.php:115
5 Illuminate\Database\DatabaseManager::makeConnection()
C:\wamp64\www\fyp\vendor\laravel\framework\src\Illuminate\Database\DatabaseManager.php:86
6 Illuminate\Database\DatabaseManager::connection()
C:\wamp64\www\fyp\vendor\laravel\framework\src\Illuminate\Support\Facades\Schema.php:31
7 Illuminate\Support\Facades\Schema::connection()
C:\wamp64\www\fyp\database\migrations\2020_02_24_133430_create_activitylog_table.php:14
8 CreateActivityLogTable::up()
C:\wamp64\www\fyp\vendor\laravel\framework\src\Illuminate\Database\Migrations\Migrator.php:392
9 Illuminate\Database\Migrations\Migrator::Illuminate\Database\Migrations{closure}()
C:\wamp64\www\fyp\vendor\laravel\framework\src\Illuminate\Database\Migrations\Migrator.php:401
10 Illuminate\Database\Migrations\Migrator::runMigration(Object(CreateActivityLogTable), "up")
C:\wamp64\www\fyp\vendor\laravel\framework\src\Illuminate\Database\Migrations\Migrator.php:200
11 Illuminate\Database\Migrations\Migrator::runUp("C:\wamp64\www\fyp\database\migrations/2020_02_24_133430_create_activitylog_table.php")
C:\wamp64\www\fyp\vendor\laravel\framework\src\Illuminate\Database\Migrations\Migrator.php:165
12 Illuminate\Database\Migrations\Migrator::runPending([])
C:\wamp64\www\fyp\vendor\laravel\framework\src\Illuminate\Database\Migrations\Migrator.php:110
13 Illuminate\Database\Migrations\Migrator::run([])
C:\wamp64\www\fyp\vendor\laravel\framework\src\Illuminate\Database\Console\Migrations\MigrateCommand.php:71
14 Illuminate\Database\Console\Migrations\MigrateCommand::handle()
C:\wamp64\www\fyp\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:32
15 call_user_func_array([])
C:\wamp64\www\fyp\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:32
16 Illuminate\Container\BoundMethod::Illuminate\Container{closure}()
C:\wamp64\www\fyp\vendor\laravel\framework\src\Illuminate\Container\Util.php:36
17 Illuminate\Container\Util::unwrapIfClosure(Object(Closure))
C:\wamp64\www\fyp\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:90
18 Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Object(Closure))
C:\wamp64\www\fyp\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:34
19 Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), [])
C:\wamp64\www\fyp\vendor\laravel\framework\src\Illuminate\Container\Container.php:590
20 Illuminate\Container\Container::call()
C:\wamp64\www\fyp\vendor\laravel\framework\src\Illuminate\Console\Command.php:134
21 Illuminate\Console\Command::execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
C:\wamp64\www\fyp\vendor\symfony\console\Command\Command.php:255
22 Symfony\Component\Console\Command\Command::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
C:\wamp64\www\fyp\vendor\laravel\framework\src\Illuminate\Console\Command.php:121
23 Illuminate\Console\Command::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
C:\wamp64\www\fyp\vendor\symfony\console\Application.php:1012
24 Symfony\Component\Console\Application::doRunCommand(Object(Illuminate\Database\Console\Migrations\MigrateCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
C:\wamp64\www\fyp\vendor\symfony\console\Application.php:272
25 Symfony\Component\Console\Application::doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
C:\wamp64\www\fyp\vendor\symfony\console\Application.php:148
26 Symfony\Component\Console\Application::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
C:\wamp64\www\fyp\vendor\laravel\framework\src\Illuminate\Console\Application.php:93
27 Illuminate\Console\Application::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
C:\wamp64\www\fyp\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php:131
28 Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
C:\wamp64\www\fyp\artisan:37
With
with -vI meant with and not only. ๐php artisan migrate -v
how do I solve it?
@Kushal-u1462694
consider checking your current config via laravel's brilliant repl: tinker
run:
php artisan tinker
enter config('activitylog') then press enter and show us the output
@Kushal-u1462694
consider checking your current config via laravel's brilliant repl: tinkerrun:
php artisan tinkerthen enter
config('activitylog')and press enter
hi this is what I'm getting
PS C:\wamp64\www\fyp> php artisan tinker
Psy Shell v0.9.12 (PHP 7.3.5 โ cli) by Justin Hileman
config('activitylog')
=> [
"enabled" => true,
"delete_records_older_than_days" => 365,
"default_log_name" => "default",
"default_auth_driver" => null,
"subject_returns_soft_deleted_models" => false,
"activity_model" => "Spatie\Activitylog\Models\Activity",
"table_name" => "activitylog",
"database_connection" => true,
]
"database_connection" => true, looks weird to me
default config is:
'database_connection' => env('ACTIVITY_LOGGER_DB_CONNECTION'),
did you set that var in your .env file?
also consider doing a fresh db state with:
php artisan config:clear
php artisan db:wipe //only local with dummy data ;)
php artisan migrate:fresh
also paste an output of config('database') but consider hiding/cleaning secrets before pasting here!
"database_connection" => true,looks weird to medefault config is:
'database_connection' => env('ACTIVITY_LOGGER_DB_CONNECTION'),did you set that var in your
.envfile?also consider doing a fresh db state with:
php artisan config:clear php artisan db:wipe //only local with dummy data ;) php artisan migrate:freshalso paste an output of
config('database')but consider hiding/cleaning secrets before pasting here!
Hi, my env file is
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:VtO8UZ9tA3SyOmCr7GYp+o0xG4XGzqZY9ZkrTq3Kw6w=
APP_DEBUG=true
APP_URL=http://localhost
ACTIVITY_LOGGER_DB_CONNECTION=true
You have to delete this line ACTIVITY_LOGGER_DB_CONNECTION=true - it uses your default connection by default.
You have to delete this line
ACTIVITY_LOGGER_DB_CONNECTION=true- it uses your default connection by default.
thank you soo much guys it's working it's migrated
Thanks @mstaack for your help here! ๐
Most helpful comment
thank you soo much guys it's working it's migrated