-
Notifications
You must be signed in to change notification settings - Fork 956
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
Update database schema to include unique keys #149
Conversation
Slightly updated the basic db schema setup to include unique columns; this required some columns to be converted to the 'varchar' type.
What DBMS's has this been tested with, other than MySQL? |
A few comments:
|
FWIW, the DDL I am currently using is available at: https://github.com/dsquier/oauth2-server-php-mysql There are some areas for improvement (i.e., conforming to ANSI SQL and a some refinement of scope storage), but it's working with the current development branch on the library without issues. |
Also added another header field for DBMS's which the schema has been tested with.
After some more testing, it seems that this doesn't work with Oracle, Postgre. or MS SQL Server. As @dsquier said, it's probably a good idea to conform with a standard such as ANSI SQL-92 for portability. However, I'm not particularly familiar with the syntax of DBMS's other than MySQL. I've pushed another commit, updating the README to include a schema which is compliant with MySQL and SQLite for the time being. |
I wasn't correct in #4 bringing ANSI SQL into the picture. I should have left this out, but let me clarify. Since this is all table (and index) definitions, I doubt we'll be able to get something to work across more than one database, much less multiple ones. More importantly, there is no ANSI standard for DDL granular enough to define tables cross-platform. For example, Oracle wants VARCHAR2 instead of VARCHAR, while MySQL wants the opposite. |
Separated the schema into two sections - after reading up on some documentation I discovered that MySQL + SQLite accept both their own CONSTRAINT syntax as well as that of Postgre and MS SQL. However Oracle continues to be stubborn and only accept VARCHAR2 types. It also doesn't recognize the "text" type - because of this, I've converted all text fields to VARCHAR/VARCHAR2 fields with a default length of 255 chars (apart from password, which is set to 2000 to accommodate hashing algorithms).
The above commit addresses all major DBMS's (MySQL, SQLite, Oracle, MS SQL, PostgreSQL) and contains the correct schema for each system. |
Update database schema to include unique keys
@dsquier awesome repo! I can call this out in the README if you'd like. |
@bshaffer You are more than welcome to include, I'd be honored! |
Slightly updated the basic db schema setup to include unique columns;
this required some columns to be converted to the 'varchar' type. This presents some security benefits (i.e. queries would fail should a required column, such as 'access_token', not be present), and allows inline editing features in phpMyAdmin.