We're trying to sort a view with draggableviews 7.x - 2.0 but when attempting to save the we get the following error:
An AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: /admin/structure/views/ajax/preview/jnytt_modul_nyhetsslider/panel_pane_2/387
StatusText: error
ResponseText: PDOException: SQLSTATE[HY000]: General error: 1364 Field 'nid'
doesn't have a default value: INSERT INTO {draggableviews_structure} (view_name,
view_display, args, entity_id, weight) VALUES (:db_insert_placeholder_0,
:db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3,
:db_insert_placeholder_4); Array
(
[:db_insert_placeholder_0] => jnytt_modul_nyhetsslider
[:db_insert_placeholder_1] => panel_pane_2
[:db_insert_placeholder_2] => ["387"]
[:db_insert_placeholder_3] => 9988
[:db_insert_placeholder_4] => 0
)
Anyone else who have had this problem and found a solution because I sure as h*** can't find one :(
It seems that your db table draggableviews_structure has a field nid that needs a default value. This is outdated because the version 2.x of draggableviews uses entity_id instead. Maybe you upgraded from 1.x to 2.x which is not possible.
There is no upgrade path from 7.x-1.x to 7.x-2.x branch
http://drupal.org/project/draggableviews
So either reinstall to module or edit the database table manually. I would suggest reinstalling via devel
Related
I am setting up a Laravel solution where I want to use a SQLite database configured as in memory database.
I have the following configuration for this:
.env:
DB_CONNECTION_DATA=sqlite
DB_DATABASE_DATA=:memory:
database.php:
...
'sqlite' => [
'driver' => 'sqlite',
'url' => env('DATABASE_URL'),
'database' => env('DB_DATABASE_DATA'),
'prefix' => '',
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
],
Migration works fine with this configuration but seeding fails with error message:
SQLSTATE[HY000]: General error: 1 no such table: permissions (SQL: select * from "permissions")
I have googled around to find a solution for this and found this package:
laravel-sqlite-named-memory-connection
Here it is described that:
It connects to SQLite's in-memory database as well as :memory:. :memory: creates a new database for each connection, whereas :named-memory:<name> returns the same connection if <name> is same.
So I assume that this is the explanation why seeding does not work because it is run in another connection than the migrations so the database does not exist for the seeding connection.
I could then use this package to solve this but the challenge is that it seem to be set up for Laravel 7, not 8 which I use and has not been updated for the last 3 years.
Anyone know if there are similar, more up to date, packages available or other ways to configure this?
PS: In googling I have found solutions in context of test use but I want to use this in production.
Tried:
php artisan db:seed PermissionsSeeder
Got error message:
SQLSTATE[HY000]: General error: 1 no such table: permissions (SQL: select * from "permissions")
Expected:
Successful seeding.
Also tried:
composer require crhg/laravel-sqlite-named-memory-connection
Got error message:
Info from https://repo.packagist.org: #StandWithUkraine
Using version ^1.1 for crhg/laravel-sqlite-named-memory-connection
./composer.json has been updated
Running composer update crhg/laravel-sqlite-named-memory-connection
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- crhg/laravel-sqlite-named-memory-connection[v1.1.0, ..., v1.1.2] require illuminate/support ^5.5 || ^6.0 -> found illuminate/support[v5.5.0, ..., 5.8.x-dev, v6.0.0, ..., 6.x-dev] but these were not loaded, likely because it conflicts with another require.
- crhg/laravel-sqlite-named-memory-connection v1.1.3 requires illuminate/support ^5.5 || ^6.0 || ^7.0 -> found illuminate/support[v5.5.0, ..., 5.8.x-dev, v6.0.0, ..., 6.x-dev, v7.0.0, ..., 7.x-dev] but these were not loaded, likely because it conflicts with another require.
- Root composer.json requires crhg/laravel-sqlite-named-memory-connection ^1.1 -> satisfiable by crhg/laravel-sqlite-named-memory-connection[v1.1.0, v1.1.1, v1.1.2, v1.1.3].
You can also try re-running composer require with an explicit version constraint, e.g. "composer require crhg/laravel-sqlite-named-memory-connection:*" to figure out if any version is installable, or "composer require crhg/laravel-sqlite-named-memory-connection:^2.1" if you know which you need.
Expected:
Successful package installation.
I'm attempting to create a database using the doctrine orm with an application built by someone else. I'm getting Database errors, and I'm unsure if I'm unclear on the concept, or if I need to adjust the Annotations.
Command and output:
php bin/console doctrine:schema:validate
Mapping
-------
[OK] The mapping files are correct.
Database
--------
15:06:28 ERROR [console] Error thrown while running command "doctrine:schema:validate". Message: "Invalid index-name unique_organization_id_application_id given, has to be [a-zA-Z0-9_]" ["error" => Doctrine\DBAL\Schema\SchemaException { …},"command" => "doctrine:schema:validate","message" => "Invalid index-name unique_organization_id_application_id given, has to be [a-zA-Z0-9_]"] []
[Doctrine\DBAL\Schema\SchemaException]
Invalid index-name unique_organization_id_application_id given, has to be [a-zA-Z0-9_]
It almost sounds like the database isn't set up properly(though I thought this was the first step before setting up the database schema)
The annotation:
#ORM\Table(name="applications", uniqueConstraints={#UniqueConstraint(name="unique_organization_id_application_id", columns={"organization_id", "application_id"})})
And this is where I'm out of my depth. organizationId and applicationId are both private members(?) of the class, with getters and setters. unique_organization_id_application_id isn't found anywhere in the class.
Invalid index-name unique_organization_id_application_id given, has to be [a-zA-Z0-9_]
The error says that you inserted some non-english letters in the index name. Try to completly remove the name.
I'm always receiving "Unauthenticated error" when using Passport in my current project. That's what I did the lasts 3 days:
Install and configure Passport (as docs says)
Request a token (password grant token) with Postman
Request a protected route (auth:api middleware) with the token
Get
`{ "error": "Unauthenticated." }`
Search and search and research
Get
`{ "error": "Unauthenticated." }`
Then, I've installed a fresh L5.3 and a fresh DB and works fine. Even with my current DB!
I've tried all the solutions that I found without success ...
Can anyone help me? Any idea would be appreciated.
Thanks.
I had the same problem as you and looked everywhere to find a solution.
It appeared to be Apache's fault in my case. Apache was deleting the header "Authorization: Bearer TOKEN_HERE" so the auth:api wouldn't work as expected (getting 401 unauthorized).
We ended up trying adding to our .htaccess:
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
And it magically worked.
I really hope it helps, we spent a whole day trying many solutions, this is the one that worked for us.
Which grant_type have you used to generate this token?
Possible resolutions are as follows
1: If you are using client credentials to generate your access_token, you have to turn on client_credentials, middleware as follows.
1.1 Add to the routeMiddleware in \App\Http\Kernel.php
'client_credentials' => \Laravel\Passport\Http\Middleware\CheckClientCredentials::class,
1.2 Use 'client_credentials' middleware in your route too.
Route::group(['prefix' => 'v1','middleware' => 'client_credentials'], function () {
// Your routes here
});
2: For Grant Type Password
2.1 : Create a Password Grant Client
php artisan passport:client --password
2.2 : Request A token with following header fields
'grant_type' => 'password',
'client_id' => 'client-id',
'client_secret' => 'client-secret',
'username' => 'taylor#laravel.com',
'password' => 'my-password',
End point /oauth/token
The token you get now should give you access to your api.
My problem was an omision, I'm building a GraphQL api and in the middleware line at the configuration file "graphql.php" I put
'middleware' => ['auth'],
when the correct way is:
'middleware' => ['auth:api'],
check your user model has
use Laravel\Passport\HasApiTokens;
instead of
use Laravel\Sanctum\HasApiTokens;
and used HasApiTokens as a trait;
Whenever I run php artisan migrate, the following error is shown in the console:
[PDOException]
SQLSTATE[HY000] [14] unable to open database file
The database.sqlite file is located at database/. I'm running Windows 10, Laravel 5.2. Here is .env file config:
.env:
DB_CONNECTION=sqlite
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=database
DB_USERNAME=homestead
DB_PASSWORD=secret
I have looked everywhere, but could not find what causes this error and how to resolve it.
Update
I managed to make migrations run successfully by replacing DB_DATABASE=database with DB_DATABASE=database/database.sqlite in .env file. However, new error occurs whenever I try to retrieve items from the database:
public function index()
{
// cause of the error
$cards = Card::all();
return view('cards.index', compact('cards'));
}
The above action throws following error:
InvalidArgumentException in SQLiteConnector.php line 34:
Database (database/database.sqlite) does not exist.
The strange thing is, that the command Card::all() works flawlessly in php artisan tinker mode. What kind of magic is that?
Anyway, I've also found out, that the line:
'database' => env('DB_DATABASE', database_path('database.sqlite')),
in database.php file needs to be replaced with just database_path('database.sqlite') and everything starts to work normally.
It seems, that the root of the problem is env('DB_DATABASE') call. I went to SQLiteConnector.php file and dumped the output of both env('DB_DATABASE') and database_path('database.sqlite'). Here are their outputs respectively:
dd(env('DB_DATABASE')) // => 'database/database.sqlite'
dd(database_path('database.sqlite')) // => 'D:\www\project\database\database.sqlite'
As you see, their output differs, and the second one is what is expected. Is this a Laravel bug? Or did I misunderstood something?
Short Solution
Though not answering the question, the way to fix "Database not found" issue is to replace the following line in database.php:
'database' => env('DB_DATABASE', database_path('database.sqlite')),
with
'database' => database_path('database.sqlite'),
By using the relative path, migrations will fail because they use project directory as root directory...
To correct everything, I suggest setting:
DB_DATABASE=database\database.sqlite
and tweaking the sqlite connections in config/database.php as follows:
'database' => env('DB_DATABASE/..', database_path('database.sqlite')),
Original Answer
The .env file should contain this:
DB_DATABASE=..\database\database.sqlite
With some testing you can verify that the link included in DB_DATABASE
is relative to the 'public' directory (at least on my Windows machine). That's why we should introduce ..\ before your link.
And of course, using an absolute link should do it too:
DB_DATABASE=D:\www\project\database\database.sqlite
as #Josh suggests
Create file called database.sqlite in this folder as database/database.sqlite
Open the .env file and change MySQL to SQLite
Comment password and username and databaseName using '#'
run php artisan migrate enjoy
env file like this:
DB_CONNECTION=sqlite
#DB_HOST=127.0.0.1
#DB_PORT=3306
#DB_DATABASE=database
#DB_USERNAME=homestead
#DB_PASSWORD=secret
Complementing the awnser by our friend #alexander-lomia
Change:
'database' => env('DB_DATABASE', database_path('database.sqlite'))
To:
'database' => database_path(env('DB_DATABASE'))
in database.php
:)
Instead of a relative path you need to use an absolute path in your .env file.
DB_DATABASE=/var/www/project/database/database.sqlite
or in your case:
DB_DATABASE=D:\www\project\database\database.sqlite
I got the same problem as you did. You have to use the absolute path in ENV file.
Please check the official documentation about this https://laravel.com/docs/5.4/database
DB_CONNECTION=sqlite
DB_DATABASE=/absolute/path/to/database.sqlite
This worked for me in Laravel 5.5
In .env file just have the connection name and remove all other DB_ related settings: DB_CONNECTION=sqlite_testing
Define your sqlite settings in the config/database.php file:
'connections' => [
'sqlite_testing' => [
'driver' => 'sqlite',
'database' => database_path('testing-db.sqlite'),
'prefix' => '',
],
...
]
My file is in the database/testing-db.sqlite.
Shortest and easiest solution is to remove default mysql settings in .env and work in database.php. That's what worked for me at least.
Remove the following...
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
I found the following works rather well, if you prefer to use relative paths:
replace the 'database' line under SQLite with the following:
'database' => database_path(env('DB_DATABASE', 'database.sqlite')),
This was the setting I had used,
'sqlite' => [
'driver' => 'sqlite',
'database' => database_path('database.sqlite'),
'prefix' => '',
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
],
I also had to run touch database.sqlite in the database folder.
The problem is that php artisan migrate will use the DB_DATABASE from the root of the project, while serving the project with php artisan serve will run from the public directory.
The best solution for me is to create a link to database inside public directory:
UNIX: ln -s database public/database
Windows: mklink /J public\database database
Of course then you would have to deny access to database folder from HTTP requests but that should be easily done.
I am trying to get FOSElasticaBundle to work.
ElasticSearch Instance is running on localhost:9200 and responding.
I followed each step in the docs https://github.com/FriendsOfSymfony/FOSElasticaBundle/blob/master/Resources/doc/setup.md
but at the last step, I get this error in my console:
c:\xampp\htdocs\my\folder>php app/console fos:elastica:populate
Resetting app
Fatal error: Wrong parameters for Exception([string $exception [, long $code [,
Exception $previous = NULL]]]) in C:\xampp\htdocs\my\folder\vendor\rufli
n\elastica\lib\Elastica\Exception\ResponseException.php on line 34
[Symfony\Component\Debug\Exception\FatalErrorException]
Error: Wrong parameters for Exception([string $exception [, long $code [, Exception $previous = NULL]]])
fos:elastica:populate [--index[="..."]] [--type[="..."]] [--no-reset] [--offset="..."] [--sleep="..."] [--batch-size="..."] [--ignore-errors] [--no-overwrite-format]
It seems like there are 3 parameters mandatory for "__construct"-Function, but there are only 2 of them. I've simply tried to add "NULL"-parameter to get it work, but then another function throws an error.
public function __construct(Request $request, Response $response)
{
$this->_request = $request;
$this->_response = $response;
parent::__construct($response->getError());
}
Is this a common problem? How do I solve it?
This is because the ruflin/Elastica package is not compatible with elasticsearch 2.0 yet.
https://github.com/ruflin/Elastica/issues/946
An alternative for now (until ruflin/Elastica is 2.0 upgraded), is to use the latest 1.x version.
You can download it here: https://www.elastic.co/downloads/past-releases/elasticsearch-1-7-3
ES 1.7.3 + FosElasticaBundle (which uses ruflin/Elastica) works fine with Elasticsearch 1.7.3 version.
The reason for this issue is, that with elasticsearch 2.0 the structure of the response error changed (more details here: https://github.com/ruflin/Elastica/issues/946). Instead of a string before it is now a nested array. Elastica is currently not yet fully compatible with elasticsearch 2.0. As soon as a new release of Elastica is out which is compatible with Elasticsearch 2.0 it will probably mean that also foselastica bundle will have to be updated as these changes will break backward compatibility. Be also aware, that this is not the only backward compatibility breaking change.
To follow the progress of the upgrade, follow this issue: https://github.com/ruflin/Elastica/issues/946