-
Notifications
You must be signed in to change notification settings - Fork 9
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
Create migration & models #4
Comments
Yes... we should. But for that we need to confirm the db structure. Are we ok on the db design? Possible DB Design Areas to Close:
If you note, I had done some slight enhancements to the db design:
|
Latest changes looks great. |
Btw, in the migrations file we must include the indices code, since there are some DBMS that don't create indices for foreign keys automatically (e.g. PostgreSQL). |
@robregonm can you take a stab at doing the |
I have incorporated quite a few additions. Have updated the module, models, and added controllers. Check the latest committed code stack.
The names above will also help generate friendly url's. We must soon have the db migration finalized. |
nice addition to data structure: User table has a last_login_ip in addition to last_login_on. Shaping up to be a very robust data structure for user. I noticed the timestamp data type for created_on and updated_on fields. In order for me to get that working properly in my Yii2 project, I had to specify the data type in behaviors by adding: 'value' => new Expression('NOW()'), to behaviors method and use yii\db\Expression; So you might want to add that to behaviors in the BaseModel. Otherwise it might record the wrong data type or fail entirely. |
Working on |
@evercode1 for handling timestamps it depends on the DB type (mysql, sqllite, postgres, nosql etc.) which developers will be using and the Expression may not work for some DB types. Hence, I have now included a module level setting 'now' => function() {
return date('Y-m-d H:i:s');
} The above function will return value similar to |
@robregonm - great... also check if we need to have a modified |
@robregonm please pull the latest code first ... before pushing (as there are updates across)... or can submit a PR. |
BTW Migrations are really cool and can u pls make them "ongoing" and not changing the "first" one only? |
Sure, atm I'd we just use the RBAC API Yii provides, so it doesn't matter which RBAC module you've plugged into your app. There's already a PHP and DB version available.
That would be really nice, see also schmunk42/yii2-extension-requests#9 |
Migrations added and models updated with commit 06f9a68. Couple of tables and models added:
|
Cool, looks nice so far, however, IMHO the table names should be customizable, so, they shouldn't be constants. |
Added |
@robregonm, @kartik-v I created an issue for this ... #6 Why should we make the table names customizable, where's the benefit? You can choose a prefix in your db config. As mentioned in the other issue, this will break if we change the table names later and adds (IMHO unneeded) complexity and a dependency to the migration. I.e., |
@kartik-v Thank you for the explanation, it's a well-thought out solution. I think the ability to customize table names is cool, but it will also make support more difficult when developers ask for help tracking down a problem and their tables names are all different. |
See #21. |
Use migrations instead of an SQL dump.
We can use the configured table prefix, like the advanced app now does: https://github.com/yiisoft/yii2/blob/master/apps/advanced/console/migrations/m130524_201442_init.php#L14
Just as a note: Usually migrations must not be changed after they've been pushed to the repo. There may be exceptions to this rule for initial development, but when we've released a first version, this is a very important convention.
The text was updated successfully, but these errors were encountered: