I would like to change the name and location of the prisma folder. Currently it called prisma and it sits on the root folder of my nextjs project. I'd like to name it db and have it within the src folder. Is that possible? If so, how?
The prisma docs explain how to do this: https://www.prisma.io/docs/concepts/components/prisma-schema#prisma-schema-file-location
For my particular situation, I added the following code to package.json:
"prisma": {
"schema": "src/db/schema.prisma"
},
That changed the location to a folder called db inside of the src folder. I tested it out it works exactly as I wanted -- migrations and all.
Related
I'm trying the Play framework with Scala and Slick for data access.
I'm playing with the play-scala-intro example app. I'm trying to set up my own database instead of using the bundled in memory H2 database.
I can't figure out how to specify the path to the database file.
If the code in application.conf reads:
slick.dbs.default.db.url="jdbc:sqlite:/test.db"
slick.dbs.default.db.driver="org.sqlite.JDBC"
where should my test.db file be placed?
Does that mean the test.db file should be in the home directory of the web app, meaning the root play-scala-intro dir, or the app/assets dir?
I'd say storing your database in Java resources (and that's where assets will end up) doesn't sound like a good idea to me. I would be surprised if nothing went wrong during e.g. writing to DB.
It would be better to have it in the same directory as JAR, and even better set some defaults and let them be overridden:
database.location="test.db"
database.location=${?DBLOCATION}
slick.dbs.default.db.url="jdbc:sqlite:"${database.location}
This should assume that your database is names test.db and placed in your working directory (see: https://stackoverflow.com/a/21061029/1305121). It can be overridden using environment variable DBLOCATION like:
export DBLOCATION="/tmp/my/database.db"
# run Play application
I have a directory with deep structure (lot of sub-directories and files) that I read from my play application. On my PC I read the directory using -
val directory = Play.getFile("directory")
for(file <- directory.listFiles) {
val lines = Source.fromFile(file).getLines()
}
This works perfectly on my PC but not on Heroku. On Heroku I get a NPE on line#2 (above code) which means that the directory object is not getting made.
This suggestion of a similar issue suggests that I could put my directory in public and read it as using the Play.resource API. But I DONT want to put my directory in public. And I have a need to list the contents of a directory as it could be changing... how can I do this in Play on Heroku?
As this suggests,in order to make Play.getFile("location_from_project_root") (or any other similar one) working in production environment, you have to explicitly ask from play to add the directory where you put the file ,to the dist.
Ex:
You want to access a file Project_Root/resources/mtFile.json, (inside /resources folder you created), you can use Play.getFile("/resources/mtFile.json")method.
But in order to make it works in any production environment, you have to add /resources folder to the dist. Otherwise that file will not be there. In order to do that you have to add these lines into your build.sbt file.
import com.typesafe.sbt.packager.MappingsHelper._
mappings in Universal ++= directory(baseDirectory.value / "resources")
Now, if you take a dist using activator dist command you can see that a directory called /resources has added into the root of the dist. Now Play.getFile("/resources/mtFile.json") should work in production environment.
Play.getFile(relativePath) retrieves a file relative to the current app's root path. Current app's root path may not be same on your PC and Heroku.
One more thing: Your statement that the directory object is not getting made is not true. listFiles operation is throwing NPE in your case.
Try this to get a list of files from your directory:
val listOfFilesInDirectory: List[java.io.File] = Option(getClass.getResource("/directory")).map(_.toURI).map(new java.io.File(_)).map(_.listFiles).flatten.toList
You can put your files under your conf folder, so that the files are not publicly available. Then use :
Play.resource("conf/directory"): Option[URL]
or
Play.resourceAsStream("conf/directory"): Option[InputStream]
I have created a Derby Embeded DB in netbeans. Now I can not find the folder in which DB is placed by netbeans.
My connection URL is jdbc:derby:Inventory;create=true;.
Where does netbeans place the DB file by default?
I am using Ubuntu 12.04.
The Default Linux Netbeans Database Folder :
/home/username/.netbeans-derby/
there is a folder Inventory
netbeans 7.2.1 :
/home/username/.netbeans/7.2.1/derby/
you can search with
sudo find / -name Inventory -print
Properties :
right click Java DB select Create Database.
The database name "Inventory" is a relative name, so it will be located in the "Inventory" subdirectory of the Derby home directory. The Derby home directory defaults to the current working directory when your program runs. So you just have to figure out where the current working directory is when your program runs.
However, this is rather the hard way to go about things. Instead, change your connection URL so that it specifies an absolute name, such as
jdbc:derby:/home/tariq/myDerbyDBs/Inventory
and then you will easily be able to find your database. (Make sure that you create the '/home/tariq/myDerbyDBs' directory first.)
I use Capifony to deploy my Symfony2 project to the production server. As a result of the deploy:setup task, folder called /shared/logs were created. However the symfony2 actually refers to /shared/app/logs to store the log files while the shared/logs remains empty.
Anyone know what's happening?
The shared/logs folder is no more created since capifony version 2.1.7.
I've just checked the latest capistrano deploy recipe in trunk and it seems like this's a default behaviour of Capistrano instead of Capifony. It create folders using only the last part of the path of the shared_children array instead of including the full path. Later on in the task deploy:shared_children of Capfifony it create the sub folders with full path.
I am trying to automate deployments of a particular project and a bit lost as to who to handle config file as well as user assets.
(Application is based on Zend Framework based btw).
Main application folder is structured as follows:
./app
./config.ini <----- config file
./modules
./controllers
./models
./views
./libs
./public
That config file is where all the configs are stored.
So 'app' folder contains whole bunch of code in PHP and 'public' contains whole bunch of code in JavaScript, HTML/CSS and stuff like that(web accessible basically).
If I follow Capistrano's model, where each package is expanded into it's own folder that is then symlinked to, how do I handle that config.ini file?
What about all the user content that is uploaded into ./public folder?
Thanks!
The Capistrano approach to this is to have a structure like this on your remote server:
releases/
20100901172311/
20101001101232/
[...]
current/ (symlink to current release)
shared/
in the shared directory you include your config file and any user generated content (e.g. shared/files). Then on each deployment, once you've checked out the code you automatically create symlinks from the checkout into your relevant shared directories. E.g.:
releases/20101001101232/public/files -> shared/files
releases/20101001101232/application/configs/config.ini -> shared/config.ini
that way, when a user uploads a file to public/files it is actually being stored in shared/files.