-
Notifications
You must be signed in to change notification settings - Fork 31
Import by foreign key #367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ | |
| * | ||
| * @author Oliver Klee <[email protected]> | ||
| * @author Tatevik Grigoryan <[email protected]> | ||
| * @SuppressWarnings(PHPMD.TooManyPublicMethods) | ||
| */ | ||
| class SubscriberRepository extends AbstractRepository implements PaginatableRepositoryInterface | ||
| { | ||
|
|
@@ -41,6 +42,11 @@ public function findOneByUniqueId(string $uniqueId): ?Subscriber | |
| return $this->findOneBy(['uniqueId' => $uniqueId]); | ||
| } | ||
|
|
||
| public function findOneByForeignKey(string $foreignKey): ?Subscriber | ||
| { | ||
| return $this->findOneBy(['foreignKey' => $foreignKey]); | ||
| } | ||
|
|
||
| public function findSubscribersBySubscribedList(int $listId): ?Subscriber | ||
| { | ||
| return $this->createQueryBuilder('s') | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace PhpList\Core\Migrations; | ||
|
|
||
| use Doctrine\DBAL\Platforms\PostgreSQLPlatform; | ||
| use Doctrine\DBAL\Schema\Schema; | ||
| use Doctrine\Migrations\AbstractMigration; | ||
|
|
||
| final class Version20251103SeedInitialAdmin extends AbstractMigration | ||
| { | ||
| public function getDescription(): string | ||
| { | ||
| return 'Seed initial admin user'; | ||
| } | ||
|
|
||
| public function up(Schema $schema): void | ||
| { | ||
| $platform = $this->connection->getDatabasePlatform(); | ||
| $this->skipIf(!$platform instanceof PostgreSQLPlatform, sprintf( | ||
| 'Unsupported platform for this migration: %s', | ||
| get_class($platform) | ||
| )); | ||
|
|
||
| $this->addSql(<<<'SQL' | ||
| INSERT INTO phplist_admin (id, created, modified, loginname, namelc, email, password, passwordchanged, disabled, superuser, privileges) | ||
| VALUES (1, NOW(), NOW(), 'admin', 'admin', '[email protected]', :hash, CURRENT_DATE, FALSE, TRUE, :privileges) | ||
| ON CONFLICT (id) DO UPDATE | ||
| SET | ||
| modified = EXCLUDED.modified, | ||
| privileges = EXCLUDED.privileges | ||
| SQL, [ | ||
| 'hash' => hash('sha256', 'password'), | ||
| 'privileges' => 'a:4:{s:11:"subscribers";b:1;s:9:"campaigns";b:1;s:10:"statistics";b:1;s:8:"settings";b:1;}', | ||
| ]); | ||
| } | ||
|
|
||
| public function down(Schema $schema): void | ||
| { | ||
| $platform = $this->connection->getDatabasePlatform(); | ||
| $this->skipIf(!$platform instanceof PostgreSQLPlatform, sprintf( | ||
| 'Unsupported platform for this migration: %s', | ||
| get_class($platform) | ||
| )); | ||
|
|
||
| $this->addSql('DELETE FROM phplist_admin WHERE id = 1'); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expose conflicting identifiers in the error.
Right now the translator string we bubble up is just “Conflict: email and foreign key refer to different subscribers.” so operators never learn which email/foreign key pair triggered the skip. Without that context the CSV owner has no actionable clue which row to fix, which is a regression in usability compared to the other error paths where we embed %email%. Please include the DTO context in the message before returning.
Apply this diff to preserve the conflict check while surfacing the identifiers:
🤖 Prompt for AI Agents