Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions migrations/Version20250731202312.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20250731202312 extends AbstractMigration
{
public function getDescription(): string
{
return '';
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! I see this migration was generated via doctrine:migrations:diff on a different local setup. It contains a lot of noise (index renames, default/colllation/type changes) that aren’t part of the feature and may break existing data (e.g. new UNIQUE constraints on server_product).

Could you please:

  • Rebase on current main and regenerate a clean migration that includes only the intentional changes from this PR (e.g. the free-trial columns)?
  • Drop unrelated index renames and type/default flips (unless there’s a mapping change that explicitly requires them and we agree on it).
  • Confirm whether the new UNIQUE constraints are intended; if not, please revert them.

I try to keep migrations minimal and deterministic so different environments don’t fight over names/collations. Thanks!

}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
// $this->addSql('CREATE TABLE user_payment (id INT AUTO_INCREMENT NOT NULL, session_id VARCHAR(255) NOT NULL, status VARCHAR(255) DEFAULT NULL, amount NUMERIC(10, 2) NOT NULL, currency VARCHAR(3) NOT NULL, balance_amount NUMERIC(10, 2) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME DEFAULT NULL, used_voucher INT DEFAULT NULL, user_id INT NOT NULL, INDEX IDX_35259A0794458029 (used_voucher), INDEX IDX_35259A07A76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4');
// $this->addSql('ALTER TABLE user_payment ADD CONSTRAINT FK_35259A0794458029 FOREIGN KEY (used_voucher) REFERENCES voucher (id)');
// $this->addSql('ALTER TABLE user_payment ADD CONSTRAINT FK_35259A07A76ED395 FOREIGN KEY (user_id) REFERENCES user (id)');
$this->addSql('DROP INDEX IDX_1F1B251A7D3656A4 ON log');
$this->addSql('ALTER TABLE payment RENAME INDEX idx_6a2b8e0d4f34d596 TO IDX_6D28840D94458029');
$this->addSql('ALTER TABLE product CHANGE eggs_configuration eggs_configuration VARCHAR(255) DEFAULT NULL, CHANGE allow_change_egg allow_change_egg TINYINT(1) NOT NULL, CHANGE schedules schedules INT NOT NULL');
$this->addSql('ALTER TABLE product_price ADD has_free_trial TINYINT(1) NOT NULL, ADD free_trial_value INT DEFAULT NULL, ADD free_trial_unit VARCHAR(255) DEFAULT NULL, CHANGE product_id product_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE product_price RENAME INDEX fk_3d3a3d3a4584665a TO IDX_6B9459854584665A');
$this->addSql('DROP INDEX IDX_5C7E2D3A7D3656A4 ON server_log');
$this->addSql('ALTER TABLE server_log CHANGE details details LONGTEXT DEFAULT NULL');
$this->addSql('ALTER TABLE server_log RENAME INDEX user_id TO IDX_B1F6629FA76ED395');
$this->addSql('ALTER TABLE server_log RENAME INDEX server_id TO IDX_B1F6629F1844E6B7');
$this->addSql('ALTER TABLE server_product DROP INDEX FK_3D3A3D3A4584665A63441329, ADD UNIQUE INDEX UNIQ_A1341F111844E6B7 (server_id)');
$this->addSql('ALTER TABLE server_product DROP INDEX FK_3D3A3D3A4584666312335B70, ADD UNIQUE INDEX UNIQ_A1341F11283311CE (original_product_id)');
$this->addSql('ALTER TABLE server_product CHANGE nodes nodes JSON DEFAULT NULL, CHANGE eggs eggs JSON DEFAULT NULL, CHANGE eggs_configuration eggs_configuration VARCHAR(255) DEFAULT NULL, CHANGE allow_change_egg allow_change_egg TINYINT(1) NOT NULL, CHANGE schedules schedules INT NOT NULL');
$this->addSql('ALTER TABLE server_product_price ADD has_free_trial TINYINT(1) NOT NULL, ADD free_trial_value INT DEFAULT NULL, ADD free_trial_unit VARCHAR(255) DEFAULT NULL');
$this->addSql('ALTER TABLE server_product_price RENAME INDEX fk_3d3a3d33a4612265a TO IDX_CD394789974BF6FD');
$this->addSql('DROP INDEX UNIQ_server_subuser_server_user ON server_subuser');
$this->addSql('ALTER TABLE server_subuser RENAME INDEX idx_server_subuser_server_id TO IDX_2658BF7E1844E6B7');
$this->addSql('ALTER TABLE server_subuser RENAME INDEX idx_server_subuser_user_id TO IDX_2658BF7EA76ED395');
$this->addSql('ALTER TABLE user CHANGE created_at created_at DATETIME NOT NULL');
$this->addSql('ALTER TABLE voucher RENAME INDEX uniq_voucher_code TO UNIQ_1392A5D877153098');
$this->addSql('ALTER TABLE voucher_usage RENAME INDEX idx_voucher_id TO IDX_1550084E28AA1B6F');
$this->addSql('ALTER TABLE voucher_usage RENAME INDEX idx_user_id TO IDX_1550084EA76ED395');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
// $this->addSql('ALTER TABLE user_payment DROP FOREIGN KEY FK_35259A0794458029');
// $this->addSql('ALTER TABLE user_payment DROP FOREIGN KEY FK_35259A07A76ED395');
// $this->addSql('DROP TABLE user_payment');
$this->addSql('CREATE INDEX IDX_1F1B251A7D3656A4 ON log (created_at)');
$this->addSql('ALTER TABLE payment RENAME INDEX idx_6d28840d94458029 TO IDX_6A2B8E0D4F34D596');
$this->addSql('ALTER TABLE product CHANGE schedules schedules INT DEFAULT 10 NOT NULL, CHANGE eggs_configuration eggs_configuration LONGTEXT DEFAULT NULL, CHANGE allow_change_egg allow_change_egg TINYINT(1) DEFAULT 0 NOT NULL');
$this->addSql('ALTER TABLE product_price DROP has_free_trial, DROP free_trial_value, DROP free_trial_unit, CHANGE product_id product_id INT NOT NULL');
$this->addSql('ALTER TABLE product_price RENAME INDEX idx_6b9459854584665a TO FK_3D3A3D3A4584665A');
$this->addSql('ALTER TABLE server_log CHANGE details details TEXT DEFAULT NULL');
$this->addSql('CREATE INDEX IDX_5C7E2D3A7D3656A4 ON server_log (created_at)');
$this->addSql('ALTER TABLE server_log RENAME INDEX idx_b1f6629fa76ed395 TO user_id');
$this->addSql('ALTER TABLE server_log RENAME INDEX idx_b1f6629f1844e6b7 TO server_id');
$this->addSql('ALTER TABLE server_product DROP INDEX UNIQ_A1341F111844E6B7, ADD INDEX FK_3D3A3D3A4584665A63441329 (server_id)');
$this->addSql('ALTER TABLE server_product DROP INDEX UNIQ_A1341F11283311CE, ADD INDEX FK_3D3A3D3A4584666312335B70 (original_product_id)');
$this->addSql('ALTER TABLE server_product CHANGE schedules schedules INT DEFAULT 10 NOT NULL, CHANGE nodes nodes LONGTEXT DEFAULT NULL COLLATE `utf8mb4_bin`, CHANGE eggs eggs LONGTEXT DEFAULT NULL COLLATE `utf8mb4_bin`, CHANGE eggs_configuration eggs_configuration LONGTEXT DEFAULT NULL, CHANGE allow_change_egg allow_change_egg TINYINT(1) DEFAULT 0 NOT NULL');
$this->addSql('ALTER TABLE server_product_price DROP has_free_trial, DROP free_trial_value, DROP free_trial_unit');
$this->addSql('ALTER TABLE server_product_price RENAME INDEX idx_cd394789974bf6fd TO FK_3D3A3D33A4612265A');
$this->addSql('CREATE UNIQUE INDEX UNIQ_server_subuser_server_user ON server_subuser (server_id, user_id)');
$this->addSql('ALTER TABLE server_subuser RENAME INDEX idx_2658bf7e1844e6b7 TO IDX_server_subuser_server_id');
$this->addSql('ALTER TABLE server_subuser RENAME INDEX idx_2658bf7ea76ed395 TO IDX_server_subuser_user_id');
$this->addSql('ALTER TABLE user CHANGE created_at created_at DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL');
$this->addSql('ALTER TABLE voucher RENAME INDEX uniq_1392a5d877153098 TO UNIQ_VOUCHER_CODE');
$this->addSql('ALTER TABLE voucher_usage RENAME INDEX idx_1550084e28aa1b6f TO IDX_VOUCHER_ID');
$this->addSql('ALTER TABLE voucher_usage RENAME INDEX idx_1550084ea76ed395 TO IDX_USER_ID');
}
}
31 changes: 31 additions & 0 deletions migrations/Version20250801080659.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20250801080659 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add is_on_free_trial field to server table to track servers created with free trial';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE server ADD is_on_free_trial TINYINT(1) DEFAULT 0 NOT NULL');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE server DROP is_on_free_trial');
}
}
33 changes: 33 additions & 0 deletions migrations/Version20250801084437.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20250801084437 extends AbstractMigration
{
public function getDescription(): string
{
return '';
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty description

}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE product CHANGE eggs_configuration eggs_configuration LONGTEXT DEFAULT NULL');
$this->addSql('ALTER TABLE server_product CHANGE eggs_configuration eggs_configuration LONGTEXT DEFAULT NULL');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE product CHANGE eggs_configuration eggs_configuration VARCHAR(255) DEFAULT NULL');
$this->addSql('ALTER TABLE server_product CHANGE eggs_configuration eggs_configuration VARCHAR(255) DEFAULT NULL');
}
}
31 changes: 31 additions & 0 deletions migrations/Version20250802083129.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20250802083129 extends AbstractMigration
{
public function getDescription(): string
{
return '';
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty description

}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE server_product DROP INDEX UNIQ_A1341F11283311CE, ADD INDEX IDX_A1341F11283311CE (original_product_id)');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE server_product DROP INDEX IDX_A1341F11283311CE, ADD UNIQUE INDEX UNIQ_A1341F11283311CE (original_product_id)');
}
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty migration file

Empty file.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty migration file

Empty file.
31 changes: 31 additions & 0 deletions migrations/Version20250802175001.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Add recharge minimum and maximum amount settings
*/
final class Version20250802175001 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add recharge minimum and maximum amount settings';
}

public function up(Schema $schema): void
{
$this->addSql('INSERT INTO setting (name, value, type, context) VALUES (\'recharge_min_amount\', \'0.50\', \'number\', \'payment_settings\')');
$this->addSql('INSERT INTO setting (name, value, type, context) VALUES (\'recharge_max_amount\', \'1000.00\', \'number\', \'payment_settings\')');
}

public function down(Schema $schema): void
{
$this->addSql('DELETE FROM setting WHERE name = \'recharge_min_amount\'');
$this->addSql('DELETE FROM setting WHERE name = \'recharge_max_amount\'');
}
}
11 changes: 10 additions & 1 deletion src/Core/Contract/ProductPriceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,17 @@ public function setUnit(ProductPriceUnitEnum $unit): self;
public function getPrice(): float;
public function setPrice(float $price): self;

public function hasFreeTrial(): bool;
public function setHasFreeTrial(bool $hasFreeTrial): self;

public function getFreeTrialValue(): ?int;
public function setFreeTrialValue(?int $value): self;

public function getFreeTrialUnit(): ?ProductPriceUnitEnum;
public function setFreeTrialUnit(?ProductPriceUnitEnum $unit): self;

public function getDeletedAt(): ?\DateTime;
public function setDeletedAt(?\DateTime $deletedAt): self;

public function __toString(): string;
}
}
13 changes: 13 additions & 0 deletions src/Core/Controller/BalanceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ public function rechargeBalance(

$currency = $this->settingService
->getSetting(SettingEnum::CURRENCY_NAME->value);

$minAmount = (float) $this->settingService
->getSetting(SettingEnum::RECHARGE_MIN_AMOUNT->value);

$maxAmount = (float) $this->settingService
->getSetting(SettingEnum::RECHARGE_MAX_AMOUNT->value);

$form = $this->createFormBuilder()
->add('amount', MoneyType::class, [
Expand All @@ -38,6 +44,10 @@ public function rechargeBalance(
$this->translator->trans('pteroca.recharge.recharge_amount'),
$currency
),
'attr' => [
'min' => $minAmount,
'max' => $maxAmount,
],
])
->add('currency', HiddenType::class, [
'data' => $currency,
Expand All @@ -49,6 +59,9 @@ public function rechargeBalance(
return $this->render('panel/wallet/recharge.html.twig', [
'form' => $form->createView(),
'balance' => $this->getUser()->getBalance(),
'min_amount' => $minAmount,
'max_amount' => $maxAmount,
'currency' => $currency,
]);
}

Expand Down
Loading
Loading