Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 1 commit
  • 68 files changed
  • 0 commit comments
  • 1 contributor
Commits on May 21, 2012
Ray Miller Initial release. b2572d1
Showing with 3,080 additions and 34 deletions.
  1. +0 −6 .gitignore
  2. +1 −1  Changes
  3. +379 −0 LICENSE
  4. +106 −0 MANIFEST
  5. +81 −0 META.yml
  6. +13 −0 README
  7. +20 −0 ddl/lims2_devel/roles.sql
  8. +13 −0 ddl/lims2_devel/schema.sql
  9. +7 −0 ddl/lims2_devel/test_roles.sql
  10. +427 −0 ddl/lims2_devel/versions/1/audit-up.sql
  11. +8 −0 ddl/lims2_devel/versions/1/fixtures.sql
  12. +175 −0 ddl/lims2_devel/versions/1/up.sql
  13. +20 −0 ddl/lims2_live/roles.sql
  14. +13 −0 ddl/lims2_live/schema.sql
  15. +7 −0 ddl/lims2_live/test_roles.sql
  16. +428 −0 ddl/lims2_live/versions/1/audit-up.sql
  17. +8 −0 ddl/lims2_live/versions/1/fixtures.sql
  18. +175 −0 ddl/lims2_live/versions/1/up.sql
  19. +20 −0 ddl/lims2_staging/roles.sql
  20. +13 −0 ddl/lims2_staging/schema.sql
  21. +7 −0 ddl/lims2_staging/test_roles.sql
  22. +428 −0 ddl/lims2_staging/versions/1/audit-up.sql
  23. +8 −0 ddl/lims2_staging/versions/1/fixtures.sql
  24. +175 −0 ddl/lims2_staging/versions/1/up.sql
  25. +20 −0 ddl/lims2_test/roles.sql
  26. +13 −0 ddl/lims2_test/schema.sql
  27. +7 −0 ddl/lims2_test/test_roles.sql
  28. +8 −0 ddl/lims2_test/versions/1/fixtures.sql
  29. +175 −0 ddl/lims2_test/versions/1/up.sql
  30. +0 −27 dist.ini
  31. +6 −0 lib/LIMS2/Catalyst/Controller/REST.pm
  32. +6 −0 lib/LIMS2/Model.pm
  33. +6 −0 lib/LIMS2/Model/AuthDB.pm
  34. +6 −0 lib/LIMS2/Model/Constants.pm
  35. +6 −0 lib/LIMS2/Model/DBConnect.pm
  36. +6 −0 lib/LIMS2/Model/FormValidator.pm
  37. +6 −0 lib/LIMS2/Model/FormValidator/Constraint.pm
  38. +6 −0 lib/LIMS2/Model/Plugin/QC.pm
  39. +6 −0 lib/LIMS2/Model/Plugin/User.pm
  40. +6 −0 lib/LIMS2/Model/Schema.pm
  41. +6 −0 lib/LIMS2/Model/Schema/Result/QcAlignment.pm
  42. +6 −0 lib/LIMS2/Model/Schema/Result/QcAlignmentRegion.pm
  43. +6 −0 lib/LIMS2/Model/Schema/Result/QcEngSeq.pm
  44. +6 −0 lib/LIMS2/Model/Schema/Result/QcRun.pm
  45. +6 −0 lib/LIMS2/Model/Schema/Result/QcRunSeqProject.pm
  46. +6 −0 lib/LIMS2/Model/Schema/Result/QcSeqProject.pm
  47. +6 −0 lib/LIMS2/Model/Schema/Result/QcSeqProjectWell.pm
  48. +6 −0 lib/LIMS2/Model/Schema/Result/QcSeqRead.pm
  49. +6 −0 lib/LIMS2/Model/Schema/Result/QcTemplate.pm
  50. +6 −0 lib/LIMS2/Model/Schema/Result/QcTemplateWell.pm
  51. +6 −0 lib/LIMS2/Model/Schema/Result/QcTestResult.pm
  52. +6 −0 lib/LIMS2/Model/Schema/Result/Role.pm
  53. +6 −0 lib/LIMS2/Model/Schema/Result/SchemaVersion.pm
  54. +6 −0 lib/LIMS2/Model/Schema/Result/User.pm
  55. +6 −0 lib/LIMS2/Model/Schema/Result/UserRole.pm
  56. +6 −0 lib/LIMS2/Test.pm
  57. +6 −0 lib/LIMS2/WebApp.pm
  58. +6 −0 lib/LIMS2/WebApp/Controller/API.pm
  59. +6 −0 lib/LIMS2/WebApp/Controller/API/QC.pm
  60. +6 −0 lib/LIMS2/WebApp/Controller/Auth.pm
  61. +6 −0 lib/LIMS2/WebApp/Controller/Root.pm
  62. +6 −0 lib/LIMS2/WebApp/Model/AuthDB.pm
  63. +6 −0 lib/LIMS2/WebApp/Model/Golgi.pm
  64. +6 −0 lib/LIMS2/WebApp/Script/FastCGI.pm
  65. +6 −0 lib/LIMS2/WebApp/View/HTML.pm
  66. +73 −0 t/00-compile.t
  67. +20 −0 t/author-critic.t
  68. +22 −0 t/release-no-smart-comments.t
View
6 .gitignore
@@ -1,6 +0,0 @@
-.build
-LIMS2-WebApp-*
-ddl/lims2_devel
-ddl/lims2_test
-ddl/lims2_live
-ddl/lims2_staging
View
2  Changes
@@ -1,3 +1,3 @@
-{{$NEXT}}
+0.001 2012-05-21 17:02:48 Europe/London
Initial release.
View
379 LICENSE
@@ -0,0 +1,379 @@
+This software is copyright (c) 2012 by Genome Research Ltd.
+
+This is free software; you can redistribute it and/or modify it under
+the same terms as the Perl 5 programming language system itself.
+
+Terms of the Perl programming language system itself
+
+a) the GNU General Public License as published by the Free
+ Software Foundation; either version 1, or (at your option) any
+ later version, or
+b) the "Artistic License"
+
+--- The GNU General Public License, Version 1, February 1989 ---
+
+This software is Copyright (c) 2012 by Genome Research Ltd.
+
+This is free software, licensed under:
+
+ The GNU General Public License, Version 1, February 1989
+
+ GNU GENERAL PUBLIC LICENSE
+ Version 1, February 1989
+
+ Copyright (C) 1989 Free Software Foundation, Inc.
+ 51 Franklin St, Suite 500, Boston, MA 02110-1335 USA
+
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The license agreements of most software companies try to keep users
+at the mercy of those companies. By contrast, our General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. The
+General Public License applies to the Free Software Foundation's
+software and to any other program whose authors commit to using it.
+You can use it for your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Specifically, the General Public License is designed to make
+sure that you have the freedom to give away or sell copies of free
+software, that you receive source code or can get it if you want it,
+that you can change the software or use pieces of it in new free
+programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of a such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must tell them their rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any program or other work which
+contains a notice placed by the copyright holder saying it may be
+distributed under the terms of this General Public License. The
+"Program", below, refers to any such program or work, and a "work based
+on the Program" means either the Program or any work containing the
+Program or a portion of it, either verbatim or with modifications. Each
+licensee is addressed as "you".
+
+ 1. You may copy and distribute verbatim copies of the Program's source
+code as you receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice and
+disclaimer of warranty; keep intact all the notices that refer to this
+General Public License and to the absence of any warranty; and give any
+other recipients of the Program a copy of this General Public License
+along with the Program. You may charge a fee for the physical act of
+transferring a copy.
+
+ 2. You may modify your copy or copies of the Program or any portion of
+it, and copy and distribute such modifications under the terms of Paragraph
+1 above, provided that you also do the following:
+
+ a) cause the modified files to carry prominent notices stating that
+ you changed the files and the date of any change; and
+
+ b) cause the whole of any work that you distribute or publish, that
+ in whole or in part contains the Program or any part thereof, either
+ with or without modifications, to be licensed at no charge to all
+ third parties under the terms of this General Public License (except
+ that you may choose to grant warranty protection to some or all
+ third parties, at your option).
+
+ c) If the modified program normally reads commands interactively when
+ run, you must cause it, when started running for such interactive use
+ in the simplest and most usual way, to print or display an
+ announcement including an appropriate copyright notice and a notice
+ that there is no warranty (or else, saying that you provide a
+ warranty) and that users may redistribute the program under these
+ conditions, and telling the user how to view a copy of this General
+ Public License.
+
+ d) You may charge a fee for the physical act of transferring a
+ copy, and you may at your option offer warranty protection in
+ exchange for a fee.
+
+Mere aggregation of another independent work with the Program (or its
+derivative) on a volume of a storage or distribution medium does not bring
+the other work under the scope of these terms.
+
+ 3. You may copy and distribute the Program (or a portion or derivative of
+it, under Paragraph 2) in object code or executable form under the terms of
+Paragraphs 1 and 2 above provided that you also do one of the following:
+
+ a) accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of
+ Paragraphs 1 and 2 above; or,
+
+ b) accompany it with a written offer, valid for at least three
+ years, to give any third party free (except for a nominal charge
+ for the cost of distribution) a complete machine-readable copy of the
+ corresponding source code, to be distributed under the terms of
+ Paragraphs 1 and 2 above; or,
+
+ c) accompany it with the information you received as to where the
+ corresponding source code may be obtained. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form alone.)
+
+Source code for a work means the preferred form of the work for making
+modifications to it. For an executable file, complete source code means
+all the source code for all modules it contains; but, as a special
+exception, it need not include source code for modules which are standard
+libraries that accompany the operating system on which the executable
+file runs, or for standard header files or definitions files that
+accompany that operating system.
+
+ 4. You may not copy, modify, sublicense, distribute or transfer the
+Program except as expressly provided under this General Public License.
+Any attempt otherwise to copy, modify, sublicense, distribute or transfer
+the Program is void, and will automatically terminate your rights to use
+the Program under this License. However, parties who have received
+copies, or rights to use copies, from you under this General Public
+License will not have their licenses terminated so long as such parties
+remain in full compliance.
+
+ 5. By copying, distributing or modifying the Program (or any work based
+on the Program) you indicate your acceptance of this license to do so,
+and all its terms and conditions.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the original
+licensor to copy, distribute or modify the Program subject to these
+terms and conditions. You may not impose any further restrictions on the
+recipients' exercise of the rights granted herein.
+
+ 7. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of the license which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+the license, you may choose any version ever published by the Free Software
+Foundation.
+
+ 8. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ Appendix: How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to humanity, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these
+terms.
+
+ To do so, attach the following notices to the program. It is safest to
+attach them to the start of each source file to most effectively convey
+the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) 19yy <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 1, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) 19xx name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the
+appropriate parts of the General Public License. Of course, the
+commands you use may be called something other than `show w' and `show
+c'; they could even be mouse-clicks or menu items--whatever suits your
+program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ program `Gnomovision' (a program to direct compilers to make passes
+ at assemblers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+
+--- The Artistic License 1.0 ---
+
+This software is Copyright (c) 2012 by Genome Research Ltd.
+
+This is free software, licensed under:
+
+ The Artistic License 1.0
+
+The Artistic License
+
+Preamble
+
+The intent of this document is to state the conditions under which a Package
+may be copied, such that the Copyright Holder maintains some semblance of
+artistic control over the development of the package, while giving the users of
+the package the right to use and distribute the Package in a more-or-less
+customary fashion, plus the right to make reasonable modifications.
+
+Definitions:
+
+ - "Package" refers to the collection of files distributed by the Copyright
+ Holder, and derivatives of that collection of files created through
+ textual modification.
+ - "Standard Version" refers to such a Package if it has not been modified,
+ or has been modified in accordance with the wishes of the Copyright
+ Holder.
+ - "Copyright Holder" is whoever is named in the copyright or copyrights for
+ the package.
+ - "You" is you, if you're thinking about copying or distributing this Package.
+ - "Reasonable copying fee" is whatever you can justify on the basis of media
+ cost, duplication charges, time of people involved, and so on. (You will
+ not be required to justify it to the Copyright Holder, but only to the
+ computing community at large as a market that must bear the fee.)
+ - "Freely Available" means that no fee is charged for the item itself, though
+ there may be fees involved in handling the item. It also means that
+ recipients of the item may redistribute it under the same conditions they
+ received it.
+
+1. You may make and give away verbatim copies of the source form of the
+Standard Version of this Package without restriction, provided that you
+duplicate all of the original copyright notices and associated disclaimers.
+
+2. You may apply bug fixes, portability fixes and other modifications derived
+from the Public Domain or from the Copyright Holder. A Package modified in such
+a way shall still be considered the Standard Version.
+
+3. You may otherwise modify your copy of this Package in any way, provided that
+you insert a prominent notice in each changed file stating how and when you
+changed that file, and provided that you do at least ONE of the following:
+
+ a) place your modifications in the Public Domain or otherwise make them
+ Freely Available, such as by posting said modifications to Usenet or an
+ equivalent medium, or placing the modifications on a major archive site
+ such as ftp.uu.net, or by allowing the Copyright Holder to include your
+ modifications in the Standard Version of the Package.
+
+ b) use the modified Package only within your corporation or organization.
+
+ c) rename any non-standard executables so the names do not conflict with
+ standard executables, which must also be provided, and provide a separate
+ manual page for each non-standard executable that clearly documents how it
+ differs from the Standard Version.
+
+ d) make other distribution arrangements with the Copyright Holder.
+
+4. You may distribute the programs of this Package in object code or executable
+form, provided that you do at least ONE of the following:
+
+ a) distribute a Standard Version of the executables and library files,
+ together with instructions (in the manual page or equivalent) on where to
+ get the Standard Version.
+
+ b) accompany the distribution with the machine-readable source of the Package
+ with your modifications.
+
+ c) accompany any non-standard executables with their corresponding Standard
+ Version executables, giving the non-standard executables non-standard
+ names, and clearly documenting the differences in manual pages (or
+ equivalent), together with instructions on where to get the Standard
+ Version.
+
+ d) make other distribution arrangements with the Copyright Holder.
+
+5. You may charge a reasonable copying fee for any distribution of this
+Package. You may charge any fee you choose for support of this Package. You
+may not charge a fee for this Package itself. However, you may distribute this
+Package in aggregate with other (possibly commercial) programs as part of a
+larger (possibly commercial) software distribution provided that you do not
+advertise this Package as a product of your own.
+
+6. The scripts and library files supplied as input to or produced as output
+from the programs of this Package do not automatically fall under the copyright
+of this Package, but belong to whomever generated them, and may be sold
+commercially, and may be aggregated with this Package.
+
+7. C or perl subroutines supplied by you and linked into this Package shall not
+be considered part of this Package.
+
+8. The name of the Copyright Holder may not be used to endorse or promote
+products derived from this software without specific prior written permission.
+
+9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+
+The End
+
View
106 MANIFEST
@@ -0,0 +1,106 @@
+Changes
+LICENSE
+MANIFEST
+META.yml
+Makefile.PL
+README
+bin/lims2_model_dump_schema.pl
+ddl/generate-schema.sh
+ddl/lims2_devel/roles.sql
+ddl/lims2_devel/schema.sql
+ddl/lims2_devel/test_roles.sql
+ddl/lims2_devel/versions/1/audit-up.sql
+ddl/lims2_devel/versions/1/fixtures.sql
+ddl/lims2_devel/versions/1/up.sql
+ddl/lims2_live/roles.sql
+ddl/lims2_live/schema.sql
+ddl/lims2_live/test_roles.sql
+ddl/lims2_live/versions/1/audit-up.sql
+ddl/lims2_live/versions/1/fixtures.sql
+ddl/lims2_live/versions/1/up.sql
+ddl/lims2_staging/roles.sql
+ddl/lims2_staging/schema.sql
+ddl/lims2_staging/test_roles.sql
+ddl/lims2_staging/versions/1/audit-up.sql
+ddl/lims2_staging/versions/1/fixtures.sql
+ddl/lims2_staging/versions/1/up.sql
+ddl/lims2_test/roles.sql
+ddl/lims2_test/schema.sql
+ddl/lims2_test/test_roles.sql
+ddl/lims2_test/versions/1/fixtures.sql
+ddl/lims2_test/versions/1/up.sql
+ddl/templates/roles.sql
+ddl/templates/schema.sql
+ddl/templates/test_roles.sql
+ddl/templates/versions/1/audit-up.sql
+ddl/templates/versions/1/fixtures.sql
+ddl/templates/versions/1/up.sql
+ddl/vars.tt
+lib/LIMS2/Catalyst/Controller/REST.pm
+lib/LIMS2/Model.pm
+lib/LIMS2/Model/AuthDB.pm
+lib/LIMS2/Model/Constants.pm
+lib/LIMS2/Model/DBConnect.pm
+lib/LIMS2/Model/FormValidator.pm
+lib/LIMS2/Model/FormValidator/Constraint.pm
+lib/LIMS2/Model/Plugin/QC.pm
+lib/LIMS2/Model/Plugin/User.pm
+lib/LIMS2/Model/Schema.pm
+lib/LIMS2/Model/Schema/Result/QcAlignment.pm
+lib/LIMS2/Model/Schema/Result/QcAlignmentRegion.pm
+lib/LIMS2/Model/Schema/Result/QcEngSeq.pm
+lib/LIMS2/Model/Schema/Result/QcRun.pm
+lib/LIMS2/Model/Schema/Result/QcRunSeqProject.pm
+lib/LIMS2/Model/Schema/Result/QcSeqProject.pm
+lib/LIMS2/Model/Schema/Result/QcSeqProjectWell.pm
+lib/LIMS2/Model/Schema/Result/QcSeqRead.pm
+lib/LIMS2/Model/Schema/Result/QcTemplate.pm
+lib/LIMS2/Model/Schema/Result/QcTemplateWell.pm
+lib/LIMS2/Model/Schema/Result/QcTestResult.pm
+lib/LIMS2/Model/Schema/Result/Role.pm
+lib/LIMS2/Model/Schema/Result/SchemaVersion.pm
+lib/LIMS2/Model/Schema/Result/User.pm
+lib/LIMS2/Model/Schema/Result/UserRole.pm
+lib/LIMS2/Test.pm
+lib/LIMS2/WebApp.pm
+lib/LIMS2/WebApp/Controller/API.pm
+lib/LIMS2/WebApp/Controller/API/QC.pm
+lib/LIMS2/WebApp/Controller/Auth.pm
+lib/LIMS2/WebApp/Controller/Root.pm
+lib/LIMS2/WebApp/Model/AuthDB.pm
+lib/LIMS2/WebApp/Model/Golgi.pm
+lib/LIMS2/WebApp/Script/FastCGI.pm
+lib/LIMS2/WebApp/View/HTML.pm
+root/favicon.ico
+root/lib/wrapper.tt
+root/site/auth/login.tt
+root/site/site_index.tt
+root/static/images/btn_120x50_built.png
+root/static/images/btn_120x50_built_shadow.png
+root/static/images/btn_120x50_powered.png
+root/static/images/btn_120x50_powered_shadow.png
+root/static/images/btn_88x31_built.png
+root/static/images/btn_88x31_built_shadow.png
+root/static/images/btn_88x31_powered.png
+root/static/images/btn_88x31_powered_shadow.png
+root/static/images/catalyst_logo.png
+script/lims2_webapp_cgi.pl
+script/lims2_webapp_create.pl
+script/lims2_webapp_fastcgi.pl
+script/lims2_webapp_server.pl
+script/lims2_webapp_test.pl
+t/00-compile.t
+t/10-dbconnect.t
+t/10-lims2-test.t
+t/20-form-validator.t
+t/50-model-plugin-qc.t
+t/50-model-plugin-user.t
+t/80-login.t
+t/80-qc.t
+t/author-critic.t
+t/data/qc_run.yaml
+t/data/qc_seq_reads.yaml
+t/data/qc_template.yaml
+t/fixtures/00-clean-db.sql
+t/fixtures/10-users-roles.sql
+t/release-no-smart-comments.t
View
81 META.yml
@@ -0,0 +1,81 @@
+---
+abstract: 'Catalyst based application'
+author:
+ - 'Wellcome Trust Sanger Institute'
+build_requires:
+ DateTime: 0
+ English: 0
+ File::Find: 0
+ File::Temp: 0
+ HTTP::Request::Common: 0
+ Test::More: 0.88
+ Test::Most: 0
+dynamic_config: 0
+generated_by: 'Dist::Zilla version 4.300014, CPAN::Meta::Converter version 2.120921'
+license: perl
+meta-spec:
+ url: http://module-build.sourceforge.net/META-spec-v1.4.html
+ version: 1.4
+name: LIMS2-WebApp
+requires:
+ Carp: 0
+ Catalyst: 0
+ Catalyst::Controller: 0
+ Catalyst::Controller::REST: 0
+ Catalyst::Devel: 0
+ Catalyst::Model::Adaptor: 0
+ Catalyst::Model::DBIC::Schema: 0
+ Catalyst::Model::Factory::PerRequest: 0
+ Catalyst::Plugin::Authorization::Roles: 0
+ Catalyst::Plugin::Session::State::Cookie: 0
+ Catalyst::Plugin::Session::Store::FastMmap: 0
+ Catalyst::Plugin::Static::Simple: 0
+ Catalyst::Runtime: 5.80
+ Catalyst::Script::FastCGI: 0
+ Catalyst::View::TT: 0
+ Class::Data::Inheritable: 0
+ Config::Any: 0
+ Const::Fast: 0
+ DBIx::Class::Core: 0
+ DBIx::Class::Schema: 0
+ DBIx::Class::Schema::Loader: 0
+ DBIx::Connector: 0
+ DBIx::RunSQL: 0
+ Data::Compare: 0
+ Data::FormValidator: 0
+ DateTime::Format::ISO8601: 0
+ DateTime::Format::Pg: 0
+ EngSeqBuilder: 0
+ Exporter: 0
+ File::stat: 0
+ FindBin: 0
+ Getopt::Long: 0
+ HTTP::Status: 0
+ Hash::MoreUtils: 0
+ JSON: 0
+ LIMS2::Exception: 0
+ LIMS2::Util: 0
+ LIMS2::Util::EnsEMBL: 0
+ List::MoreUtils: 0
+ Log::Log4perl: 0
+ Log::Log4perl::Catalyst: 0
+ Module::Pluggable::Object: 0
+ Moose: 0
+ Moose::Role: 0
+ MooseX::MarkAsMethods: 0
+ MooseX::NonMoose: 0
+ Path::Class: 0
+ Regexp::Common: 0
+ Scalar::Util: 0
+ Sub::Exporter: 0
+ Term::ReadPassword: 0
+ Test::More: 0
+ Test::WWW::Mechanize::Catalyst: 0
+ Try::Tiny: 0
+ YAML::Any: 0
+ base: 0
+ namespace::autoclean: 0
+ strict: 0
+ utf8: 0
+ warnings: 0
+version: 0.001
View
13 README
@@ -0,0 +1,13 @@
+
+
+This archive contains the distribution LIMS2-WebApp,
+version 0.001:
+
+ Catalyst based application
+
+This software is copyright (c) 2012 by Genome Research Ltd.
+
+This is free software; you can redistribute it and/or modify it under
+the same terms as the Perl 5 programming language system itself.
+
+
View
20 ddl/lims2_devel/roles.sql
@@ -0,0 +1,20 @@
+
+
+CREATE ROLE "lims2_devel_admin" NOLOGIN NOINHERIT;
+CREATE ROLE "lims2_devel_rw" NOLOGIN NOINHERIT;
+CREATE ROLE "lims2_devel_ro" NOLOGIN NOINHERIT;
+CREATE ROLE "lims2_devel_webapp" WITH ENCRYPTED PASSWORD 'ilgexmYeojd9' LOGIN NOINHERIT IN ROLE "lims2_devel_ro";
+CREATE ROLE "lims2_devel_webapp_ro" WITH ENCRYPTED PASSWORD 'VUSybNGoSAih' LOGIN INHERIT IN ROLE "lims2_devel_ro";
+CREATE ROLE "lims2_devel_task" WITH ENCRYPTED PASSWORD 'QXsNMvLz6sJ1' LOGIN INHERIT IN ROLE "lims2_devel_rw";
+
+GRANT "lims2_devel_rw" TO "rm7@sanger.ac.uk";
+GRANT "rm7@sanger.ac.uk" TO "lims2_devel_webapp";
+GRANT "lims2_devel_rw" TO "sp12@sanger.ac.uk";
+GRANT "sp12@sanger.ac.uk" TO "lims2_devel_webapp";
+
+GRANT "lims2_devel_admin" TO "rm7";
+GRANT "lims2_devel_ro" TO "rm7";
+GRANT "lims2_devel_rw" TO "rm7";
+GRANT "lims2_devel_admin" TO "sp12";
+GRANT "lims2_devel_ro" TO "sp12";
+GRANT "lims2_devel_rw" TO "sp12";
View
13 ddl/lims2_devel/schema.sql
@@ -0,0 +1,13 @@
+
+
+DROP SCHEMA IF EXISTS public CASCADE;
+CREATE SCHEMA public AUTHORIZATION "lims2_devel_admin";
+REVOKE ALL ON SCHEMA public FROM PUBLIC;
+GRANT USAGE ON SCHEMA public TO "lims2_devel_rw";
+GRANT USAGE ON SCHEMA public TO "lims2_devel_ro";
+
+DROP SCHEMA IF EXISTS audit CASCADE;
+CREATE SCHEMA audit AUTHORIZATION "lims2_devel_admin";
+REVOKE ALL ON SCHEMA audit FROM PUBLIC;
+GRANT USAGE ON SCHEMA audit TO "lims2_devel_rw";
+GRANT USAGE ON SCHEMA audit TO "lims2_devel_ro";
View
7 ddl/lims2_devel/test_roles.sql
@@ -0,0 +1,7 @@
+
+
+CREATE ROLE "lims2_devel_test_admin" WITH NOLOGIN NOINHERIT;
+CREATE ROLE "lims2_devel_test" WITH ENCRYPTED PASSWORD 'E0fs7sYm1rKw' LOGIN INHERIT IN ROLE "lims2_devel_rw";
+
+GRANT "lims2_devel_test_admin" TO "lims2_devel_test";
+GRANT "lims2_devel_admin" TO "lims2_devel_test_admin";
View
427 ddl/lims2_devel/versions/1/audit-up.sql
@@ -0,0 +1,427 @@
+CREATE TABLE audit.roles (
+audit_op CHAR(1) NOT NULL CHECK (audit_op IN ('D','I','U')),
+audit_user TEXT NOT NULL,
+audit_stamp TIMESTAMP NOT NULL,
+audit_txid INTEGER NOT NULL,
+id integer,
+name text
+);
+GRANT SELECT ON audit.roles TO lims2_devel_ro;
+GRANT SELECT,INSERT ON audit.roles TO lims2_devel_rw;
+CREATE OR REPLACE FUNCTION public.process_roles_audit()
+RETURNS TRIGGER AS $roles_audit$
+ BEGIN
+ IF (TG_OP = 'DELETE') THEN
+ INSERT INTO audit.roles SELECT 'D', user, now(), txid_current(), OLD.*;
+ ELSIF (TG_OP = 'UPDATE') THEN
+ INSERT INTO audit.roles SELECT 'U', user, now(), txid_current(), NEW.*;
+ ELSIF (TG_OP = 'INSERT') THEN
+ INSERT INTO audit.roles SELECT 'I', user, now(), txid_current(), NEW.*;
+ END IF;
+ RETURN NULL;
+ END;
+$roles_audit$ LANGUAGE plpgsql;
+CREATE TRIGGER roles_audit
+AFTER INSERT OR UPDATE OR DELETE ON public.roles
+ FOR EACH ROW EXECUTE PROCEDURE public.process_roles_audit();
+CREATE TABLE audit.qc_seq_project_wells (
+audit_op CHAR(1) NOT NULL CHECK (audit_op IN ('D','I','U')),
+audit_user TEXT NOT NULL,
+audit_stamp TIMESTAMP NOT NULL,
+audit_txid INTEGER NOT NULL,
+id integer,
+qc_seq_project_id text,
+plate_name text,
+well_name text
+);
+GRANT SELECT ON audit.qc_seq_project_wells TO lims2_devel_ro;
+GRANT SELECT,INSERT ON audit.qc_seq_project_wells TO lims2_devel_rw;
+CREATE OR REPLACE FUNCTION public.process_qc_seq_project_wells_audit()
+RETURNS TRIGGER AS $qc_seq_project_wells_audit$
+ BEGIN
+ IF (TG_OP = 'DELETE') THEN
+ INSERT INTO audit.qc_seq_project_wells SELECT 'D', user, now(), txid_current(), OLD.*;
+ ELSIF (TG_OP = 'UPDATE') THEN
+ INSERT INTO audit.qc_seq_project_wells SELECT 'U', user, now(), txid_current(), NEW.*;
+ ELSIF (TG_OP = 'INSERT') THEN
+ INSERT INTO audit.qc_seq_project_wells SELECT 'I', user, now(), txid_current(), NEW.*;
+ END IF;
+ RETURN NULL;
+ END;
+$qc_seq_project_wells_audit$ LANGUAGE plpgsql;
+CREATE TRIGGER qc_seq_project_wells_audit
+AFTER INSERT OR UPDATE OR DELETE ON public.qc_seq_project_wells
+ FOR EACH ROW EXECUTE PROCEDURE public.process_qc_seq_project_wells_audit();
+CREATE TABLE audit.schema_versions (
+audit_op CHAR(1) NOT NULL CHECK (audit_op IN ('D','I','U')),
+audit_user TEXT NOT NULL,
+audit_stamp TIMESTAMP NOT NULL,
+audit_txid INTEGER NOT NULL,
+version integer,
+deployed_at timestamp without time zone
+);
+GRANT SELECT ON audit.schema_versions TO lims2_devel_ro;
+GRANT SELECT,INSERT ON audit.schema_versions TO lims2_devel_rw;
+CREATE OR REPLACE FUNCTION public.process_schema_versions_audit()
+RETURNS TRIGGER AS $schema_versions_audit$
+ BEGIN
+ IF (TG_OP = 'DELETE') THEN
+ INSERT INTO audit.schema_versions SELECT 'D', user, now(), txid_current(), OLD.*;
+ ELSIF (TG_OP = 'UPDATE') THEN
+ INSERT INTO audit.schema_versions SELECT 'U', user, now(), txid_current(), NEW.*;
+ ELSIF (TG_OP = 'INSERT') THEN
+ INSERT INTO audit.schema_versions SELECT 'I', user, now(), txid_current(), NEW.*;
+ END IF;
+ RETURN NULL;
+ END;
+$schema_versions_audit$ LANGUAGE plpgsql;
+CREATE TRIGGER schema_versions_audit
+AFTER INSERT OR UPDATE OR DELETE ON public.schema_versions
+ FOR EACH ROW EXECUTE PROCEDURE public.process_schema_versions_audit();
+CREATE TABLE audit.qc_alignments (
+audit_op CHAR(1) NOT NULL CHECK (audit_op IN ('D','I','U')),
+audit_user TEXT NOT NULL,
+audit_stamp TIMESTAMP NOT NULL,
+audit_txid INTEGER NOT NULL,
+id integer,
+qc_seq_read_id text,
+qc_eng_seq_id integer,
+primer_name text,
+query_start integer,
+query_end integer,
+query_strand integer,
+target_start integer,
+target_end integer,
+target_strand integer,
+score integer,
+pass boolean,
+features text,
+cigar text,
+op_str text
+);
+GRANT SELECT ON audit.qc_alignments TO lims2_devel_ro;
+GRANT SELECT,INSERT ON audit.qc_alignments TO lims2_devel_rw;
+CREATE OR REPLACE FUNCTION public.process_qc_alignments_audit()
+RETURNS TRIGGER AS $qc_alignments_audit$
+ BEGIN
+ IF (TG_OP = 'DELETE') THEN
+ INSERT INTO audit.qc_alignments SELECT 'D', user, now(), txid_current(), OLD.*;
+ ELSIF (TG_OP = 'UPDATE') THEN
+ INSERT INTO audit.qc_alignments SELECT 'U', user, now(), txid_current(), NEW.*;
+ ELSIF (TG_OP = 'INSERT') THEN
+ INSERT INTO audit.qc_alignments SELECT 'I', user, now(), txid_current(), NEW.*;
+ END IF;
+ RETURN NULL;
+ END;
+$qc_alignments_audit$ LANGUAGE plpgsql;
+CREATE TRIGGER qc_alignments_audit
+AFTER INSERT OR UPDATE OR DELETE ON public.qc_alignments
+ FOR EACH ROW EXECUTE PROCEDURE public.process_qc_alignments_audit();
+CREATE TABLE audit.user_role (
+audit_op CHAR(1) NOT NULL CHECK (audit_op IN ('D','I','U')),
+audit_user TEXT NOT NULL,
+audit_stamp TIMESTAMP NOT NULL,
+audit_txid INTEGER NOT NULL,
+user_id integer,
+role_id integer
+);
+GRANT SELECT ON audit.user_role TO lims2_devel_ro;
+GRANT SELECT,INSERT ON audit.user_role TO lims2_devel_rw;
+CREATE OR REPLACE FUNCTION public.process_user_role_audit()
+RETURNS TRIGGER AS $user_role_audit$
+ BEGIN
+ IF (TG_OP = 'DELETE') THEN
+ INSERT INTO audit.user_role SELECT 'D', user, now(), txid_current(), OLD.*;
+ ELSIF (TG_OP = 'UPDATE') THEN
+ INSERT INTO audit.user_role SELECT 'U', user, now(), txid_current(), NEW.*;
+ ELSIF (TG_OP = 'INSERT') THEN
+ INSERT INTO audit.user_role SELECT 'I', user, now(), txid_current(), NEW.*;
+ END IF;
+ RETURN NULL;
+ END;
+$user_role_audit$ LANGUAGE plpgsql;
+CREATE TRIGGER user_role_audit
+AFTER INSERT OR UPDATE OR DELETE ON public.user_role
+ FOR EACH ROW EXECUTE PROCEDURE public.process_user_role_audit();
+CREATE TABLE audit.qc_templates (
+audit_op CHAR(1) NOT NULL CHECK (audit_op IN ('D','I','U')),
+audit_user TEXT NOT NULL,
+audit_stamp TIMESTAMP NOT NULL,
+audit_txid INTEGER NOT NULL,
+id integer,
+name text,
+created_at timestamp without time zone
+);
+GRANT SELECT ON audit.qc_templates TO lims2_devel_ro;
+GRANT SELECT,INSERT ON audit.qc_templates TO lims2_devel_rw;
+CREATE OR REPLACE FUNCTION public.process_qc_templates_audit()
+RETURNS TRIGGER AS $qc_templates_audit$
+ BEGIN
+ IF (TG_OP = 'DELETE') THEN
+ INSERT INTO audit.qc_templates SELECT 'D', user, now(), txid_current(), OLD.*;
+ ELSIF (TG_OP = 'UPDATE') THEN
+ INSERT INTO audit.qc_templates SELECT 'U', user, now(), txid_current(), NEW.*;
+ ELSIF (TG_OP = 'INSERT') THEN
+ INSERT INTO audit.qc_templates SELECT 'I', user, now(), txid_current(), NEW.*;
+ END IF;
+ RETURN NULL;
+ END;
+$qc_templates_audit$ LANGUAGE plpgsql;
+CREATE TRIGGER qc_templates_audit
+AFTER INSERT OR UPDATE OR DELETE ON public.qc_templates
+ FOR EACH ROW EXECUTE PROCEDURE public.process_qc_templates_audit();
+CREATE TABLE audit.qc_eng_seqs (
+audit_op CHAR(1) NOT NULL CHECK (audit_op IN ('D','I','U')),
+audit_user TEXT NOT NULL,
+audit_stamp TIMESTAMP NOT NULL,
+audit_txid INTEGER NOT NULL,
+id integer,
+method text,
+params text
+);
+GRANT SELECT ON audit.qc_eng_seqs TO lims2_devel_ro;
+GRANT SELECT,INSERT ON audit.qc_eng_seqs TO lims2_devel_rw;
+CREATE OR REPLACE FUNCTION public.process_qc_eng_seqs_audit()
+RETURNS TRIGGER AS $qc_eng_seqs_audit$
+ BEGIN
+ IF (TG_OP = 'DELETE') THEN
+ INSERT INTO audit.qc_eng_seqs SELECT 'D', user, now(), txid_current(), OLD.*;
+ ELSIF (TG_OP = 'UPDATE') THEN
+ INSERT INTO audit.qc_eng_seqs SELECT 'U', user, now(), txid_current(), NEW.*;
+ ELSIF (TG_OP = 'INSERT') THEN
+ INSERT INTO audit.qc_eng_seqs SELECT 'I', user, now(), txid_current(), NEW.*;
+ END IF;
+ RETURN NULL;
+ END;
+$qc_eng_seqs_audit$ LANGUAGE plpgsql;
+CREATE TRIGGER qc_eng_seqs_audit
+AFTER INSERT OR UPDATE OR DELETE ON public.qc_eng_seqs
+ FOR EACH ROW EXECUTE PROCEDURE public.process_qc_eng_seqs_audit();
+CREATE TABLE audit.qc_alignment_regions (
+audit_op CHAR(1) NOT NULL CHECK (audit_op IN ('D','I','U')),
+audit_user TEXT NOT NULL,
+audit_stamp TIMESTAMP NOT NULL,
+audit_txid INTEGER NOT NULL,
+qc_alignment_id integer,
+name text,
+length integer,
+match_count integer,
+query_str text,
+target_str text,
+match_str text,
+pass boolean
+);
+GRANT SELECT ON audit.qc_alignment_regions TO lims2_devel_ro;
+GRANT SELECT,INSERT ON audit.qc_alignment_regions TO lims2_devel_rw;
+CREATE OR REPLACE FUNCTION public.process_qc_alignment_regions_audit()
+RETURNS TRIGGER AS $qc_alignment_regions_audit$
+ BEGIN
+ IF (TG_OP = 'DELETE') THEN
+ INSERT INTO audit.qc_alignment_regions SELECT 'D', user, now(), txid_current(), OLD.*;
+ ELSIF (TG_OP = 'UPDATE') THEN
+ INSERT INTO audit.qc_alignment_regions SELECT 'U', user, now(), txid_current(), NEW.*;
+ ELSIF (TG_OP = 'INSERT') THEN
+ INSERT INTO audit.qc_alignment_regions SELECT 'I', user, now(), txid_current(), NEW.*;
+ END IF;
+ RETURN NULL;
+ END;
+$qc_alignment_regions_audit$ LANGUAGE plpgsql;
+CREATE TRIGGER qc_alignment_regions_audit
+AFTER INSERT OR UPDATE OR DELETE ON public.qc_alignment_regions
+ FOR EACH ROW EXECUTE PROCEDURE public.process_qc_alignment_regions_audit();
+CREATE TABLE audit.users (
+audit_op CHAR(1) NOT NULL CHECK (audit_op IN ('D','I','U')),
+audit_user TEXT NOT NULL,
+audit_stamp TIMESTAMP NOT NULL,
+audit_txid INTEGER NOT NULL,
+id integer,
+name text,
+password text
+);
+GRANT SELECT ON audit.users TO lims2_devel_ro;
+GRANT SELECT,INSERT ON audit.users TO lims2_devel_rw;
+CREATE OR REPLACE FUNCTION public.process_users_audit()
+RETURNS TRIGGER AS $users_audit$
+ BEGIN
+ IF (TG_OP = 'DELETE') THEN
+ INSERT INTO audit.users SELECT 'D', user, now(), txid_current(), OLD.*;
+ ELSIF (TG_OP = 'UPDATE') THEN
+ INSERT INTO audit.users SELECT 'U', user, now(), txid_current(), NEW.*;
+ ELSIF (TG_OP = 'INSERT') THEN
+ INSERT INTO audit.users SELECT 'I', user, now(), txid_current(), NEW.*;
+ END IF;
+ RETURN NULL;
+ END;
+$users_audit$ LANGUAGE plpgsql;
+CREATE TRIGGER users_audit
+AFTER INSERT OR UPDATE OR DELETE ON public.users
+ FOR EACH ROW EXECUTE PROCEDURE public.process_users_audit();
+CREATE TABLE audit.qc_test_results (
+audit_op CHAR(1) NOT NULL CHECK (audit_op IN ('D','I','U')),
+audit_user TEXT NOT NULL,
+audit_stamp TIMESTAMP NOT NULL,
+audit_txid INTEGER NOT NULL,
+id integer,
+qc_run_id character(36),
+qc_eng_seq_id integer,
+qc_seq_project_well_id integer,
+score integer,
+pass boolean
+);
+GRANT SELECT ON audit.qc_test_results TO lims2_devel_ro;
+GRANT SELECT,INSERT ON audit.qc_test_results TO lims2_devel_rw;
+CREATE OR REPLACE FUNCTION public.process_qc_test_results_audit()
+RETURNS TRIGGER AS $qc_test_results_audit$
+ BEGIN
+ IF (TG_OP = 'DELETE') THEN
+ INSERT INTO audit.qc_test_results SELECT 'D', user, now(), txid_current(), OLD.*;
+ ELSIF (TG_OP = 'UPDATE') THEN
+ INSERT INTO audit.qc_test_results SELECT 'U', user, now(), txid_current(), NEW.*;
+ ELSIF (TG_OP = 'INSERT') THEN
+ INSERT INTO audit.qc_test_results SELECT 'I', user, now(), txid_current(), NEW.*;
+ END IF;
+ RETURN NULL;
+ END;
+$qc_test_results_audit$ LANGUAGE plpgsql;
+CREATE TRIGGER qc_test_results_audit
+AFTER INSERT OR UPDATE OR DELETE ON public.qc_test_results
+ FOR EACH ROW EXECUTE PROCEDURE public.process_qc_test_results_audit();
+CREATE TABLE audit.qc_seq_reads (
+audit_op CHAR(1) NOT NULL CHECK (audit_op IN ('D','I','U')),
+audit_user TEXT NOT NULL,
+audit_stamp TIMESTAMP NOT NULL,
+audit_txid INTEGER NOT NULL,
+id text,
+description text,
+qc_seq_project_well_id integer,
+primer_name text,
+seq text,
+length integer
+);
+GRANT SELECT ON audit.qc_seq_reads TO lims2_devel_ro;
+GRANT SELECT,INSERT ON audit.qc_seq_reads TO lims2_devel_rw;
+CREATE OR REPLACE FUNCTION public.process_qc_seq_reads_audit()
+RETURNS TRIGGER AS $qc_seq_reads_audit$
+ BEGIN
+ IF (TG_OP = 'DELETE') THEN
+ INSERT INTO audit.qc_seq_reads SELECT 'D', user, now(), txid_current(), OLD.*;
+ ELSIF (TG_OP = 'UPDATE') THEN
+ INSERT INTO audit.qc_seq_reads SELECT 'U', user, now(), txid_current(), NEW.*;
+ ELSIF (TG_OP = 'INSERT') THEN
+ INSERT INTO audit.qc_seq_reads SELECT 'I', user, now(), txid_current(), NEW.*;
+ END IF;
+ RETURN NULL;
+ END;
+$qc_seq_reads_audit$ LANGUAGE plpgsql;
+CREATE TRIGGER qc_seq_reads_audit
+AFTER INSERT OR UPDATE OR DELETE ON public.qc_seq_reads
+ FOR EACH ROW EXECUTE PROCEDURE public.process_qc_seq_reads_audit();
+CREATE TABLE audit.qc_runs (
+audit_op CHAR(1) NOT NULL CHECK (audit_op IN ('D','I','U')),
+audit_user TEXT NOT NULL,
+audit_stamp TIMESTAMP NOT NULL,
+audit_txid INTEGER NOT NULL,
+id character(36),
+created_at timestamp without time zone,
+created_by_id integer,
+profile text,
+qc_template_id integer,
+software_version text
+);
+GRANT SELECT ON audit.qc_runs TO lims2_devel_ro;
+GRANT SELECT,INSERT ON audit.qc_runs TO lims2_devel_rw;
+CREATE OR REPLACE FUNCTION public.process_qc_runs_audit()
+RETURNS TRIGGER AS $qc_runs_audit$
+ BEGIN
+ IF (TG_OP = 'DELETE') THEN
+ INSERT INTO audit.qc_runs SELECT 'D', user, now(), txid_current(), OLD.*;
+ ELSIF (TG_OP = 'UPDATE') THEN
+ INSERT INTO audit.qc_runs SELECT 'U', user, now(), txid_current(), NEW.*;
+ ELSIF (TG_OP = 'INSERT') THEN
+ INSERT INTO audit.qc_runs SELECT 'I', user, now(), txid_current(), NEW.*;
+ END IF;
+ RETURN NULL;
+ END;
+$qc_runs_audit$ LANGUAGE plpgsql;
+CREATE TRIGGER qc_runs_audit
+AFTER INSERT OR UPDATE OR DELETE ON public.qc_runs
+ FOR EACH ROW EXECUTE PROCEDURE public.process_qc_runs_audit();
+CREATE TABLE audit.qc_template_wells (
+audit_op CHAR(1) NOT NULL CHECK (audit_op IN ('D','I','U')),
+audit_user TEXT NOT NULL,
+audit_stamp TIMESTAMP NOT NULL,
+audit_txid INTEGER NOT NULL,
+id integer,
+qc_template_id integer,
+name text,
+qc_eng_seq_id integer
+);
+GRANT SELECT ON audit.qc_template_wells TO lims2_devel_ro;
+GRANT SELECT,INSERT ON audit.qc_template_wells TO lims2_devel_rw;
+CREATE OR REPLACE FUNCTION public.process_qc_template_wells_audit()
+RETURNS TRIGGER AS $qc_template_wells_audit$
+ BEGIN
+ IF (TG_OP = 'DELETE') THEN
+ INSERT INTO audit.qc_template_wells SELECT 'D', user, now(), txid_current(), OLD.*;
+ ELSIF (TG_OP = 'UPDATE') THEN
+ INSERT INTO audit.qc_template_wells SELECT 'U', user, now(), txid_current(), NEW.*;
+ ELSIF (TG_OP = 'INSERT') THEN
+ INSERT INTO audit.qc_template_wells SELECT 'I', user, now(), txid_current(), NEW.*;
+ END IF;
+ RETURN NULL;
+ END;
+$qc_template_wells_audit$ LANGUAGE plpgsql;
+CREATE TRIGGER qc_template_wells_audit
+AFTER INSERT OR UPDATE OR DELETE ON public.qc_template_wells
+ FOR EACH ROW EXECUTE PROCEDURE public.process_qc_template_wells_audit();
+CREATE TABLE audit.qc_run_seq_project (
+audit_op CHAR(1) NOT NULL CHECK (audit_op IN ('D','I','U')),
+audit_user TEXT NOT NULL,
+audit_stamp TIMESTAMP NOT NULL,
+audit_txid INTEGER NOT NULL,
+qc_run_id character(36),
+qc_seq_project_id text
+);
+GRANT SELECT ON audit.qc_run_seq_project TO lims2_devel_ro;
+GRANT SELECT,INSERT ON audit.qc_run_seq_project TO lims2_devel_rw;
+CREATE OR REPLACE FUNCTION public.process_qc_run_seq_project_audit()
+RETURNS TRIGGER AS $qc_run_seq_project_audit$
+ BEGIN
+ IF (TG_OP = 'DELETE') THEN
+ INSERT INTO audit.qc_run_seq_project SELECT 'D', user, now(), txid_current(), OLD.*;
+ ELSIF (TG_OP = 'UPDATE') THEN
+ INSERT INTO audit.qc_run_seq_project SELECT 'U', user, now(), txid_current(), NEW.*;
+ ELSIF (TG_OP = 'INSERT') THEN
+ INSERT INTO audit.qc_run_seq_project SELECT 'I', user, now(), txid_current(), NEW.*;
+ END IF;
+ RETURN NULL;
+ END;
+$qc_run_seq_project_audit$ LANGUAGE plpgsql;
+CREATE TRIGGER qc_run_seq_project_audit
+AFTER INSERT OR UPDATE OR DELETE ON public.qc_run_seq_project
+ FOR EACH ROW EXECUTE PROCEDURE public.process_qc_run_seq_project_audit();
+CREATE TABLE audit.qc_seq_projects (
+audit_op CHAR(1) NOT NULL CHECK (audit_op IN ('D','I','U')),
+audit_user TEXT NOT NULL,
+audit_stamp TIMESTAMP NOT NULL,
+audit_txid INTEGER NOT NULL,
+id text
+);
+GRANT SELECT ON audit.qc_seq_projects TO lims2_devel_ro;
+GRANT SELECT,INSERT ON audit.qc_seq_projects TO lims2_devel_rw;
+CREATE OR REPLACE FUNCTION public.process_qc_seq_projects_audit()
+RETURNS TRIGGER AS $qc_seq_projects_audit$
+ BEGIN
+ IF (TG_OP = 'DELETE') THEN
+ INSERT INTO audit.qc_seq_projects SELECT 'D', user, now(), txid_current(), OLD.*;
+ ELSIF (TG_OP = 'UPDATE') THEN
+ INSERT INTO audit.qc_seq_projects SELECT 'U', user, now(), txid_current(), NEW.*;
+ ELSIF (TG_OP = 'INSERT') THEN
+ INSERT INTO audit.qc_seq_projects SELECT 'I', user, now(), txid_current(), NEW.*;
+ END IF;
+ RETURN NULL;
+ END;
+$qc_seq_projects_audit$ LANGUAGE plpgsql;
+CREATE TRIGGER qc_seq_projects_audit
+AFTER INSERT OR UPDATE OR DELETE ON public.qc_seq_projects
+ FOR EACH ROW EXECUTE PROCEDURE public.process_qc_seq_projects_audit();
View
8 ddl/lims2_devel/versions/1/fixtures.sql
@@ -0,0 +1,8 @@
+
+
+
+INSERT INTO schema_versions (version) VALUES (1);
+
+INSERT INTO roles (name)
+VALUES ('admin'),('edit'),('read');
+
View
175 ddl/lims2_devel/versions/1/up.sql
@@ -0,0 +1,175 @@
+
+
+--
+-- Initial schema version. Contains tables to store users, roles and qc data
+--
+
+--
+-- Schema metadata
+--
+CREATE TABLE schema_versions (
+ version INTEGER NOT NULL,
+ deployed_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ PRIMARY KEY (version, deployed_at)
+);
+GRANT SELECT ON schema_versions TO "lims2_devel/_ro", "lims2_devel/_rw";
+
+--
+-- Users and roles
+--
+CREATE TABLE users (
+ id SERIAL PRIMARY KEY,
+ name TEXT NOT NULL UNIQUE CHECK (name <> ''),
+ password TEXT
+);
+GRANT SELECT ON users TO "lims2_devel/_ro";
+GRANT SELECT, INSERT, UPDATE, DELETE ON users TO "lims2_devel/_rw";
+GRANT USAGE ON SEQUENCE users_id_seq TO "lims2_devel/_rw";
+
+CREATE TABLE roles (
+ id SERIAL PRIMARY KEY,
+ name TEXT NOT NULL UNIQUE CHECK (name <> '')
+);
+GRANT SELECT ON roles TO "lims2_devel/_ro";
+GRANT SELECT, INSERT, UPDATE, DELETE ON roles TO "lims2_devel/_rw";
+GRANT USAGE ON SEQUENCE roles_id_seq TO "lims2_devel/_rw";
+
+CREATE TABLE user_role (
+ user_id INTEGER NOT NULL REFERENCES users(id),
+ role_id INTEGER NOT NULL REFERENCES roles(id),
+ PRIMARY KEY (user_id, role_id)
+);
+GRANT SELECT ON user_role TO "lims2_devel/_ro";
+GRANT SELECT, INSERT, UPDATE, DELETE ON user_role TO "lims2_devel/_rw";
+
+--
+-- Data for sequencing QC
+--
+CREATE TABLE qc_eng_seqs (
+ id SERIAL PRIMARY KEY,
+ method TEXT NOT NULL,
+ params TEXT NOT NULL,
+ UNIQUE ( method, params )
+);
+GRANT SELECT ON qc_eng_seqs TO "lims2_devel/_ro";
+GRANT SELECT, INSERT, UPDATE, DELETE ON qc_eng_seqs TO "lims2_devel/_rw";
+GRANT USAGE ON SEQUENCE qc_eng_seqs_id_seq TO "lims2_devel/_rw";
+
+CREATE TABLE qc_templates (
+ id SERIAL PRIMARY KEY,
+ name TEXT NOT NULL,
+ created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ UNIQUE (name, created_at)
+);
+GRANT SELECT ON qc_templates TO "lims2_devel/_ro";
+GRANT SELECT, INSERT, UPDATE, DELETE ON qc_templates TO "lims2_devel/_rw";
+GRANT USAGE ON SEQUENCE qc_templates_id_seq TO "lims2_devel/_rw";
+
+CREATE TABLE qc_template_wells (
+ id SERIAL PRIMARY KEY,
+ qc_template_id INTEGER NOT NULL REFERENCES qc_templates(id),
+ name TEXT NOT NULL CHECK (name ~ '^[A-O](0[1-9]|1[0-9]|2[0-4])$'),
+ qc_eng_seq_id INTEGER NOT NULL REFERENCES qc_eng_seqs(id),
+ UNIQUE (qc_template_id, name)
+);
+GRANT SELECT ON qc_template_wells TO "lims2_devel/_ro";
+GRANT SELECT, INSERT, UPDATE, DELETE ON qc_template_wells TO "lims2_devel/_rw";
+GRANT USAGE ON SEQUENCE qc_template_wells_id_seq TO "lims2_devel/_rw";
+
+CREATE TABLE qc_runs (
+ id CHAR(36) PRIMARY KEY,
+ created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ created_by_id INTEGER NOT NULL REFERENCES users(id),
+ profile TEXT NOT NULL,
+ qc_template_id INTEGER NOT NULL REFERENCES qc_templates(id),
+ software_version TEXT NOT NULL,
+ upload_complete BOOLEAN NOT NULL DEFAULT FALSE
+);
+GRANT SELECT ON qc_runs TO "lims2_devel/_ro";
+GRANT SELECT, INSERT, UPDATE, DELETE ON qc_runs TO "lims2_devel/_rw";
+
+CREATE TABLE qc_seq_projects (
+ id TEXT PRIMARY KEY
+);
+GRANT SELECT ON qc_seq_projects TO "lims2_devel/_ro";
+GRANT SELECT, INSERT, UPDATE, DELETE ON qc_seq_projects TO "lims2_devel/_rw";
+
+CREATE TABLE qc_seq_project_wells (
+ id SERIAL PRIMARY KEY,
+ qc_seq_project_id TEXT NOT NULL REFERENCES qc_seq_projects(id),
+ plate_name TEXT NOT NULL,
+ well_name TEXT NOT NULL,
+ UNIQUE(qc_seq_project_id,plate_name,well_name)
+);
+GRANT SELECT ON qc_seq_project_wells TO "lims2_devel/_ro";
+GRANT SELECT, INSERT, UPDATE, DELETE ON qc_seq_project_wells TO "lims2_devel/_rw";
+GRANT USAGE ON qc_seq_project_wells_id_seq TO "lims2_devel/_rw";
+
+CREATE TABLE qc_seq_reads (
+ id TEXT PRIMARY KEY,
+ description TEXT NOT NULL DEFAULT '',
+ qc_seq_project_well_id INTEGER NOT NULL REFERENCES qc_seq_project_wells(id),
+ primer_name TEXT NOT NULL,
+ seq TEXT NOT NULL,
+ length INTEGER NOT NULL
+);
+GRANT SELECT ON qc_seq_reads TO "lims2_devel/_ro";
+GRANT SELECT, INSERT, UPDATE, DELETE ON qc_seq_reads TO "lims2_devel/_rw";
+
+CREATE INDEX ON qc_seq_reads(qc_seq_project_well_id);
+
+CREATE TABLE qc_run_seq_project (
+ qc_run_id CHAR(36) NOT NULL REFERENCES qc_runs(id),
+ qc_seq_project_id TEXT NOT NULL REFERENCES qc_seq_projects(id),
+ PRIMARY KEY(qc_run_id, qc_seq_project_id)
+);
+GRANT SELECT ON qc_run_seq_project TO "lims2_devel/_ro";
+GRANT SELECT, INSERT, UPDATE, DELETE ON qc_run_seq_project TO "lims2_devel/_rw";
+
+CREATE TABLE qc_test_results (
+ id SERIAL PRIMARY KEY,
+ qc_run_id CHAR(36) NOT NULL REFERENCES qc_runs(id),
+ qc_eng_seq_id INTEGER NOT NULL REFERENCES qc_eng_seqs(id),
+ qc_seq_project_well_id INTEGER NOT NULL REFERENCES qc_seq_project_wells(id),
+ score INTEGER NOT NULL DEFAULT 0,
+ pass BOOLEAN NOT NULL DEFAULT FALSE,
+ UNIQUE(qc_run_id, qc_eng_seq_id, qc_seq_project_well_id)
+);
+GRANT SELECT ON qc_test_results TO "lims2_devel/_ro";
+GRANT SELECT, INSERT, UPDATE, DELETE ON qc_test_results TO "lims2_devel/_rw";
+GRANT USAGE ON SEQUENCE qc_test_results_id_seq TO "lims2_devel/_rw";
+
+CREATE TABLE qc_alignments (
+ id SERIAL PRIMARY KEY,
+ qc_seq_read_id TEXT NOT NULL REFERENCES qc_seq_reads(id),
+ qc_eng_seq_id INTEGER NOT NULL REFERENCES qc_eng_seqs(id),
+ primer_name TEXT NOT NULL,
+ query_start INTEGER NOT NULL,
+ query_end INTEGER NOT NULL,
+ query_strand INTEGER NOT NULL CHECK (query_strand IN (1, -1)),
+ target_start INTEGER NOT NULL,
+ target_end INTEGER NOT NULL,
+ target_strand INTEGER NOT NULL CHECK (target_strand IN (1, -1)),
+ score INTEGER NOT NULL,
+ pass BOOLEAN NOT NULL DEFAULT FALSE,
+ features TEXT NOT NULL,
+ cigar TEXT NOT NULL,
+ op_str TEXT NOT NULL
+);
+GRANT SELECT ON qc_alignments TO "lims2_devel/_ro";
+GRANT SELECT, INSERT, UPDATE, DELETE ON qc_alignments TO "lims2_devel/_rw";
+GRANT USAGE ON SEQUENCE qc_alignments_id_seq TO "lims2_devel/_rw";
+
+CREATE TABLE qc_alignment_regions (
+ qc_alignment_id INTEGER NOT NULL REFERENCES qc_alignments(id),
+ name TEXT NOT NULL,
+ length INTEGER NOT NULL,
+ match_count INTEGER NOT NULL,
+ query_str TEXT NOT NULL,
+ target_str TEXT NOT NULL,
+ match_str TEXT NOT NULL,
+ pass BOOLEAN NOT NULL DEFAULT FALSE,
+ PRIMARY KEY(qc_alignment_id, name)
+);
+GRANT SELECT ON qc_alignment_regions TO "lims2_devel/_ro";
+GRANT SELECT, INSERT, UPDATE, DELETE ON qc_alignment_regions TO "lims2_devel/_rw";
View
20 ddl/lims2_live/roles.sql
@@ -0,0 +1,20 @@
+
+
+CREATE ROLE "lims2_live_admin" NOLOGIN NOINHERIT;
+CREATE ROLE "lims2_live_rw" NOLOGIN NOINHERIT;
+CREATE ROLE "lims2_live_ro" NOLOGIN NOINHERIT;
+CREATE ROLE "lims2_live_webapp" WITH ENCRYPTED PASSWORD '3Udg2bhzeG5q' LOGIN NOINHERIT IN ROLE "lims2_live_ro";
+CREATE ROLE "lims2_live_webapp_ro" WITH ENCRYPTED PASSWORD 'eIpCbK5GiLnE' LOGIN INHERIT IN ROLE "lims2_live_ro";
+CREATE ROLE "lims2_live_task" WITH ENCRYPTED PASSWORD 'IfuqUIrrEGaE' LOGIN INHERIT IN ROLE "lims2_live_rw";
+
+GRANT "lims2_live_rw" TO "rm7@sanger.ac.uk";
+GRANT "rm7@sanger.ac.uk" TO "lims2_live_webapp";
+GRANT "lims2_live_rw" TO "sp12@sanger.ac.uk";
+GRANT "sp12@sanger.ac.uk" TO "lims2_live_webapp";
+
+GRANT "lims2_live_admin" TO "rm7";
+GRANT "lims2_live_ro" TO "rm7";
+GRANT "lims2_live_rw" TO "rm7";
+GRANT "lims2_live_admin" TO "sp12";
+GRANT "lims2_live_ro" TO "sp12";
+GRANT "lims2_live_rw" TO "sp12";
View
13 ddl/lims2_live/schema.sql
@@ -0,0 +1,13 @@
+
+
+DROP SCHEMA IF EXISTS public CASCADE;
+CREATE SCHEMA public AUTHORIZATION "lims2_live_admin";
+REVOKE ALL ON SCHEMA public FROM PUBLIC;
+GRANT USAGE ON SCHEMA public TO "lims2_live_rw";
+GRANT USAGE ON SCHEMA public TO "lims2_live_ro";
+
+DROP SCHEMA IF EXISTS audit CASCADE;
+CREATE SCHEMA audit AUTHORIZATION "lims2_live_admin";
+REVOKE ALL ON SCHEMA audit FROM PUBLIC;
+GRANT USAGE ON SCHEMA audit TO "lims2_live_rw";
+GRANT USAGE ON SCHEMA audit TO "lims2_live_ro";
View
7 ddl/lims2_live/test_roles.sql
@@ -0,0 +1,7 @@
+
+
+CREATE ROLE "lims2_live_test_admin" WITH NOLOGIN NOINHERIT;
+CREATE ROLE "lims2_live_test" WITH ENCRYPTED PASSWORD 'H6soxoL61tFG' LOGIN INHERIT IN ROLE "lims2_live_rw";
+
+GRANT "lims2_live_test_admin" TO "lims2_live_test";
+GRANT "lims2_live_admin" TO "lims2_live_test_admin";
View
428 ddl/lims2_live/versions/1/audit-up.sql
@@ -0,0 +1,428 @@
+CREATE TABLE audit.roles (
+audit_op CHAR(1) NOT NULL CHECK (audit_op IN ('D','I','U')),
+audit_user TEXT NOT NULL,
+audit_stamp TIMESTAMP NOT NULL,
+audit_txid INTEGER NOT NULL,
+id integer,
+name text
+);
+GRANT SELECT ON audit.roles TO lims2_live_ro;
+GRANT SELECT,INSERT ON audit.roles TO lims2_live_rw;
+CREATE OR REPLACE FUNCTION public.process_roles_audit()
+RETURNS TRIGGER AS $roles_audit$
+ BEGIN
+ IF (TG_OP = 'DELETE') THEN
+ INSERT INTO audit.roles SELECT 'D', user, now(), txid_current(), OLD.*;
+ ELSIF (TG_OP = 'UPDATE') THEN
+ INSERT INTO audit.roles SELECT 'U', user, now(), txid_current(), NEW.*;
+ ELSIF (TG_OP = 'INSERT') THEN
+ INSERT INTO audit.roles SELECT 'I', user, now(), txid_current(), NEW.*;
+ END IF;
+ RETURN NULL;
+ END;
+$roles_audit$ LANGUAGE plpgsql;
+CREATE TRIGGER roles_audit
+AFTER INSERT OR UPDATE OR DELETE ON public.roles
+ FOR EACH ROW EXECUTE PROCEDURE public.process_roles_audit();
+CREATE TABLE audit.qc_seq_project_wells (
+audit_op CHAR(1) NOT NULL CHECK (audit_op IN ('D','I','U')),
+audit_user TEXT NOT NULL,
+audit_stamp TIMESTAMP NOT NULL,
+audit_txid INTEGER NOT NULL,
+id integer,
+qc_seq_project_id text,
+plate_name text,
+well_name text
+);
+GRANT SELECT ON audit.qc_seq_project_wells TO lims2_live_ro;
+GRANT SELECT,INSERT ON audit.qc_seq_project_wells TO lims2_live_rw;
+CREATE OR REPLACE FUNCTION public.process_qc_seq_project_wells_audit()
+RETURNS TRIGGER AS $qc_seq_project_wells_audit$
+ BEGIN
+ IF (TG_OP = 'DELETE') THEN
+ INSERT INTO audit.qc_seq_project_wells SELECT 'D', user, now(), txid_current(), OLD.*;
+ ELSIF (TG_OP = 'UPDATE') THEN
+ INSERT INTO audit.qc_seq_project_wells SELECT 'U', user, now(), txid_current(), NEW.*;
+ ELSIF (TG_OP = 'INSERT') THEN
+ INSERT INTO audit.qc_seq_project_wells SELECT 'I', user, now(), txid_current(), NEW.*;
+ END IF;
+ RETURN NULL;
+ END;
+$qc_seq_project_wells_audit$ LANGUAGE plpgsql;
+CREATE TRIGGER qc_seq_project_wells_audit
+AFTER INSERT OR UPDATE OR DELETE ON public.qc_seq_project_wells
+ FOR EACH ROW EXECUTE PROCEDURE public.process_qc_seq_project_wells_audit();
+CREATE TABLE audit.schema_versions (
+audit_op CHAR(1) NOT NULL CHECK (audit_op IN ('D','I','U')),
+audit_user TEXT NOT NULL,
+audit_stamp TIMESTAMP NOT NULL,
+audit_txid INTEGER NOT NULL,
+version integer,
+deployed_at timestamp without time zone
+);
+GRANT SELECT ON audit.schema_versions TO lims2_live_ro;
+GRANT SELECT,INSERT ON audit.schema_versions TO lims2_live_rw;
+CREATE OR REPLACE FUNCTION public.process_schema_versions_audit()
+RETURNS TRIGGER AS $schema_versions_audit$
+ BEGIN
+ IF (TG_OP = 'DELETE') THEN
+ INSERT INTO audit.schema_versions SELECT 'D', user, now(), txid_current(), OLD.*;
+ ELSIF (TG_OP = 'UPDATE') THEN
+ INSERT INTO audit.schema_versions SELECT 'U', user, now(), txid_current(), NEW.*;
+ ELSIF (TG_OP = 'INSERT') THEN
+ INSERT INTO audit.schema_versions SELECT 'I', user, now(), txid_current(), NEW.*;
+ END IF;
+ RETURN NULL;
+ END;
+$schema_versions_audit$ LANGUAGE plpgsql;
+CREATE TRIGGER schema_versions_audit
+AFTER INSERT OR UPDATE OR DELETE ON public.schema_versions
+ FOR EACH ROW EXECUTE PROCEDURE public.process_schema_versions_audit();
+CREATE TABLE audit.qc_alignments (
+audit_op CHAR(1) NOT NULL CHECK (audit_op IN ('D','I','U')),
+audit_user TEXT NOT NULL,
+audit_stamp TIMESTAMP NOT NULL,
+audit_txid INTEGER NOT NULL,
+id integer,
+qc_seq_read_id text,
+qc_eng_seq_id integer,
+primer_name text,
+query_start integer,
+query_end integer,
+query_strand integer,
+target_start integer,
+target_end integer,
+target_strand integer,
+score integer,
+pass boolean,
+features text,
+cigar text,
+op_str text
+);
+GRANT SELECT ON audit.qc_alignments TO lims2_live_ro;
+GRANT SELECT,INSERT ON audit.qc_alignments TO lims2_live_rw;
+CREATE OR REPLACE FUNCTION public.process_qc_alignments_audit()
+RETURNS TRIGGER AS $qc_alignments_audit$
+ BEGIN
+ IF (TG_OP = 'DELETE') THEN
+ INSERT INTO audit.qc_alignments SELECT 'D', user, now(), txid_current(), OLD.*;
+ ELSIF (TG_OP = 'UPDATE') THEN
+ INSERT INTO audit.qc_alignments SELECT 'U', user, now(), txid_current(), NEW.*;
+ ELSIF (TG_OP = 'INSERT') THEN
+ INSERT INTO audit.qc_alignments SELECT 'I', user, now(), txid_current(), NEW.*;
+ END IF;
+ RETURN NULL;
+ END;
+$qc_alignments_audit$ LANGUAGE plpgsql;
+CREATE TRIGGER qc_alignments_audit
+AFTER INSERT OR UPDATE OR DELETE ON public.qc_alignments
+ FOR EACH ROW EXECUTE PROCEDURE public.process_qc_alignments_audit();
+CREATE TABLE audit.user_role (
+audit_op CHAR(1) NOT NULL CHECK (audit_op IN ('D','I','U')),
+audit_user TEXT NOT NULL,
+audit_stamp TIMESTAMP NOT NULL,
+audit_txid INTEGER NOT NULL,
+user_id integer,
+role_id integer
+);
+GRANT SELECT ON audit.user_role TO lims2_live_ro;
+GRANT SELECT,INSERT ON audit.user_role TO lims2_live_rw;
+CREATE OR REPLACE FUNCTION public.process_user_role_audit()
+RETURNS TRIGGER AS $user_role_audit$
+ BEGIN
+ IF (TG_OP = 'DELETE') THEN
+ INSERT INTO audit.user_role SELECT 'D', user, now(), txid_current(), OLD.*;
+ ELSIF (TG_OP = 'UPDATE') THEN
+ INSERT INTO audit.user_role SELECT 'U', user, now(), txid_current(), NEW.*;
+ ELSIF (TG_OP = 'INSERT') THEN
+ INSERT INTO audit.user_role SELECT 'I', user, now(), txid_current(), NEW.*;
+ END IF;
+ RETURN NULL;
+ END;
+$user_role_audit$ LANGUAGE plpgsql;
+CREATE TRIGGER user_role_audit
+AFTER INSERT OR UPDATE OR DELETE ON public.user_role
+ FOR EACH ROW EXECUTE PROCEDURE public.process_user_role_audit();
+CREATE TABLE audit.qc_templates (
+audit_op CHAR(1) NOT NULL CHECK (audit_op IN ('D','I','U')),
+audit_user TEXT NOT NULL,
+audit_stamp TIMESTAMP NOT NULL,
+audit_txid INTEGER NOT NULL,
+id integer,
+name text,
+created_at timestamp without time zone
+);
+GRANT SELECT ON audit.qc_templates TO lims2_live_ro;
+GRANT SELECT,INSERT ON audit.qc_templates TO lims2_live_rw;
+CREATE OR REPLACE FUNCTION public.process_qc_templates_audit()
+RETURNS TRIGGER AS $qc_templates_audit$
+ BEGIN
+ IF (TG_OP = 'DELETE') THEN
+ INSERT INTO audit.qc_templates SELECT 'D', user, now(), txid_current(), OLD.*;
+ ELSIF (TG_OP = 'UPDATE') THEN
+ INSERT INTO audit.qc_templates SELECT 'U', user, now(), txid_current(), NEW.*;
+ ELSIF (TG_OP = 'INSERT') THEN
+ INSERT INTO audit.qc_templates SELECT 'I', user, now(), txid_current(), NEW.*;
+ END IF;
+ RETURN NULL;
+ END;
+$qc_templates_audit$ LANGUAGE plpgsql;
+CREATE TRIGGER qc_templates_audit
+AFTER INSERT OR UPDATE OR DELETE ON public.qc_templates
+ FOR EACH ROW EXECUTE PROCEDURE public.process_qc_templates_audit();
+CREATE TABLE audit.qc_eng_seqs (
+audit_op CHAR(1) NOT NULL CHECK (audit_op IN ('D','I','U')),
+audit_user TEXT NOT NULL,
+audit_stamp TIMESTAMP NOT NULL,
+audit_txid INTEGER NOT NULL,
+id integer,
+method text,
+params text
+);
+GRANT SELECT ON audit.qc_eng_seqs TO lims2_live_ro;
+GRANT SELECT,INSERT ON audit.qc_eng_seqs TO lims2_live_rw;
+CREATE OR REPLACE FUNCTION public.process_qc_eng_seqs_audit()
+RETURNS TRIGGER AS $qc_eng_seqs_audit$
+ BEGIN
+ IF (TG_OP = 'DELETE') THEN
+ INSERT INTO audit.qc_eng_seqs SELECT 'D', user, now(), txid_current(), OLD.*;
+ ELSIF (TG_OP = 'UPDATE') THEN
+ INSERT INTO audit.qc_eng_seqs SELECT 'U', user, now(), txid_current(), NEW.*;
+ ELSIF (TG_OP = 'INSERT') THEN
+ INSERT INTO audit.qc_eng_seqs SELECT 'I', user, now(), txid_current(), NEW.*;
+ END IF;
+ RETURN NULL;
+ END;
+$qc_eng_seqs_audit$ LANGUAGE plpgsql;
+CREATE TRIGGER qc_eng_seqs_audit
+AFTER INSERT OR UPDATE OR DELETE ON public.qc_eng_seqs
+ FOR EACH ROW EXECUTE PROCEDURE public.process_qc_eng_seqs_audit();
+CREATE TABLE audit.qc_alignment_regions (
+audit_op CHAR(1) NOT NULL CHECK (audit_op IN ('D','I','U')),
+audit_user TEXT NOT NULL,
+audit_stamp TIMESTAMP NOT NULL,
+audit_txid INTEGER NOT NULL,
+qc_alignment_id integer,
+name text,
+length integer,
+match_count integer,
+query_str text,
+target_str text,
+match_str text,
+pass boolean
+);
+GRANT SELECT ON audit.qc_alignment_regions TO lims2_live_ro;
+GRANT SELECT,INSERT ON audit.qc_alignment_regions TO lims2_live_rw;
+CREATE OR REPLACE FUNCTION public.process_qc_alignment_regions_audit()
+RETURNS TRIGGER AS $qc_alignment_regions_audit$
+ BEGIN
+ IF (TG_OP = 'DELETE') THEN
+ INSERT INTO audit.qc_alignment_regions SELECT 'D', user, now(), txid_current(), OLD.*;
+ ELSIF (TG_OP = 'UPDATE') THEN
+ INSERT INTO audit.qc_alignment_regions SELECT 'U', user, now(), txid_current(), NEW.*;
+ ELSIF (TG_OP = 'INSERT') THEN
+ INSERT INTO audit.qc_alignment_regions SELECT 'I', user, now(), txid_current(), NEW.*;
+ END IF;
+ RETURN NULL;
+ END;
+$qc_alignment_regions_audit$ LANGUAGE plpgsql;
+CREATE TRIGGER qc_alignment_regions_audit
+AFTER INSERT OR UPDATE OR DELETE ON public.qc_alignment_regions
+ FOR EACH ROW EXECUTE PROCEDURE public.process_qc_alignment_regions_audit();
+CREATE TABLE audit.users (
+audit_op CHAR(1) NOT NULL CHECK (audit_op IN ('D','I','U')),
+audit_user TEXT NOT NULL,
+audit_stamp TIMESTAMP NOT NULL,
+audit_txid INTEGER NOT NULL,
+id integer,
+name text,
+password text
+);
+GRANT SELECT ON audit.users TO lims2_live_ro;
+GRANT SELECT,INSERT ON audit.users TO lims2_live_rw;
+CREATE OR REPLACE FUNCTION public.process_users_audit()
+RETURNS TRIGGER AS $users_audit$
+ BEGIN
+ IF (TG_OP = 'DELETE') THEN
+ INSERT INTO audit.users SELECT 'D', user, now(), txid_current(), OLD.*;
+ ELSIF (TG_OP = 'UPDATE') THEN
+ INSERT INTO audit.users SELECT 'U', user, now(), txid_current(), NEW.*;
+ ELSIF (TG_OP = 'INSERT') THEN
+ INSERT INTO audit.users SELECT 'I', user, now(), txid_current(), NEW.*;
+ END IF;
+ RETURN NULL;
+ END;
+$users_audit$ LANGUAGE plpgsql;
+CREATE TRIGGER users_audit
+AFTER INSERT OR UPDATE OR DELETE ON public.users
+ FOR EACH ROW EXECUTE PROCEDURE public.process_users_audit();
+CREATE TABLE audit.qc_test_results (
+audit_op CHAR(1) NOT NULL CHECK (audit_op IN ('D','I','U')),
+audit_user TEXT NOT NULL,
+audit_stamp TIMESTAMP NOT NULL,
+audit_txid INTEGER NOT NULL,
+id integer,
+qc_run_id character(36),
+qc_eng_seq_id integer,
+qc_seq_project_well_id integer,
+score integer,
+pass boolean
+);
+GRANT SELECT ON audit.qc_test_results TO lims2_live_ro;
+GRANT SELECT,INSERT ON audit.qc_test_results TO lims2_live_rw;
+CREATE OR REPLACE FUNCTION public.process_qc_test_results_audit()
+RETURNS TRIGGER AS $qc_test_results_audit$
+ BEGIN
+ IF (TG_OP = 'DELETE') THEN
+ INSERT INTO audit.qc_test_results SELECT 'D', user, now(), txid_current(), OLD.*;
+ ELSIF (TG_OP = 'UPDATE') THEN
+ INSERT INTO audit.qc_test_results SELECT 'U', user, now(), txid_current(), NEW.*;
+ ELSIF (TG_OP = 'INSERT') THEN
+ INSERT INTO audit.qc_test_results SELECT 'I', user, now(), txid_current(), NEW.*;
+ END IF;
+ RETURN NULL;
+ END;
+$qc_test_results_audit$ LANGUAGE plpgsql;
+CREATE TRIGGER qc_test_results_audit
+AFTER INSERT OR UPDATE OR DELETE ON public.qc_test_results
+ FOR EACH ROW EXECUTE PROCEDURE public.process_qc_test_results_audit();
+CREATE TABLE audit.qc_seq_reads (
+audit_op CHAR(1) NOT NULL CHECK (audit_op IN ('D','I','U')),
+audit_user TEXT NOT NULL,
+audit_stamp TIMESTAMP NOT NULL,
+audit_txid INTEGER NOT NULL,
+id text,
+description text,
+qc_seq_project_well_id integer,
+primer_name text,
+seq text,
+length integer
+);
+GRANT SELECT ON audit.qc_seq_reads TO lims2_live_ro;
+GRANT SELECT,INSERT ON audit.qc_seq_reads TO lims2_live_rw;
+CREATE OR REPLACE FUNCTION public.process_qc_seq_reads_audit()
+RETURNS TRIGGER AS $qc_seq_reads_audit$
+ BEGIN
+ IF (TG_OP = 'DELETE') THEN
+ INSERT INTO audit.qc_seq_reads SELECT 'D', user, now(), txid_current(), OLD.*;
+ ELSIF (TG_OP = 'UPDATE') THEN
+ INSERT INTO audit.qc_seq_reads SELECT 'U', user, now(), txid_current(), NEW.*;
+ ELSIF (TG_OP = 'INSERT') THEN
+ INSERT INTO audit.qc_seq_reads SELECT 'I', user, now(), txid_current(), NEW.*;
+ END IF;
+ RETURN NULL;
+ END;
+$qc_seq_reads_audit$ LANGUAGE plpgsql;
+CREATE TRIGGER qc_seq_reads_audit
+AFTER INSERT OR UPDATE OR DELETE ON public.qc_seq_reads
+ FOR EACH ROW EXECUTE PROCEDURE public.process_qc_seq_reads_audit();
+CREATE TABLE audit.qc_runs (
+audit_op CHAR(1) NOT NULL CHECK (audit_op IN ('D','I','U')),
+audit_user TEXT NOT NULL,
+audit_stamp TIMESTAMP NOT NULL,
+audit_txid INTEGER NOT NULL,
+id character(36),
+created_at timestamp without time zone,
+created_by_id integer,
+profile text,
+qc_template_id integer,
+software_version text,
+upload_complete boolean
+);
+GRANT SELECT ON audit.qc_runs TO lims2_live_ro;
+GRANT SELECT,INSERT ON audit.qc_runs TO lims2_live_rw;
+CREATE OR REPLACE FUNCTION public.process_qc_runs_audit()
+RETURNS TRIGGER AS $qc_runs_audit$
+ BEGIN
+ IF (TG_OP = 'DELETE') THEN
+ INSERT INTO audit.qc_runs SELECT 'D', user, now(), txid_current(), OLD.*;
+ ELSIF (TG_OP = 'UPDATE') THEN
+ INSERT INTO audit.qc_runs SELECT 'U', user, now(), txid_current(), NEW.*;
+ ELSIF (TG_OP = 'INSERT') THEN
+ INSERT INTO audit.qc_runs SELECT 'I', user, now(), txid_current(), NEW.*;
+ END IF;
+ RETURN NULL;
+ END;
+$qc_runs_audit$ LANGUAGE plpgsql;
+CREATE TRIGGER qc_runs_audit
+AFTER INSERT OR UPDATE OR DELETE ON public.qc_runs
+ FOR EACH ROW EXECUTE PROCEDURE public.process_qc_runs_audit();
+CREATE TABLE audit.qc_template_wells (
+audit_op CHAR(1) NOT NULL CHECK (audit_op IN ('D','I','U')),
+audit_user TEXT NOT NULL,
+audit_stamp TIMESTAMP NOT NULL,
+audit_txid INTEGER NOT NULL,
+id integer,
+qc_template_id integer,
+name text,
+qc_eng_seq_id integer
+);
+GRANT SELECT ON audit.qc_template_wells TO lims2_live_ro;
+GRANT SELECT,INSERT ON audit.qc_template_wells TO lims2_live_rw;
+CREATE OR REPLACE FUNCTION public.process_qc_template_wells_audit()
+RETURNS TRIGGER AS $qc_template_wells_audit$
+ BEGIN
+ IF (TG_OP = 'DELETE') THEN
+ INSERT INTO audit.qc_template_wells SELECT 'D', user, now(), txid_current(), OLD.*;
+ ELSIF (TG_OP = 'UPDATE') THEN
+ INSERT INTO audit.qc_template_wells SELECT 'U', user, now(), txid_current(), NEW.*;
+ ELSIF (TG_OP = 'INSERT') THEN
+ INSERT INTO audit.qc_template_wells SELECT 'I', user, now(), txid_current(), NEW.*;
+ END IF;
+ RETURN NULL;
+ END;
+$qc_template_wells_audit$ LANGUAGE plpgsql;
+CREATE TRIGGER qc_template_wells_audit
+AFTER INSERT OR UPDATE OR DELETE ON public.qc_template_wells
+ FOR EACH ROW EXECUTE PROCEDURE public.process_qc_template_wells_audit();
+CREATE TABLE audit.qc_run_seq_project (
+audit_op CHAR(1) NOT NULL CHECK (audit_op IN ('D','I','U')),
+audit_user TEXT NOT NULL,
+audit_stamp TIMESTAMP NOT NULL,
+audit_txid INTEGER NOT NULL,
+qc_run_id character(36),
+qc_seq_project_id text
+);
+GRANT SELECT ON audit.qc_run_seq_project TO lims2_live_ro;
+GRANT SELECT,INSERT ON audit.qc_run_seq_project TO lims2_live_rw;
+CREATE OR REPLACE FUNCTION public.process_qc_run_seq_project_audit()
+RETURNS TRIGGER AS $qc_run_seq_project_audit$
+ BEGIN
+ IF (TG_OP = 'DELETE') THEN
+ INSERT INTO audit.qc_run_seq_project SELECT 'D', user, now(), txid_current(), OLD.*;
+ ELSIF (TG_OP = 'UPDATE') THEN
+ INSERT INTO audit.qc_run_seq_project SELECT 'U', user, now(), txid_current(), NEW.*;
+ ELSIF (TG_OP = 'INSERT') THEN
+ INSERT INTO audit.qc_run_seq_project SELECT 'I', user, now(), txid_current(), NEW.*;
+ END IF;
+ RETURN NULL;
+ END;
+$qc_run_seq_project_audit$ LANGUAGE plpgsql;
+CREATE TRIGGER qc_run_seq_project_audit
+AFTER INSERT OR UPDATE OR DELETE ON public.qc_run_seq_project
+ FOR EACH ROW EXECUTE PROCEDURE public.process_qc_run_seq_project_audit();
+CREATE TABLE audit.qc_seq_projects (
+audit_op CHAR(1) NOT NULL CHECK (audit_op IN ('D','I','U')),
+audit_user TEXT NOT NULL,
+audit_stamp TIMESTAMP NOT NULL,
+audit_txid INTEGER NOT NULL,
+id text
+);
+GRANT SELECT ON audit.qc_seq_projects TO lims2_live_ro;
+GRANT SELECT,INSERT ON audit.qc_seq_projects TO lims2_live_rw;
+CREATE OR REPLACE FUNCTION public.process_qc_seq_projects_audit()
+RETURNS TRIGGER AS $qc_seq_projects_audit$
+ BEGIN
+ IF (TG_OP = 'DELETE') THEN
+ INSERT INTO audit.qc_seq_projects SELECT 'D', user, now(), txid_current(), OLD.*;
+ ELSIF (TG_OP = 'UPDATE') THEN
+ INSERT INTO audit.qc_seq_projects SELECT 'U', user, now(), txid_current(), NEW.*;
+ ELSIF (TG_OP = 'INSERT') THEN
+ INSERT INTO audit.qc_seq_projects SELECT 'I', user, now(), txid_current(), NEW.*;
+ END IF;
+ RETURN NULL;
+ END;
+$qc_seq_projects_audit$ LANGUAGE plpgsql;
+CREATE TRIGGER qc_seq_projects_audit
+AFTER INSERT OR UPDATE OR DELETE ON public.qc_seq_projects
+ FOR EACH ROW EXECUTE PROCEDURE public.process_qc_seq_projects_audit();
View
8 ddl/lims2_live/versions/1/fixtures.sql
@@ -0,0 +1,8 @@
+
+
+
+INSERT INTO schema_versions (version) VALUES (1);
+
+INSERT INTO roles (name)
+VALUES ('admin'),('edit'),('read');
+
View
175 ddl/lims2_live/versions/1/up.sql
@@ -0,0 +1,175 @@
+
+
+--
+-- Initial schema version. Contains tables to store users, roles and qc data
+--
+
+--
+-- Schema metadata
+--
+CREATE TABLE schema_versions (
+ version INTEGER NOT NULL,
+ deployed_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ PRIMARY KEY (version, deployed_at)
+);
+GRANT SELECT ON schema_versions TO "lims2_live_ro", "lims2_live_rw";
+
+--
+-- Users and roles
+--
+CREATE TABLE users (
+ id SERIAL PRIMARY KEY,
+ name TEXT NOT NULL UNIQUE CHECK (name <> ''),
+ password TEXT
+);
+GRANT SELECT ON users TO "lims2_live_ro";
+GRANT SELECT, INSERT, UPDATE, DELETE ON users TO "lims2_live_rw";
+GRANT USAGE ON SEQUENCE users_id_seq TO "lims2_live_rw";
+
+CREATE TABLE roles (
+ id SERIAL PRIMARY KEY,
+ name TEXT NOT NULL UNIQUE CHECK (name <> '')
+);
+GRANT SELECT ON roles TO "lims2_live_ro";
+GRANT SELECT, INSERT, UPDATE, DELETE ON roles TO "lims2_live_rw";
+GRANT USAGE ON SEQUENCE roles_id_seq TO "lims2_live_rw";
+
+CREATE TABLE user_role (
+ user_id INTEGER NOT NULL REFERENCES users(id),
+ role_id INTEGER NOT NULL REFERENCES roles(id),
+ PRIMARY KEY (user_id, role_id)
+);
+GRANT SELECT ON user_role TO "lims2_live_ro";
+GRANT SELECT, INSERT, UPDATE, DELETE ON user_role TO "lims2_live_rw";
+
+--
+-- Data for sequencing QC
+--
+CREATE TABLE qc_eng_seqs (
+ id SERIAL PRIMARY KEY,
+ method TEXT NOT NULL,
+ params TEXT NOT NULL,
+ UNIQUE ( method, params )
+);
+GRANT SELECT ON qc_eng_seqs TO "lims2_live_ro";
+GRANT SELECT, INSERT, UPDATE, DELETE ON qc_eng_seqs TO "lims2_live_rw";
+GRANT USAGE ON SEQUENCE qc_eng_seqs_id_seq TO "lims2_live_rw";
+
+CREATE TABLE qc_templates (
+ id SERIAL PRIMARY KEY,
+ name TEXT NOT NULL,
+ created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ UNIQUE (name, created_at)
+);
+GRANT SELECT ON qc_templates TO "lims2_live_ro";
+GRANT SELECT, INSERT, UPDATE, DELETE ON qc_templates TO "lims2_live_rw";
+GRANT USAGE ON SEQUENCE qc_templates_id_seq TO "lims2_live_rw";
+
+CREATE TABLE qc_template_wells (
+ id SERIAL PRIMARY KEY,
+ qc_template_id INTEGER NOT NULL REFERENCES qc_templates(id),
+ name TEXT NOT NULL CHECK (name ~ '^[A-O](0[1-9]|1[0-9]|2[0-4])$'),
+ qc_eng_seq_id INTEGER NOT NULL REFERENCES qc_eng_seqs(id),
+ UNIQUE (qc_template_id, name)
+);
+GRANT SELECT ON qc_template_wells TO "lims2_live_ro";
+GRANT SELECT, INSERT, UPDATE, DELETE ON qc_template_wells TO "lims2_live_rw";
+GRANT USAGE ON SEQUENCE qc_template_wells_id_seq TO "lims2_live_rw";
+
+CREATE TABLE qc_runs (
+ id CHAR(36) PRIMARY KEY,
+ created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ created_by_id INTEGER NOT NULL REFERENCES users(id),
+ profile TEXT NOT NULL,
+ qc_template_id INTEGER NOT NULL REFERENCES qc_templates(id),
+ software_version TEXT NOT NULL,
+ upload_complete BOOLEAN NOT NULL DEFAULT FALSE
+);
+GRANT SELECT ON qc_runs TO "lims2_live_ro";
+GRANT SELECT, INSERT, UPDATE, DELETE ON qc_runs TO "lims2_live_rw";
+
+CREATE TABLE qc_seq_projects (
+ id TEXT PRIMARY KEY
+);
+GRANT SELECT ON qc_seq_projects TO "lims2_live_ro";
+GRANT SELECT, INSERT, UPDATE, DELETE ON qc_seq_projects TO "lims2_live_rw";
+
+CREATE TABLE qc_seq_project_wells (
+ id SERIAL PRIMARY KEY,
+ qc_seq_project_id TEXT NOT NULL REFERENCES qc_seq_projects(id),
+ plate_name TEXT NOT NULL,
+ well_name TEXT NOT NULL,
+ UNIQUE(qc_seq_project_id,plate_name,well_name)
+);
+GRANT SELECT ON qc_seq_project_wells TO "lims2_live_ro";
+GRANT SELECT, INSERT, UPDATE, DELETE ON qc_seq_project_wells TO "lims2_live_rw";
+GRANT USAGE ON qc_seq_project_wells_id_seq TO "lims2_live_rw";
+
+CREATE TABLE qc_seq_reads (
+ id TEXT PRIMARY KEY,
+ description TEXT NOT NULL DEFAULT '',
+ qc_seq_project_well_id INTEGER NOT NULL REFERENCES qc_seq_project_wells(id),
+ primer_name TEXT NOT NULL,
+ seq TEXT NOT NULL,
+ length INTEGER NOT NULL
+);
+GRANT SELECT ON qc_seq_reads TO "lims2_live_ro";
+GRANT SELECT, INSERT, UPDATE, DELETE ON qc_seq_reads TO "lims2_live_rw";
+
+CREATE INDEX ON qc_seq_reads(qc_seq_project_well_id);
+
+CREATE TABLE qc_run_seq_project (
+ qc_run_id CHAR(36) NOT NULL REFERENCES qc_runs(id),
+ qc_seq_project_id TEXT NOT NULL REFERENCES qc_seq_projects(id),
+ PRIMARY KEY(qc_run_id, qc_seq_project_id)
+);
+GRANT SELECT ON qc_run_seq_project TO "lims2_live_ro";
+GRANT SELECT, INSERT, UPDATE, DELETE ON qc_run_seq_project TO "lims2_live_rw";
+
+CREATE TABLE qc_test_results (
+ id SERIAL PRIMARY KEY,
+ qc_run_id CHAR(36) NOT NULL REFERENCES qc_runs(id),
+ qc_eng_seq_id INTEGER NOT NULL REFERENCES qc_eng_seqs(id),
+ qc_seq_project_well_id INTEGER NOT NULL REFERENCES qc_seq_project_wells(id),
+ score INTEGER NOT NULL DEFAULT 0,
+ pass BOOLEAN NOT NULL DEFAULT FALSE,
+ UNIQUE(qc_run_id, qc_eng_seq_id, qc_seq_project_well_id)
+);
+GRANT SELECT ON qc_test_results TO "lims2_live_ro";
+GRANT SELECT, INSERT, UPDATE, DELETE ON qc_test_results TO "lims2_live_rw";
+GRANT USAGE ON SEQUENCE qc_test_results_id_seq TO "lims2_live_rw";
+
+CREATE TABLE qc_alignments (
+ id SERIAL PRIMARY KEY,
+ qc_seq_read_id TEXT NOT NULL REFERENCES qc_seq_reads(id),
+ qc_eng_seq_id INTEGER NOT NULL REFERENCES qc_eng_seqs(id),
+ primer_name TEXT NOT NULL,
+ query_start INTEGER NOT NULL,
+ query_end INTEGER NOT NULL,
+ query_strand INTEGER NOT NULL CHECK (query_strand IN (1, -1)),
+ target_start INTEGER NOT NULL,
+ target_end INTEGER NOT NULL,
+ target_strand INTEGER NOT NULL CHECK (target_strand IN (1, -1)),
+ score INTEGER NOT NULL,
+ pass BOOLEAN NOT NULL DEFAULT FALSE,
+ features TEXT NOT NULL,
+ cigar TEXT NOT NULL,
+ op_str TEXT NOT NULL
+);
+GRANT SELECT ON qc_alignments TO "lims2_live_ro";
+GRANT SELECT, INSERT, UPDATE, DELETE ON qc_alignments TO "lims2_live_rw";
+GRANT USAGE ON SEQUENCE qc_alignments_id_seq TO "lims2_live_rw";
+
+CREATE TABLE qc_alignment_regions (
+ qc_alignment_id INTEGER NOT NULL REFERENCES qc_alignments(id),
+ name TEXT NOT NULL,
+ length INTEGER NOT NULL,
+ match_count INTEGER NOT NULL,
+ query_str TEXT NOT NULL,
+ target_str TEXT NOT NULL,
+ match_str TEXT NOT NULL,
+ pass BOOLEAN NOT NULL DEFAULT FALSE,
+ PRIMARY KEY(qc_alignment_id, name)
+);
+GRANT SELECT ON qc_alignment_regions TO "lims2_live_ro";
+GRANT SELECT, INSERT, UPDATE, DELETE ON qc_alignment_regions TO "lims2_live_rw";
View
20 ddl/lims2_staging/roles.sql
@@ -0,0 +1,20 @@
+
+
+CREATE ROLE "lims2_staging_admin" NOLOGIN NOINHERIT;
+CREATE ROLE "lims2_staging_rw" NOLOGIN NOINHERIT;
+CREATE ROLE "lims2_staging_ro" NOLOGIN NOINHERIT;
+CREATE ROLE "lims2_staging_webapp" WITH ENCRYPTED PASSWORD 'cxjkBaL7puC7' LOGIN NOINHERIT IN ROLE "lims2_staging_ro";
+CREATE ROLE "lims2_staging_webapp_ro" WITH ENCRYPTED PASSWORD 'VFJO7BINbSXX' LOGIN INHERIT IN ROLE "lims2_staging_ro";
+CREATE ROLE "lims2_staging_task" WITH ENCRYPTED PASSWORD 'K2V4BEv95jdn' LOGIN INHERIT IN ROLE "lims2_staging_rw";
+
+GRANT "lims2_staging_rw" TO "rm7@sanger.ac.uk";
+GRANT "rm7@sanger.ac.uk" TO "lims2_staging_webapp";
+GRANT "lims2_staging_rw" TO "sp12@sanger.ac.uk";
+GRANT "sp12@sanger.ac.uk" TO "lims2_staging_webapp";
+
+GRANT "lims2_staging_admin" TO "rm7";
+GRANT "lims2_staging_ro" TO "rm7";
+GRANT "lims2_staging_rw" TO "rm7";
+GRANT "lims2_staging_admin" TO "sp12";
+GRANT "lims2_staging_ro" TO "sp12";
+GRANT "lims2_staging_rw" TO "sp12";
View
13 ddl/lims2_staging/schema.sql
@@ -0,0 +1,13 @@
+
+
+DROP SCHEMA IF EXISTS public CASCADE;
+CREATE SCHEMA public AUTHORIZATION "lims2_staging_admin";
+REVOKE ALL ON SCHEMA public FROM PUBLIC;
+GRANT USAGE ON SCHEMA public TO "lims2_staging_rw";
+GRANT USAGE ON SCHEMA public TO "lims2_staging_ro";
+
+DROP SCHEMA IF EXISTS audit CASCADE;
+CREATE SCHEMA audit AUTHORIZATION "lims2_staging_admin";
+REVOKE ALL ON SCHEMA audit FROM PUBLIC;
+GRANT USAGE ON SCHEMA audit TO "lims2_staging_rw";
+GRANT USAGE ON SCHEMA audit TO "lims2_staging_ro";
View
7 ddl/lims2_staging/test_roles.sql
@@ -0,0 +1,7 @@
+
+
+CREATE ROLE "lims2_staging_test_admin" WITH NOLOGIN NOINHERIT;
+CREATE ROLE "lims2_staging_test" WITH ENCRYPTED PASSWORD 'vTnpa0MTXeoX' LOGIN INHERIT IN ROLE "lims2_staging_rw";
+
+GRANT "lims2_staging_test_admin" TO "lims2_staging_test";
+GRANT "lims2_staging_admin" TO "lims2_staging_test_admin";
View
428 ddl/lims2_staging/versions/1/audit-up.sql
@@ -0,0 +1,428 @@
+CREATE TABLE audit.roles (
+audit_op CHAR(1) NOT NULL CHECK (audit_op IN ('D','I','U')),
+audit_user TEXT NOT NULL,
+audit_stamp TIMESTAMP NOT NULL,
+audit_txid INTEGER NOT NULL,
+id integer,
+name text
+);
+GRANT SELECT ON audit.roles TO lims2_staging_ro;
+GRANT SELECT,INSERT ON audit.roles TO lims2_staging_rw;
+CREATE OR REPLACE FUNCTION public.process_roles_audit()
+RETURNS TRIGGER AS $roles_audit$
+ BEGIN
+ IF (TG_OP = 'DELETE') THEN
+ INSERT INTO audit.roles SELECT 'D', user, now(), txid_current(), OLD.*;
+ ELSIF (TG_OP = 'UPDATE') THEN
+ INSERT INTO audit.roles SELECT 'U', user, now(), txid_current(), NEW.*;
+ ELSIF (TG_OP = 'INSERT') THEN
+ INSERT INTO audit.roles SELECT 'I', user, now(), txid_current(), NEW.*;
+ END IF;
+ RETURN NULL;
+ END;
+$roles_audit$ LANGUAGE plpgsql;
+CREATE TRIGGER roles_audit
+AFTER INSERT OR UPDATE OR DELETE ON public.roles
+ FOR EACH ROW EXECUTE PROCEDURE public.process_roles_audit();
+CREATE TABLE audit.qc_seq_project_wells (
+audit_op CHAR(1) NOT NULL CHECK (audit_op IN ('D','I','U')),
+audit_user TEXT NOT NULL,
+audit_stamp TIMESTAMP NOT NULL,
+audit_txid INTEGER NOT NULL,
+id integer,
+qc_seq_project_id text,
+plate_name text,
+well_name text
+);
+GRANT SELECT ON audit.qc_seq_project_wells TO lims2_staging_ro;
+GRANT SELECT,INSERT ON audit.qc_seq_project_wells TO lims2_staging_rw;
+CREATE OR REPLACE FUNCTION public.process_qc_seq_project_wells_audit()
+RETURNS TRIGGER AS $qc_seq_project_wells_audit$
+ BEGIN
+ IF (TG_OP = 'DELETE') THEN
+ INSERT INTO audit.qc_seq_project_wells SELECT 'D', user, now(), txid_current(), OLD.*;
+ ELSIF (TG_OP = 'UPDATE') THEN
+ INSERT INTO audit.qc_seq_project_wells SELECT 'U', user, now(), txid_current(), NEW.*;
+ ELSIF (TG_OP = 'INSERT') THEN
+ INSERT INTO audit.qc_seq_project_wells SELECT 'I', user, now(), txid_current(), NEW.*;
+ END IF;
+ RETURN NULL;
+ END;
+$qc_seq_project_wells_audit$ LANGUAGE plpgsql;
+CREATE TRIGGER qc_seq_project_wells_audit
+AFTER INSERT OR UPDATE OR DELETE ON public.qc_seq_project_wells
+ FOR EACH ROW EXECUTE PROCEDURE public.process_qc_seq_project_wells_audit();
+CREATE TABLE audit.schema_versions (
+audit_op CHAR(1) NOT NULL CHECK (audit_op IN ('D','I','U')),
+audit_user TEXT NOT NULL,
+audit_stamp TIMESTAMP NOT NULL,
+audit_txid INTEGER NOT NULL,
+version integer,
+deployed_at timestamp without time zone
+);
+GRANT SELECT ON audit.schema_versions TO lims2_staging_ro;
+GRANT SELECT,INSERT ON audit.schema_versions TO lims2_staging_rw;
+CREATE OR REPLACE FUNCTION public.process_schema_versions_audit()
+RETURNS TRIGGER AS $schema_versions_audit$
+ BEGIN
+ IF (TG_OP = 'DELETE') THEN
+ INSERT INTO audit.schema_versions SELECT 'D', user, now(), txid_current(), OLD.*;
+ ELSIF (TG_OP = 'UPDATE') THEN
+ INSERT INTO audit.schema_versions SELECT 'U', user, now(), txid_current(), NEW.*;
+ ELSIF (TG_OP = 'INSERT') THEN
+ INSERT INTO audit.schema_versions SELECT 'I', user, now(), txid_current(), NEW.*;
+ END IF;
+ RETURN NULL;
+ END;
+$schema_versions_audit$ LANGUAGE plpgsql;
+CREATE TRIGGER schema_versions_audit
+AFTER INSERT OR UPDATE OR DELETE ON public.schema_versions
+ FOR EACH ROW EXECUTE PROCEDURE public.process_schema_versions_audit();
+CREATE TABLE audit.qc_alignments (
+audit_op CHAR(1) NOT NULL CHECK (audit_op IN ('D','I','U')),
+audit_user TEXT NOT NULL,
+audit_stamp TIMESTAMP NOT NULL,
+audit_txid INTEGER NOT NULL,
+id integer,
+qc_seq_read_id text,
+qc_eng_seq_id integer,
+primer_name text,
+query_start integer,
+query_end integer,
+query_strand integer,
+target_start integer,
+target_end integer,
+target_strand integer,
+score integer,
+pass boolean,
+features text,
+cigar text,
+op_str text
+);
+GRANT SELECT ON audit.qc_alignments TO lims2_staging_ro;
+GRANT SELECT,INSERT ON audit.qc_alignments TO lims2_staging_rw;
+CREATE OR REPLACE FUNCTION public.process_qc_alignments_audit()
+RETURNS TRIGGER AS $qc_alignments_audit$
+ BEGIN
+ IF (TG_OP = 'DELETE') THEN
+ INSERT INTO audit.qc_alignments SELECT 'D', user, now(), txid_current(), OLD.*;
+ ELSIF (TG_OP = 'UPDATE') THEN
+ INSERT INTO audit.qc_alignments SELECT 'U', user, now(), txid_current(), NEW.*;
+ ELSIF (TG_OP = 'INSERT') THEN
+ INSERT INTO audit.qc_alignments SELECT 'I', user, now(), txid_current(), NEW.*;
+ END IF;
+ RETURN NULL;
+ END;
+$qc_alignments_audit$ LANGUAGE plpgsql;
+CREATE TRIGGER qc_alignments_audit
+AFTER INSERT OR UPDATE OR DELETE ON public.qc_alignments
+ FOR EACH ROW EXECUTE PROCEDURE public.process_qc_alignments_audit();
+CREATE TABLE audit.user_role (
+audit_op CHAR(1) NOT NULL CHECK (audit_op IN ('D','I','U')),
+audit_user TEXT NOT NULL,
+audit_stamp TIMESTAMP NOT NULL,