Bug 10337 - Add a script to insert all sample data automatically
Summary: Add a script to insert all sample data automatically
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Command-line Utilities (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Jonathan Druart
QA Contact:
URL:
Keywords:
: 15392 (view as bug list)
Depends on:
Blocks: 17529 17544 17567 24397
  Show dependency treegraph
 
Reported: 2013-05-24 14:41 UTC by Jonathan Druart
Modified: 2020-05-14 23:07 UTC (History)
8 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 10337: Unit tests is based on an existing database (4.54 KB, patch)
2013-05-24 14:50 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 10337: Unit tests is based on an existing database (4.74 KB, patch)
2013-05-24 14:54 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 10337: Unit tests is based on an existing database (4.92 KB, patch)
2015-09-22 13:21 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 10337: Add a script to populate devs' DBs with sample data (5.57 KB, patch)
2016-10-17 16:55 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 10337: Add a script to populate devs' DBs with sample data (5.62 KB, patch)
2016-10-18 07:45 UTC, Chris Cormack
Details | Diff | Splinter Review
Bug 10337: Add a script to populate devs' DBs with sample data (5.67 KB, patch)
2016-10-18 13:28 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 10337: (QA followup) Allow choosing MARC flavour (4.24 KB, patch)
2016-10-18 13:28 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 10337: (followup) Upper case MARC flavour (959 bytes, patch)
2016-10-18 15:04 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Druart 2013-05-24 14:41:49 UTC
Currently, only jenkins is able to launch tests successfully.
It would great to have a file in the db_dependent directory to initialize the database structure with sample data.
Like that all developers will be able to launch unit tests and check if a development breaks something.
Comment 1 Jonathan Druart 2013-05-24 14:50:25 UTC Comment hidden (obsolete)
Comment 2 Jonathan Druart 2013-05-24 14:53:08 UTC
This patch is proposed for discussion.
Comment 3 Jonathan Druart 2013-05-24 14:54:35 UTC Comment hidden (obsolete)
Comment 4 Chris Cormack 2013-12-27 01:12:25 UTC
I like this idea, it might be nicer to rework it to use the new schema rather than kohastructure.sql now though.

That way we could test deploying the schema also.
Comment 5 Martin Renvoize (ashimema) 2014-12-30 08:30:49 UTC
I'm wondering if https://metacpan.org/pod/DBIx::Class::Fixtures may actaully be a nicer way to impliment this now?
Comment 6 Jonathan Druart 2015-09-22 13:21:36 UTC
Created attachment 42784 [details] [review]
Bug 10337: Unit tests is based on an existing database

This patchs adds a new unit tests file which will launched before all
others db_dependent tests.
It will drop and recreate the database with sample data.

Prerequisite:
The database 'koha_ut' have to be created with
  CREATE DATABASE $dbname CHARACTER SET utf8 COLLATE utf8_bin
Comment 7 Jonathan Druart 2016-10-17 16:42:40 UTC
I reworked this patch to create a misc/devel script inserting all the sample data in the DB.
Comment 8 Jonathan Druart 2016-10-17 16:55:58 UTC
Created attachment 56607 [details] [review]
Bug 10337: Add a script to populate devs' DBs with sample data

Executing the installer process and inserting all the sample data take a
lot of clics and time.
The idea of this script is to provide a quick way to insert all the
sample data easily to get a working Koha install asap.

Test plan:
- Set your database config to a non-existent DB
- Execute perl misc/devel/populate_db.pl
You will get an error
- Create an empty DB
- Execute perl misc/devel/populate_db.pl
It will insert all the MARC21 sample data
- Execute perl misc/devel/populate_db.pl
You will get an error because the DB is not empty (systempreferences and
borrowers tables)
Comment 9 Tomás Cohen Arazi (tcohen) 2016-10-17 19:18:17 UTC
*** Bug 15392 has been marked as a duplicate of this bug. ***
Comment 10 Chris Cormack 2016-10-18 07:45:38 UTC
Created attachment 56614 [details] [review]
Bug 10337: Add a script to populate devs' DBs with sample data

Executing the installer process and inserting all the sample data take a
lot of clics and time.
The idea of this script is to provide a quick way to insert all the
sample data easily to get a working Koha install asap.

Test plan:
- Set your database config to a non-existent DB
- Execute perl misc/devel/populate_db.pl
You will get an error
- Create an empty DB
- Execute perl misc/devel/populate_db.pl
It will insert all the MARC21 sample data
- Execute perl misc/devel/populate_db.pl
You will get an error because the DB is not empty (systempreferences and
borrowers tables)

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Comment 11 Tomás Cohen Arazi (tcohen) 2016-10-18 13:28:04 UTC
Created attachment 56621 [details] [review]
Bug 10337: Add a script to populate devs' DBs with sample data

Executing the installer process and inserting all the sample data take a
lot of clics and time.
The idea of this script is to provide a quick way to insert all the
sample data easily to get a working Koha install asap.

Test plan:
- Set your database config to a non-existent DB
- Execute perl misc/devel/populate_db.pl
You will get an error
- Create an empty DB
- Execute perl misc/devel/populate_db.pl
It will insert all the MARC21 sample data
- Execute perl misc/devel/populate_db.pl
You will get an error because the DB is not empty (systempreferences and
borrowers tables)

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 12 Tomás Cohen Arazi (tcohen) 2016-10-18 13:28:12 UTC
Created attachment 56622 [details] [review]
Bug 10337: (QA followup) Allow choosing MARC flavour

This patch enables the --marcflavour option switch so the user
can specify the desired marc flavour. The code for handling it
was already in place, just not used.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 13 Tomás Cohen Arazi (tcohen) 2016-10-18 15:04:09 UTC
Created attachment 56625 [details] [review]
Bug 10337: (followup) Upper case MARC flavour

This patch makes the populate_db.pl script upper case what gets passed
with the --marcflavour option switch. This is needed in order for this
to fit ``kohadevbox`` configuration files, and it is harmless for other
uses.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 14 Kyle M Hall (khall) 2016-10-21 14:11:34 UTC
Push to master for 16.11, thanks Jonathan!
Comment 15 Frédéric Demians 2016-10-22 12:56:20 UTC
Pushed in 16.05. Will be in 16.05.05.
Comment 16 David Cook 2020-05-14 01:02:43 UTC
Should this script be removed now that we use misc4dev?
Comment 17 Jonathan Druart 2020-05-14 08:45:01 UTC
(In reply to David Cook from comment #16)
> Should this script be removed now that we use misc4dev?

Related bug removed it
Comment 18 David Cook 2020-05-14 23:07:17 UTC
(In reply to Jonathan Druart from comment #17)
> Related bug removed it

Thanks, Jonathan. I was looking at a slightly out of date 19.11 ﷐[U+1F605]﷑