# |
Jul 13th 2021, 17:25 |
tyler.adam.lazenby |
is there a way to call seeds within a migration? |
# |
Jul 13th 2021, 16:38 |
kevin.pfeifer |
sometimes they work pretty well :) |
# |
Jul 13th 2021, 16:37 |
tyler.adam.lazenby |
You got gifs to work huh? |
# |
Jul 13th 2021, 16:35 |
kevin.pfeifer |
calm down |
# |
Jul 13th 2021, 16:31 |
tyler.adam.lazenby |
HistoryTypesSeed and MessageTypesSeed |
# |
Jul 13th 2021, 16:31 |
tyler.adam.lazenby |
I was running two different seeds and didn't even realize |
# |
Jul 13th 2021, 16:31 |
tyler.adam.lazenby |
Nevermind guys |
# |
Jul 13th 2021, 16:29 |
tyler.adam.lazenby |
it does that |
# |
Jul 13th 2021, 16:28 |
tyler.adam.lazenby |
even if I truncate it |
# |
Jul 13th 2021, 16:25 |
tyler.adam.lazenby |
yes |
# |
Jul 13th 2021, 16:25 |
kevin.pfeifer |
does your `id` column have a `AUTO_INCREMENT` on it? |
# |
Jul 13th 2021, 16:23 |
tyler.adam.lazenby |
if I remove the duplicate |
# |
Jul 13th 2021, 16:23 |
tyler.adam.lazenby |
the email is duplicated yes but the seed still fails |
# |
Jul 13th 2021, 16:23 |
tyler.adam.lazenby |
nevermind |
# |
Jul 13th 2021, 16:23 |
tyler.adam.lazenby |
goddamnit |
# |
Jul 13th 2021, 16:23 |
tyler.adam.lazenby |
oh wait |
# |
Jul 13th 2021, 16:22 |
tyler.adam.lazenby |
```$data = [ [ 'name' => 'Email', 'description' => 'Emails sent to contact', ], [ 'name' => 'Text', 'description' => 'Texts sent to contact', ], [ 'name' => 'Other', 'description' => 'Other histories', ], [ 'name' => 'Email', 'description' => 'Email sent to contact', ] ];``` |
# |
Jul 13th 2021, 16:22 |
tyler.adam.lazenby |
But my seed doesn't even reference the primary key |
# |
Jul 13th 2021, 16:22 |
tyler.adam.lazenby |
Integrity constraint violation: 1062 Duplicate entry '1' for key 'PRIMARY' in C:\Users\TylerLazenby\Documents\ezBusinessManager2\vendor\robmorgan\phinx\src\Phinx\Db\Adapte r\PdoAdapter.php on line 339 |
# |
Jul 13th 2021, 16:22 |
tyler.adam.lazenby |
but the issue now is that I am running into this |
# |
Jul 13th 2021, 16:22 |
tyler.adam.lazenby |
I am running seeds and I had to drop the data from the table so that I could reseed in test |
# |
Jul 13th 2021, 16:22 |
tyler.adam.lazenby |
I am also running into something else |
# |
Jul 13th 2021, 15:57 |
dereuromark |
based on the current activity just reporting might not get it fixed any time soon I would recommend a PR directly, if you want to have this rather sooner than later. |
# |
Jul 13th 2021, 15:54 |
tyler.adam.lazenby |
should I report that? |
# |
Jul 13th 2021, 15:50 |
dereuromark |
sounds like a bug then |
# |
Jul 13th 2021, 15:48 |
richard |
oh |
# |
Jul 13th 2021, 15:47 |
tyler.adam.lazenby |
`bin/cake bake migration_snapshot Initial` |
# |
Jul 13th 2021, 15:47 |
richard |
how exactly did you create it via the migrations plugin |
# |
Jul 13th 2021, 15:46 |
tyler.adam.lazenby |
but the first was actually created by the migrations plugin |
# |
Jul 13th 2021, 15:46 |
tyler.adam.lazenby |
```->addColumn('updated', 'datetime', [ 'default' => 'CURRENT_TIMESTAMP', 'limit' => null, 'null' => false, ])``` |
# |
Jul 13th 2021, 15:46 |
tyler.adam.lazenby |
It will work if I mass change it to this |
# |
Jul 13th 2021, 15:45 |
tyler.adam.lazenby |
```->addColumn('updated', 'datetime', [ 'default' => 'current_timestamp()', 'limit' => null, 'null' => false, ])``` |
# |
Jul 13th 2021, 15:45 |
kevin.pfeifer |
I can’t find any valid php function which is called `current_timestamp()` Or do you mean the MySQL function? |
# |
Jul 13th 2021, 15:41 |
tyler.adam.lazenby |
Is there a reason why the default value for datetime `current_timestamp()` is (a) generated by the snapshot command in migrations and (b) the system considers that invalid? |
# |
Jul 13th 2021, 14:59 |
tyler.adam.lazenby |
gosh dang it, I have to use an app_local file |
# |
Jul 13th 2021, 14:57 |
richard |
tired of doing sudo mysql then creating dbs/etc |
# |
Jul 13th 2021, 14:57 |
richard |
I was thinking as some sort of dev ops chain but honestly i haven’t done that either, it’s something i want to start doing more often though |
# |
Jul 13th 2021, 14:56 |
tyler.adam.lazenby |
init script huh? I have never done one of those |
# |
Jul 13th 2021, 14:55 |
richard |
also might be weird, yeah, so you’re better off just doing that part yourself as some sort of init script or something |
# |
Jul 13th 2021, 14:55 |
tyler.adam.lazenby |
yeah, but the thing about that is... migrations rufuses to run if it can't find a database connection |
# |
Jul 13th 2021, 14:55 |
richard |
i don’t think there is a db-agnostic way to do it though |
# |
Jul 13th 2021, 14:54 |
richard |
@tyler.adam.lazenby you can run any query in a migration technically, so yeah |
# |
Jul 13th 2021, 14:45 |
tyler.adam.lazenby |
so question... can migrations be programed to create a db or do I need to do that manually |
# |
Jul 13th 2021, 13:46 |
erwane |
If data are encoded with default flags, you can change it after i think. toPhp decode all data (escaped or not) toDatabase recode them with flags. I'm hot sure this should add bug. BUT this should be an option in JsonType, not default. |
# |
Jul 13th 2021, 13:43 |
dereuromark |
yeah, as expected the impact is rather small. but none the less, sounds like a more consistent data storage if done with the right flags from the beginning. one should however not change those in the middle (if data already exists). |
# |
Jul 13th 2021, 13:42 |
erwane |
```decode 1119 escaped: 0.001491s decode 1663 unescaped: 0.001954s``` |
# |
Jul 13th 2021, 13:42 |
erwane |
After more tests, not sure there is a large impact on speed. |
# |
Jul 13th 2021, 13:38 |
erwane |
weird result :S |
# |
Jul 13th 2021, 13:38 |
erwane |
with true datas : ```decode 1663 unescaped: 0.005169s decode 1119 escaped: 0.002547s``` |
# |
Jul 13th 2021, 13:14 |
erwane |
on 10'000 iteration but input is not random. Maybe internal php cache do the job. ```encode default: 0.335539s encode unescaped: 0.341111s decode escaped json: 0.426201s decode unescaped json: 0.410178s``` |
# |
Jul 13th 2021, 13:08 |
val |
but that doesn't work |
# |
Jul 13th 2021, 13:07 |
val |
I tried ``` $Query->getTypeMap() ->addDefaults([ 'Restaurant' => Restaurant::class, ]);``` |
# |
Jul 13th 2021, 13:02 |
val |
Hi, is there a way in Cake 3.x to tell the framework that the results of manual join in the query should be parsed as a model entity object (when there is no association to that's entity table)? |
# |
Jul 13th 2021, 12:17 |
dereuromark |
could be interesting to know also the impact of this - for a future default case one day as well |
# |
Jul 13th 2021, 12:17 |
dereuromark |
did you do a performance check here for lets say 1000 rows etc? |
# |
Jul 13th 2021, 12:17 |
dereuromark |
ok, sounds useful :) |
# |
Jul 13th 2021, 12:13 |
erwane |
@dereuromark cleaner json in an utf8 context (database tables encoding set to utf8 or utf8mb4). No need to escape everything i think. |
# |
Jul 13th 2021, 12:00 |
caseyw |
Thanks for that, I'll look into it! |
# |
Jul 13th 2021, 11:53 |
dereuromark |
I use it for font icons for example, to not have to search the correct names, but just to get the list of available ones. |
# |
Jul 13th 2021, 11:52 |
dereuromark |
e.g. any $this->Theme->get(..) etc would be able to give you a list of available magic strings, constants or alike to select from, at least in PHPStorm that works nicely. |
# |
Jul 13th 2021, 11:51 |
dereuromark |
I would also look into that for generating IDE specific meta data that can help to create auto complete lists. Most useful for magic strings. But also for a list of classes or constants on those. |
# |
Jul 13th 2021, 11:50 |
dereuromark |
Plugin::path() is for plugins usually, see how IdeHelper detects paths here for the plugins available. |
# |
Jul 13th 2021, 11:46 |
caseyw |
Yeah, sorry I was just meaning an example. In our system as new themes are created an old one is typically duplicated and some things change while most remain the same. I was hoping to have a dynamic way of calling the plugin specific constant without having to know the name of the Plugin itself. Someone messaged me and said App::path() might help to know the plugin dynamically, but I don't see how that would. Anyway, this is |
# |
Jul 13th 2021, 11:46 |
slackebot2 |
probably something outside the general support scope. |
# |
Jul 13th 2021, 11:42 |
dereuromark |
No, not with constants. They usually use ClassName::CONST_NAME syntax, which requires use statements. You could build a helper that does that though. Thats how I wrapped some things like Configure to be more easily accessible in the view (See Shim plugin). |
# |
Jul 13th 2021, 11:19 |
caseyw |
Ok, thanks. As far as accessing the class is there a way to initialize it into the view to make use easier? $this->ConstantClass->MARK ? |
# |
Jul 13th 2021, 10:41 |
dereuromark |
this is quite a specific case. I guess you could create some ConstantInterface that defines those, if there are different groups I suggest naming the interfaces accordingly. |
# |
Jul 13th 2021, 10:39 |
caseyw |
Hello all! I’m our software we have a number of plugins our team has made for mainly new themes, etc. im looking to create some constants on the plugin level to share in the ctp files of the plugin who owns it. Where’s the best place to setup general plugin specific constants? Im doing away with a bunch of magic numbers, etc. this is in Cake 3.9. |
# |
Jul 13th 2021, 10:19 |
paolo.bragagni |
probably I'm done |
# |
Jul 13th 2021, 10:16 |
paolo.bragagni |
mmm didnt understand |
# |
Jul 13th 2021, 10:15 |
dereuromark |
just remember all aliases you encountered, as they must be unique. |
# |
Jul 13th 2021, 10:15 |
paolo.bragagni |
I could cycle in associations but I'd like to make one only cicle |
# |
Jul 13th 2021, 10:14 |
paolo.bragagni |
how to know if the relation is BelongsToMany or HasMany in the cycle? |
# |
Jul 13th 2021, 10:14 |
dereuromark |
@erwane on the other side. Why does it need special ones? invalid syntax ignore maybe, but otherwise: as long as the same Type class is reading it again it shouldn't be a big deal |
# |
Jul 13th 2021, 10:13 |
paolo.bragagni |
and then it cyclea trough {% for alias, details in relations %} |
# |
Jul 13th 2021, 10:13 |
paolo.bragagni |
there is {% set relations = associations.BelongsToMany|merge(associations.HasMany) %} |
# |
Jul 13th 2021, 10:13 |
paolo.bragagni |
in view.twig |
# |
Jul 13th 2021, 10:13 |
paolo.bragagni |
cant go ahead in my problem.. :S |
# |
Jul 13th 2021, 10:12 |
dereuromark |
@erwane sounds like it, yeah |
# |
Jul 13th 2021, 09:50 |
charolastra |
sorry, looks like i've forgot to update setPrimaryKey() |
# |
Jul 13th 2021, 09:44 |
charolastra |
on a table with a composite key consiting of 3 fields a newEntity->save() updates an existent entity (where the 3rd key component is a boolean) instead of persisting the new one. not even doing something like $newScreening = $screening. what's going on? |
# |
Jul 13th 2021, 09:29 |
erwane |
Hi. It's a good idea to PR the `Database\Type\JsonType::toDatabase()` to allows options for json_encode like ` ```JSON_UNESCAPED_UNICODE + JSON_INVALID_UTF8_IGNORE + JSON_UNESCAPED_SLASHES``` Maybe via static `JsonType::setJsonEncodeOptions(int value)` |
# |
Jul 12th 2021, 20:24 |
kevin.pfeifer |
oh wow, the cookbook is build via the python library `cakephpsphinx` :cold_sweat: |
# |
Jul 12th 2021, 19:59 |
tyler.adam.lazenby |
are you using cannoical links with your cakephp website? |
# |
Jul 12th 2021, 19:57 |
tyler.adam.lazenby |
the company name is deprecated btw, so don't @ me for that |
# |
Jul 12th 2021, 19:57 |
tyler.adam.lazenby |
```if ($this->request->is(['POST', 'PUT'])) { $data = $this->request->getData(); $data['account_id'] = $current_user->account_id; $data['company_name'] = $current_user->account->name; $data['token'] = Security::randomString();``` ... |
# |
Jul 12th 2021, 19:57 |
tyler.adam.lazenby |
well this way works for now |
# |
Jul 12th 2021, 19:56 |
kevin.pfeifer |
or jsut a Table method if its just for 1 table/entity type |
# |
Jul 12th 2021, 19:56 |
kevin.pfeifer |
you could make a behavior which populates you empty entites with a given set of default data |
# |
Jul 12th 2021, 19:55 |
kevin.pfeifer |
well the default `newEmptyEntity` method just creates a new entity object of whatever is given to it so no default data there |
# |
Jul 12th 2021, 19:55 |
cnizzardini |
there are times where automated jobs or events trigger stuff though :man-shrugging: |
# |
Jul 12th 2021, 19:54 |
cnizzardini |
or doing things |
# |
Jul 12th 2021, 19:54 |
cnizzardini |
its not the worst thing, generally you only want a single source for creating things |
# |
Jul 12th 2021, 19:53 |
kevin.pfeifer |
maybe some other MVC gurus can give you other insights of why this needs to be done this way |
# |
Jul 12th 2021, 19:52 |
cnizzardini |
there is no way to call entity->isNew() or whatever from there to isolate it to new creations |
# |
Jul 12th 2021, 19:52 |
kevin.pfeifer |
:) |
# |
Jul 12th 2021, 19:52 |
kevin.pfeifer |
It would also be nice if the cakephp book would “remember” where I was when switching from 3 to 4 Like https://book.cakephp.org/3/en/orm/table-objects.html and then clicking on the 4.x link at the top right should lead me to https://book.cakephp.org/4/en/orm/table-objects.html |
# |
Jul 12th 2021, 19:52 |
tyler.adam.lazenby |
I just hate it |
# |
Jul 12th 2021, 19:52 |
tyler.adam.lazenby |
Kevin you might be right here |
# |
Jul 12th 2021, 19:51 |
tyler.adam.lazenby |
gosh dang it |