Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Cannot declare class when running migration from PHAR#364

Unanswered
underdpt asked this question inQ&A
Discussion options

Hello,

I've added some migrations to SQLITE on one laravel-zero project (v 8.9.1), and added thedatabase folder tobox.json. It works from source perfectly, but when running from PHAR I get:

❯ php .\enlazador migrate***************************************     Application In Production!     *************************************** Do you really wish to run this command? (yes/no) [no]: > yesPHP Fatal error:  Cannot declare class AddTableFacturas, because the name is already in use in phar://D:/desarrollos/mclehm/tpv/enlazador/builds/enlazador/database/migrations/2021_07_24_151855_add_table_facturas.php on line 7In 2021_07_24_151855_add_table_facturas.php line 7:  Cannot declare class AddTableFacturas, because the name is already in use

This is silly because that class is only declared on that file. I've searched for related issues without any luck. I guess the file is being loaded twice but I've been unable to find where. Anyone else has had this issue?

You must be logged in to vote

Replies: 3 comments

Comment options

I've the same issue.

box.json

{    "chmod": "0755",    "directories": [        "app",        "bootstrap",        "config",        "vendor",        "database"    ],    "files": [        "composer.json"    ],    "exclude-composer-files": false,    "compression": "GZ",    "compactors": [        "KevinGH\\Box\\Compactor\\Php",        "KevinGH\\Box\\Compactor\\Json"    ]}

In develop site (before compiling) only a AccountsMigrate in databse/migrations. Any more on path/development

  • Build app
  • Put in server
  • Run a artisan command for deploy app. In this command there are a$this->call('migrate');
php cpanel-api app:setupDirectory already exists: /usr/local/cpanel-api/databaseFile already exists: /usr/local/cpanel-api/database/database.sqliteDirectory already exists: /usr/local/cpanel-api/filesDirectory already exists: /usr/local/cpanel-api/logs                                                                                                                                                                                                                                        APPLICATION IN PRODUCTION.  Do you really wish to run this command? (yes/no) [no]❯ yes   INFO  Running migrations.[2023-06-15 17:32:09] production.ERROR: Cannot declare class AccountsMigrate, because the name is already in use {"exception":"[object] (Symfony\\Component\\ErrorHandler\\Error\\FatalError(code: 0): Cannot declare class AccountsMigrate, because the name is already in use at phar:///root/cpanel-api/database/migrations/2021_05_11_175421_accounts_migrate.php:7)[stacktrace]#0 {main}"}In 2021_05_11_175421_accounts_migrate.php line 7:  Cannot declare class AccountsMigrate, because the name is already in use
You must be logged in to vote
0 replies
Comment options

Oh my god. I see a mistake.

my project is old...

And code for one migration is very old with older format

class AccountsMigrate extends Migration{   /**    * Run the migrations.    *    * @return void    */   public function up()   {       Schema::create('accounts_migrate', function (Blueprint $table) {           $table->id();           $table->string('account');           $table->string('domain');           $table->string('email');           $table->boolean('dispatched_email')->default(false);           $table->timestamps();       });   }   /**    * Reverse the migrations.    *    * @return void    */   public function down()   {       Schema::dropIfExists('users');   }}

I changed forreturn new class extends Migration insteadclass AccountsMigrate extends Migration and work fine.

You must be logged in to vote
0 replies
Comment options

Thanks@abkrim

I don't remember how I solved it, I'm sorry I forgot to update this issue. Thanks for reporting the solution.

Also... saludos desde mainsip.com ;-)

You must be logged in to vote
0 replies
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
2 participants
@underdpt@abkrim

[8]ページ先頭

©2009-2025 Movatter.jp