{"action":"created","issue":{"url":"https://api.github.com/repos/eymengunay/EoHoneypotBundle/issues/11","repository_url":"https://api.github.com/repos/eymengunay/EoHoneypotBundle","labels_url":"https://api.github.com/repos/eymengunay/EoHoneypotBundle/issues/11/labels{/name}","comments_url":"https://api.github.com/repos/eymengunay/EoHoneypotBundle/issues/11/comments","events_url":"https://api.github.com/repos/eymengunay/EoHoneypotBundle/issues/11/events","html_url":"https://github.com/eymengunay/EoHoneypotBundle/issues/11","id":54290221,"number":11,"title":"Alternate ORM configuration","user":{"login":"iisisrael","id":932987,"avatar_url":"https://avatars.githubusercontent.com/u/932987?v=3","gravatar_id":"","url":"https://api.github.com/users/iisisrael","html_url":"https://github.com/iisisrael","followers_url":"https://api.github.com/users/iisisrael/followers","following_url":"https://api.github.com/users/iisisrael/following{/other_user}","gists_url":"https://api.github.com/users/iisisrael/gists{/gist_id}","starred_url":"https://api.github.com/users/iisisrael/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iisisrael/subscriptions","organizations_url":"https://api.github.com/users/iisisrael/orgs","repos_url":"https://api.github.com/users/iisisrael/repos","events_url":"https://api.github.com/users/iisisrael/events{/privacy}","received_events_url":"https://api.github.com/users/iisisrael/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-01-14T06:50:47Z","updated_at":"2016-06-18T02:58:48Z","closed_at":null,"body":"Using the `class HoneypotPrey extends BaseHoneypotPrey` configuration as shown in the example, I was getting this error when running `app/console doctrine:schema:update --dump-sql`:\r\n```\r\n[Doctrine\\ORM\\Mapping\\MappingException]\r\nDuplicate definition of column 'id' on entity 'ExampleBundle\\Entity\\HoneypotPrey' in a field or discriminator column mapping.\r\n```\r\nI then tried extending `Eo\\HoneypotBundle\\Model\\HoneypotPrey` instead of `Eo\\HoneypotBundle\\Entity\\HoneypotPrey`, and that worked as far as the schema update was concerned.  I had two tables - `HoneypotPrey` with just the `id` column, and `honeypot_prey` with the columns `id`, `ip`, and `createdAt`.  However, after submitting some test spam registrations with the honeypot field populated with data, I was only getting new rows in the `HoneypotPrey` table (and lines appended to honeypot.log), but nothing in the `honeypot_prey` table.\r\n\r\nSo, instead, I mapped the schema like so (sorry, not a fan of annotations)...\r\n```\r\nExampleBundle\\Entity\\HoneypotPrey:\r\n    type: entity\r\n    table: HoneypotPrey\r\n    id:\r\n        id:\r\n            type:   integer\r\n            generator:\r\n                strategy: AUTO\r\n    fields:\r\n        createdAt:\r\n            type:     datetime\r\n        ip:\r\n            type:     string\r\n```\r\n... generated the entities, copied the `__construct()` method from `Eo\\HoneypotBundle\\Model\\HoneypotPrey` into my Entity class, modified my Entity class like so...\r\n```\r\nnamespace ExampleBundle\\Entity;\r\n\r\nuse Doctrine\\ORM\\Mapping as ORM;\r\nuse Eo\\HoneypotBundle\\Model\\HoneypotPreyInterface;\r\n\r\n/**\r\n * HoneypotPrey\r\n */\r\nclass HoneypotPrey implements HoneypotPreyInterface\r\n{\r\n    ...\r\n```\r\n... dropped the `honeypot_prey` table, and reran the schema update command.  I'm now getting records in my `HoneypotPrey` table...\r\n```\r\nmysql> select * from HoneypotPrey;\r\n+----+---------------------+-------------+\r\n| id | createdAt           | ip          |\r\n+----+---------------------+-------------+\r\n|  4 | 2015-01-14 00:05:56 | 172.16.61.1 |\r\n+----+---------------------+-------------+\r\n```\r\nConfigs are set like so:\r\n```\r\n# Honeypot\r\neo_honeypot:\r\n    storage:\r\n        # Record for reporting\r\n        database:\r\n            enabled: true\r\n            driver:  orm\r\n            class:   ExampleBundle:HoneypotPrey\r\n        # Log for IP banning using fail2ban\r\n        file:\r\n            enabled: true\r\n            output:  %kernel.root_dir%/logs/honeypot.log\r\n```"},"comment":{"url":"https://api.github.com/repos/eymengunay/EoHoneypotBundle/issues/comments/226918051","html_url":"https://github.com/eymengunay/EoHoneypotBundle/issues/11#issuecomment-226918051","issue_url":"https://api.github.com/repos/eymengunay/EoHoneypotBundle/issues/11","id":226918051,"user":{"login":"asentner","id":2752040,"avatar_url":"https://avatars.githubusercontent.com/u/2752040?v=3","gravatar_id":"","url":"https://api.github.com/users/asentner","html_url":"https://github.com/asentner","followers_url":"https://api.github.com/users/asentner/followers","following_url":"https://api.github.com/users/asentner/following{/other_user}","gists_url":"https://api.github.com/users/asentner/gists{/gist_id}","starred_url":"https://api.github.com/users/asentner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asentner/subscriptions","organizations_url":"https://api.github.com/users/asentner/orgs","repos_url":"https://api.github.com/users/asentner/repos","events_url":"https://api.github.com/users/asentner/events{/privacy}","received_events_url":"https://api.github.com/users/asentner/received_events","type":"User","site_admin":false},"created_at":"2016-06-18T02:58:48Z","updated_at":"2016-06-18T02:58:48Z","body":"Thanks for this. I am not a fan of annotations either. I didn't encounter the error because I built the table to match my app as far as naming conventions go.\r\n\r\nA work around is very simple. You do not have to use the provided model at all. In my case I just created my table in the ORM and generated the entity like I normally would with my own fields. Just implement `Eo\\HoneypotBundle\\Model\\HoneypotPreyInterface` in your entity to ensure you have `getIp()` and `setIp()`. You can even call the ip column something else as long as you provide the methods required by the interface. Much better for me because my table name in the db would be t_honeypot_prey and primary key honeypot_pre_id. Use your constructor to set the timestamp. On mine I use creationDate to match the rest of my tables.\r\n\r\nJust added this constructor to my class:\r\n\r\n```php\r\npublic function __construct($ip = null)\r\n{\r\n    $this->ip = $ip;\r\n    $this->creationDate = new \\DateTime();\r\n}\r\n```"}}
{"actor":{"display_login":"asentner"}}