phplaravelstripe-paymentslaravel-cashier

I can't launch migrations after installing stripe cashier in Laravel


I already have a fairly advanced project made with Laravel in which I have my database with the tables, views and their functionalities, my idea now is to use stripe to make purchases, reading the documentation that used the composer command require laravel/cashier and after this php artisan migrate so that stripe creates its fields inside the users table, the problem comes here, stripe expects me to have a table called users but my table is called usuarios, is there no way to tell stripe that my table usuarios is this the users table are waiting for? The other solution that occurs to me is to create a new migration called users, but I don't see much sense in having a table called users and other usuarios in the same database. Users and usuarios are the same, they have the same meaning but in Spanish.enter image description here

I have tried creating a new migration of user calls, leaving the one I have as usuarios, although it doesn't make much sense. This way works for me, but I have two tables called users


Solution

  • Publish Cashier migrations in order to edit them, the one you have to edit should be a migration named create_customer_columns:

    By default, it will attempt to add the columns to the users table, as should be a common practice to have it like so, edit the migration like this:

    public function up(): void
    {
        Schema::table('usuarios', function (Blueprint $table) {
            $table->string('stripe_id')->nullable()->index();
            $table->string('pm_type')->nullable();
            $table->string('pm_last_four', 4)->nullable();
            $table->timestamp('trial_ends_at')->nullable();
        });
    }
    
    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('usuarios', function (Blueprint $table) {
            $table->dropColumn([
                'stripe_id',
                'pm_type',
                'pm_last_four',
                'trial_ends_at',
            ]);
      
    

    Change the users table name, to your usuarios table name, and you should have it working.